Make text bigger  Make text smaller  Toggle background color  Bookmark/Share


CUSTOM FONT UPLOADER FOR WORDPRESS THEMES

Font-Uploader-Image Custom Font Uploader for Wordpress Themes

WordPress thesis choice panels were a endless walk in a universe of thesis development; they gave site owner’s a capability to cgange assorted aspects of their site, though ever carrying to hold a code. Every good thesis presumably has or should have an endless options panel.

In this tutorial, I’m starting to denote how to supplement a law rise uploader to your options panel. This will concede site owners to upload any series of rise files as good as request them to opposite sections of a site.

As a designer, we tremble a small at a suspicion of clients presumably screwing up my delicately comparison fonts with their own rambling selection, but, in a end, it’s what a customer wants.

Before Starting

To begin, we initial need to emanate your options panel. For this task, we suggest we follow Rohan Mehta’s educational over on Net Tuts. It’s a most appropriate educational I’ve found on this subject as good as will yield we with roughly all we need for this tutorial.

#1 – The Essentials

The initial thing we need to do is emanate a printed matter called fonts in a thesis directory. Your Structure should demeanour identical to this:

  • wp-content
    • themes
      • your_theme_folder
        • fonts

For confidence reasons, set a permissions of this printed matter to 774. This will concede a server to read, govern as good as write, whilst disallowing any open write / govern privileges.

You will additionally need to safeguard we have a functions.php file, which, of course, we do since you’ve already followed a Net Tuts tutorial, or combined an options page of your own ;-)

#2 – The Upload Script

In sequence to essentially upload files, such as law fonts, we need to emanate a php upload script.

Save this as upload.php in your thesis printed matter (the same place we combined a uploads folder):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
//include inner wordpress functions
require($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');
 
//define a adage distance for a uploaded files
define ("MAX_SIZE","20000000");
 
//This duty reads a prolongation of a file. It is used to establish if a record  is an rise by checking a extension.
function getExtension($str)
{
   $parts = explode('.', $str);
   return end($parts);
}
 
//This non-static is used as a flag. The worth is initialized with 0 (meaning no blunder  found)  
//and it will be altered to 1 if an errro occures.  
//If a blunder occures a record will not be uploaded.
 $errors=0;
//checks if a form has been submitted
 if(isset($_POST['Submit']))
 {
 	//reads a name of a record a user submitted for uploading
 	$font=$_FILES['font']['name'];
 	//if it is not empty
 	if ($font)
 	{
	 	//get a strange name of a record from a clients machine
	 		$filename = stripslashes($_FILES['font']['name']);
	 	//get a prolongation of a record in a reduce box format
	  		$extension = getExtension($filename);
	 		$extension = strtolower($extension);
	 	//if it is not a good known extension, we will suspect it is an blunder as good as will not upload a file,
	 	//we will usually concede .ttf as good as .otf record extensions  
		//otherwise we will do some-more tests
		if (($extension != "ttf") && ($extension != "otf"))
	 	{
			//print blunder message
	 		echo '<h1>Unknown extension!</h1>';
	 		$errors=1;
	 	}
	 	else
	 	{
			//check a mimetypes opposite an authorised list
			$mime = array ("application/x-font-ttf", "application/vnd.oasis.opendocument.forumla-template", "application/octet-stream");
 
			if (!in_array($_FILES['font']['type'],$mime))
			{
		 		echo '<h1>Unknown mimetype!</h1>';
				$errors=1;
			}
			//get a distance of a record in bytes
			//$_FILES['image']['tmp_name'] is a proxy filename of a file
			//in which a uploaded record was stored on a server
			$size=filesize($_FILES['font']['tmp_name']);
			//compare a distance with a adage distance we tangible as good as imitation blunder if bigger
			if ($size > MAX_SIZE)
			{
				echo '<h1>You have exceeded a distance limit!</h1>';
				$errors=1;
			}
			//keep a strange record name
			$font_name=$filename;
 
			if (!$errors)
			{
				//the brand new name will be containing a full trail where fonts will be stored (fonts folder)
				$newname="fonts/".$font_name;
				//we determine if a picture has been uploaded, as good as imitation blunder instead
				$copied = copy($_FILES['font']['tmp_name'], $newname);
				if (!$copied)
				{
					echo '<h1>Copy unsuccessfull!</h1>';
					$errors=1;
				}
			}
		}
	}
	//If no errors registred, route behind to a thesis options panel
	if(isset($_POST['Submit']) && !$errors)
	{
	$url = get_bloginfo('url') . '/wp-admin/admin.php?page=functions.php';
 
	header ("Location: $url");
	}
 }
 ?>

For explanations of how this book works, review a embedded comments.

#3 – Embed a Upload Script

We right away need to emanate a upload form in a options row which will concede us to essentially upload rise files to a server.

Place this in your functions.php:

1
2
3
4
5
6
7
8
9
10
11
	<h2>Upload Fonts</h2>
	<p><em>Filetypes accepted: <strong>.ttf</strong> as good as <strong>.otf</strong></em></p>
	<p>Uploaded fonts will crop up in a <strong>FONTS</strong> menu below</p>
	<form name="newad" method="post" enctype="multipart/form-data"  action="<?php bloginfo('template_directory');?>/upload.php">
	 <table>
	 	<tr>
	 		<td><input type="file" name="font"></td>
	 		<td><input name="Submit" type="submit" value="Upload"></td>
	 	</tr>
	 </table>
	</form>

This formula provides an interface to a upload.php which we combined earlier, as good as it looks identical to this:

upload form

Important! In a Net Tuts tutorial, we combined a territory in functions.php which displays a thesis options in a list formed layout. The on top of formula should be placed identical to this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<div class="wrap rm_wrap">
    <h2><?php echo $themename; ?> Settings</h2>
    <div class="rm_opts">
 
        //upload form starts here
 
	<h2>Upload Fonts</h2>
	<p><em>Filetypes accepted: <strong>.ttf</strong> as good as <strong>.otf</strong></em></p>
	<p>Uploaded fonts will crop up in a <strong>FONTS</strong> menu below</p>
	<form name="newad" method="post" enctype="multipart/form-data"  action="<?php bloginfo('template_directory');?>/upload.php">
	 <table>
	 	<tr>
	 		<td><input type="file" name="font"></td>
	 		<td><input name="Submit" type="submit" value="Upload"></td>
	 	</tr>
	 </table>
	</form>
 
       //upload form ends here
 
 <form method="post">
 
<?php
                foreach ($options as $value):
                    switch ( $value['type'] ):
                        case "open":
                            break;
 
                        case "close":
?>
. . .

If we do not place a upload form in a scold area, it will not uncover up in your thesis options panel.

#4 – List a Available Fonts

We have combined a capability to upload fonts as good as store them in a printed matter called fonts. Now we have been starting to emanate a duty to list all of a accessible fonts inside a thesis options panel.

Place this formula in your functions.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$fontsList = array();
$fontDirectoryURL = $_SERVER['DOCUMENT_ROOT'] . get_bloginfo('template_directory') . '/fonts';
$removeSiteURL = get_bloginfo('url');
$fontDirectoryPath = str_replace($removeSiteURL, "", $fontDirectoryURL);
$fontURL = get_bloginfo('template_directory') . '/fonts';
$fontDir = opendir($fontDirectoryPath);
while(($font = readdir($fontDir)) !== false)
	{
		if($font != '.' && $font != '..' && !is_file($font) && $font != '.htaccess' && $font != 'resource.frk' && !eregi('^Icon',$font))
			{
				$fontList[] = $fontURL."/".$font;
			}
	}
closedir($fontDir);
array_unshift($fontList, "Choose a font");

just after

1
2
$themename = "Theme-Name";
$shortname = "sn";

These dual lines have been combined in a Net Tuts article.

This is a duty which functions identical to this:

  • create a url which will be used to entrance a rise files in a CSS
  • open a rise directory
  • read all files contained in a directory
  • exclude sure record names as good as directories
  • place all fonts found inside a list

#5 – Create a Font Options

Anywhere between a rest of your thesis options combined in a Net Tuts article, place this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    array( "name" => "Fonts",
        "type" => "section"),
    array( "type" => "open"),
 
	 array( "name" => "Headers",
		"desc" => "Choose a font",
		"id" => $shortname."_header_font",
		"type" => "select",
		"options" => $fontList),
 
	 array( "name" => "Navigation",
		"desc" => "Choose a font",
		"id" => $shortname."_nav_font",
		"type" => "select",
		"options" => $fontList),
 
	 array( "name" => "Main Body",
		"desc" => "Choose a font",
		"id" => $shortname."_body_font",
		"type" => "select",
		"options" => $fontList),
 
	 array( "name" => "Footer",
		"desc" => "Choose a font",
		"id" => $shortname."_footer_font",
		"type" => "select",
		"options" => $fontList),
 
    array( "type" => "close"),

#6 – The CSS Part One

We’re starting to embody a fonts in a header.php record so which we can request them to a web elements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<style type="text/css" media="screen">
@font-face {
  font-family: "header-font";
  src: url("<?php relate get_option('sn_header_font'); ?>");
}
@font-face {
  font-family: "nav-font";
  src: url("<?php relate get_option('sn_nav_font'); ?>");
}
@font-face {
  font-family: "body-font";
  src: url("<?php relate get_option('sn_body_font'); ?>");
}
@font-face {
  font-family: "footer-font";
  src: url("<?php relate get_option('sn_footer_font'); ?>");
}
</style>

Important! Do not dont think about to reinstate sn with your own theme’s reduced name.

#6 – The CSS Part Two

In your style.css file:

1
2
3
4
5
6
7
8
9
10
11
12
h1,h2,h3,h4,h5,h6,h7  {
  font-family: "header-font";
}
p  {
  font-family: "body-font";
}
.navigation  {
  font-family: "nav-font";
}
#footer p  {
  font-family: "footer-font";
}

That’s it! Your last result should demeanour identical to this (unless we used your own thesis options page rsther than than following Net Tuts’):

font uploader

#7 – Going Further

The complement we’ve combined functions really good as good as is significantly improved than any wordpress rise plugin I’ve been means to find. Here have been a small suggestions for starting a small serve as good as creation it even better:

  • Add jQuery as good as or Ajax to a upload form to forestall reloading of a page as good as to emanate cleanser blunder / success messages
  • Create options for some-more specific site elements, such as p tags with a category of “antique”, rsther than than only general elements as I’ve finished above.
  • Allow some-more rise record sorts by adding their mime sorts as good as extensions to upload.php

 Custom Font Uploader for Wordpress Themes

See strange here:
Custom Font Uploader for Wordpress Themes


Get Auto Caffeinated Content for Your WordPress Blog



30 PRO JQUERY TIPS, TRICKS AND STRATEGIES

jquery-banner 30 Pro jQuery Tips, Tricks and Strategies

Whether you’re a developer or a designer, a clever jQuery skillset is something we can’t equates to to be without. Today, I’m starting to uncover we thirty accessible jQuery coding tricks that will assistance we have your scripts some-more robust, superb as good as professional.

Getting Started

These tips as good as tricks all have a single thing in common- they have been all smashingly useful. With this things in your behind pocket, you’ll be ready to go shift a world, as good as even better, write jQuery identical to we know what you’re doing. It’s gonna be fun.

We’ll begin with a small elementary tricks, as good as pierce to a small some-more modernized things identical to essentially fluctuating jQuery’s methods as good as filters. Of course, we should be informed with a basis of jQuery first. If we haven’t used jQuery before, we rarely suggest browsing a documentation as good as examination jQuery for Absolute Beginners Video Series. Otherwise, you’re ready to puncture in!

#1 – Delay with Animate()

animate 30 Pro jQuery Tips, Tricks and Strategies

This is a unequivocally quick, easy approach to equates to behind actions in jQuery yet regulating setTimeout. The approach we have it work is to supplement an spur duty in to your sequence as good as spur a component to 100% opacity (which it’s already at), so it looks identical to zero is happening.

For instance, let’s contend that we longed for to open a dialog as good as afterwards blur it divided after 5 seconds. Using animate, we can do it identical to this:

1
2
3
$(function(){
	$("body").append("<div class='dialog'></div>").<em>animate({ opacity : 1.0 }, 5000)</em>.fadeOut();
});

Don’t we usually adore jQuery chaining? You’re acquire to review some-more about this technique from Karl Swedberg.

UPDATE: jQuery 1.4 has separated a need for this penetrate with a process called delay(). It is usually what is sounds identical to – a duty privately finished to check an existence effect. Way to go, jQuery!

#2 – Loop by Elements Backwards

One of my personal favorites is being equates to to double behind retrograde by a set of elements. We all know each() lets us simply double behind by elements, yet what if we need to go backwards? Here’s a trick:

1
2
3
4
5
6
7
8
$(function(){
	var reversedSet = $("li").get().reverse();
	//Use get() to lapse an form of elements, as good as afterwards retreat it
 
	$(reversedSet).each(function(){
		//Now we can block a topsy-turvy set right in to a any function. Could it be easier?
	});
});

#3 – Is There Anything in a jQuery Object?

Another unequivocally facile yet continually utilitarian pretence is checking if there have been any elements in a jQuery object. For example, let’s contend we need to find out if there have been any elements with a category of ‘active’ in a DOM. You can do that with a discerning check of a jQuery object’s length skill identical to this:

1
2
3
4
5
$(function(){
	if( $(".active").length ){
		//Now a formula here will usually be executed if there is at slightest a single active element
	}
});

This functions since 0 evaluates false, so a countenance usually evaluates loyal if there is at slightest a single component in a jQuery object. You can additionally have have have have have have have have make make make make make use of of of of of of of of of of of of of size() to do a same thing.

#4 – Access iFrame Elements

Iframes aren’t a most appropriate resolution to most problems, yet when we do need to have have have have have have have have make make make make make use of of of of of of of of of of of of of a single it’s unequivocally accessible to know how to entrance a elements inside it with Javascript. jQuery’s contents() process creates this a breeze, enabling us to bucket a iframe’s DOM in a single line identical to this:

1
2
3
4
5
6
7
$(function(){
	var iFrameDOM = $("iframe#someID").contents();
	//Now we can have have have have have have have have make make make make make use of of of of of of of of of of of of of <strong>find()</strong> to entrance any component in a iframe:
 
	iFrameDOM.find(".message").slideUp();
	//Slides up all elements classed 'message' in a iframe
});

#5 – Equal Height Columns

This was a single of CSS Newbie’s most renouned posts of 2009, as good as it is a good, plain pretence to have in your toolbox. The duty functions by usurpation a organisation of columns, measuring any a single to see that is largest, as good as afterwards resizing them all to compare a greatest one. Here’s a formula (slighly modified):

1
2
3
4
5
6
7
8
9
10
11
12
$(function(){
	jQuery.fn.equalHeight = function () {
		var tallest = 0;
		this.each(function() {
			tallest = ($(this).height() > tallest)? $(this).height() : tallest;
		});
		return this.height(tallest);
	}
 
	//Now we can call equalHeight
	$(".content-column").equalHeight();
});

An engaging as good as identical judgment is a overwhelming jQuery masonry plugin, if you’re meddlesome in checking it out.

#6 – Find a Selected Phrase as good as Manipulate It

Whether you’re seeking to perform find as good as replace, prominence poke terms, or something else, jQuery again creates it easy with html():

1
2
3
4
5
6
7
8
9
10
11
12
$(function(){
	//First conclude your poke string, deputy as good as context:
	var word = "your poke string";
	var deputy = "new string";
	var context = $(body);
 
	//
	context.html(
		context.html().replace('/'+phrase+'/gi', replacement);
	);
 
});

#7 – Hack Your Titles to Prevent Widows

Nobody likes to see widows – yet thankfully with a small jQuery as good as a small assistance from &nbsp; we can stop that from happening:

1
2
3
4
5
6
7
8
$(function(){
	//Loop by any title
	$("h3").each(function(){
		var calm = $(this).text().split(" ");
		var widow = "&amp;nbsp;"+content.pop();
		$(this).html(content.join(" ")+widow);
	});
});

This technique was referred to in a criticism by Bill Brown on Css-Tricks.

#8 – Add Pseudo-Selector Support in IE

Whether or not to await IE (especially 6) is a hotly debated issue, yet if we have been of a “let’s-make-the-best-of-this” camp, it’s good to know that we can supplement pseudo-selector await with jQuery. And we aren’t usually singular to :hover, nonetheless that’s a most common:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$(function(){
	<strong>//ADD HOVER SUPPORT:</strong>
	function hoverOn(){
		var currentClass = $(this).attr('class').split(' ')[0]; //Get initial category name
		$(this).addClass(currentClass + '-hover');
	}
	function hoverOff(){
		var currentClass = $(this).attr('class').split(' ')[0]; //Get initial category name
		$(this).removeClass(currentClass + '-hover');
	}
	$(".nav-item").hover(hoverOn,hoverOff);
 
	<strong>//ADD FIRST-CHILD SUPPORT:</strong>
	jQuery.fn.firstChild = function(){
		return this.each(function(){
			var currentClass = $(this).attr('class').split(' ')[0]; //Get initial category name
			$(this).children(":first").addClass(currentClass + '-first-child');
		});
	}
	$(".searchform").firstChild();
});

The good thing about environment it up that approach firstChild(), hoverOn() as good as hoverOff() have been unequivocally reusable. Now, in a CSS we can simply supplement a ‘nav-item-hover’ or ’searchform-first-child’ classes as a single some-more selectors:

1
2
3
4
5
6
7
8
.nav-item:hover, <strong>.nav-item-hover</strong>{
	background:#FFFFFF;
	border: solid 3px #888;
}
.searchform:first-child, <strong>.searchform-first-child</strong>{
	background:#FFFFFF;
	border: solid 3px #888;
}

It’s not pretty, yet it is current as good as it works. I’ve got to say, though, that we certain am seeking brazen to a day we won’t have to worry with this stuff!

#9 – Manage Search Box Values

A renouned outcome is to fill a site’s poke box with a worth (like ’search…’) as good as afterwards have have have have have have have have make make make make make use of of of of of of of of of of of of of jQuery to transparent a default worth when a margin receives focus, reverting if a margin is dull when blurred. That is simply achieved with a integrate lines of jQuery:

1
2
3
4
5
6
7
8
9
$(function(){
	//set default value:
	$("#searchbox")
	  .val('search?');
	  .focus(function(){this.val('')})
	  .blur(function(){
		(this.val() === '')? this.val('search?') : null;
	  });
});

#10 – Create a Disappearing ‘Back-to-Top’ Link

The disintegrating back-to-top integrate was desirous by Brian Cray. All we have to do is supplement a back-to-top integrate at a bottom of your calm identical to normal, as good as afterwards jQuery performs a magic:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$(function(){
/* set variables locally for increasing opening */
	var scroll_timer,
		displayed = false,
		$message = $('#message a'),
		$window = $(window),
		top = $(document.body).children(0).position().top;
 
	/* conflict to corkscrew eventuality on window */
	$window.scroll(function () {
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout(function () { // have have have have have have have have make make make make make use of of of of of of of of of of of of of a timer for performance
			if($window.scrollTop() <= top) // censor if at a tip of a page
			{
				displayed = false;
				$message.fadeOut(500);
			}
			else if(displayed == false) // uncover if scrolling down
			{
				displayed = true;
				$message.stop(true, true).show().click(function () { $message.fadeOut(500); });
			}
		}, 100);
	});
});

Brian additionally combined a small nice-looking CSS, that we could supplement as a css record or conclude in an intent verbatim as good as ask it regulating jQuery.css(). Feel giveaway to go check out his in-depth explanation if we wish to sense more.

#11 – Easily Respond to Event Data

One of my a a single preferred things about jQuery is a available remapping of eventuality data, substantially expelling cross-browser inconsitencies as good as creation events most simpler to reply to. jQuery passes an eventuality parameter in to all bound/triggered functions, that is ordinarily called e:

1
2
3
4
5
6
7
8
9
10
11
12
$(function() {
	//We can get X/Y coordinates on click events:
	$("a").click(function(<em>e</em>){
		var clickX = e.pageX;
		var clickY = e.pageX;
	});
 
	//Or acknowledge that pass was pressed:
	$("window").keypress(function(<em>e</em>){
		var keyPressed = e.which;
	});
});

You can check out a jQuery docs on this a single to see all a possibilites, or perspective this keycode reference if you’d identical to to demeanour up a certain key’s impression code.

#12 – Encode HTML Entities

The initial place we saw this referred to was over at Debuggable, as good as we have to contend they unequivocally came up with something good here. The thought is to furnish a jQuery outcome identical to PHP’s htmlentities(). Check this out:

1
2
3
4
5
6
7
8
9
$(function(){
	var calm = $("#someElement").text();
	var text2 = "Some <code> & such to encode";
	//you can conclude a fibre or get a calm of an component or field
 
	var html = $(text).html();
	var html2 = $(text2).html();
	//Done - html as good as html2 right away reason a encoded values!
});

#13 – Friendly Text Resizing

Originally referred to at ShopDev, this is an glorious approach to embody a small user-centricity in your formula (allowing them to carry out a font-size):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$(function(){
  // Reset Font Size
  var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    $('html').css('font-size', newFontSize);
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
    $('html').css('font-size', newFontSize);
    return false;
  });
});

As we said, this is good pretence to know as good as adds a small of that energetic friendship that people suffer so much.

#14 – Open External Links in a New Window

This outmost links penetrate has been referred to prior to at Cats Who Code, as good as nonetheless unlawful it’s a good approach to open outmost links in brand brand brand brand brand brand new windows yet causing validation errors in XHTML 1.0 Strict.

1
2
3
4
5
$(function(){
	$('a[rel$='external']').click(function(){
		this.target = "_blank";
	});
});

This functions by grabbing all links with an outmost rel as good as adding a vacant target. Same result, it’s usually not hardcoded in to a site.

#15 – Gracefully Degrading AJAX Navigation

AJAX navigation is good – yet not for users as good as bots who can’t have have have have have have have have make make make make make use of of of of of of of of of of of of of it. The good headlines is, it’s probable to suggest approach links to your calm whilst still presenting AJAX functionality (to users who have that capability) by throwing links prior to they go anywhere, returning fake on them as good as loading a AJAX calm instead. It could demeanour identical to this:

1
2
3
4
5
6
$(function(){
	$("a").bind("click",function(){
		//Put your AJAX ask formula here
		return false;
	});
});

Of course, this is unequivocally basic, yet it’s an necessary facet to any AJAX navigation. You can additionally check out SpeckyBoy’s post on Easy-to-Use Free Ajax Navigation Solutions.

#16 – Create an Array of GET variables

Although this is not privately a jQuery trick, it’s utilitarian sufficient to be enclosed here. Using GET variables in Javascript formula doesn’t occur everyday, yet when it does you’ll wish to know a discerning as good as fit approach to review them. All we have to do is get document.location.search as good as do a small parsing on it:

1
2
3
4
5
6
7
8
9
10
 
var searchArray = document.location.search.substring(1).split("&");
//Take off a '?' as good as apart in to apart queries
 
//Now we'll double behind by searchArray as good as emanate an associative form (object literal) called GET
var GET = [];
for (searchTerm in searchArray){
	searchTerm.split("="); //Divide a searchTerm in to skill as good as value
	GET[searchTerm[0]] = searchTerm[1]; //Add skill as good as worth to a GET array
}

#17 – Partial Page Refresh Using load()

This glorious technique found at a Mediasoft Blog is approach cold as good as unequivocally accessible for formulating a continually updating dashboard/widget/etc. It functions by regulating jQuery.load() to perform a AJAX request:

1
2
3
4
5
$(document).ready(function() {
	setInterval(function() {
		$("#content").load(location.href+" #content>*","");
	}, 5000);
});

Voila! It functions – no iframes, meta refreshes or alternative such nonsense.

#18 – Skin with jQuery UI

If you’re starting to write any jQuery plugins (I goal we have already!), we should know that a good approach to supplement coherence as good as magnificence is to soak up jQueryUI theming classes in to any widgets/visible elements your plugin produces. The good thing about we do this is that it cuts or eliminates a css we have to yield with a plugin, as good as it adds a lot of customizability, as good (which is a single of a pass factors in a successful plugin).

And a tangible we do is as elementary as guidance how a classes work as good as attaching them to plugin elements. we can see this would be generally good with plugins identical to form beautifiers as good as print sliders, creation it easy to keep a unchanging demeanour via a website or app. You can check out a Theming Reference here.

#19 – Include Other Scripts

Stylesheet switchers have been zero new, yet adding alternative scripts with jQuery is something that is mostly overlooked. The worth is twofold:

  1. It creates it easy to have quiescent book loading.
  2. It additionally allows us to supplement scripts at runtime, that could be utilitarian in a total horde of situations.

It’s as easy as regulating append() to supplement a brand brand brand brand brand brand new book to a conduct of a document:

1
2
3
4
5
6
7
8
$(function(){
	$("head").append("<script type='text/javascript' src='somescript.js'></script>");
 
	//Or, loading usually when a delayed things is ready:
	$("img,form").load(function(){
		$("head").append("<script type='text/javascript' src='somescript.js'></script>");
	});
});

#20 – Use Body Classes for Easy Styling

Do we wish to save on formula as good as keep your styling in a css record where it should be? Body classes (another good ideas referred to by Karl Swedberg) concede we to do that. In short, we can have have have have have have have have make make make make make use of of of of of of of of of of of of of jQuery to supplement a ‘JS’ category to a physique element, that will capacitate we to set styles in your css that will usually be practical if Javascript is enabled. For example:

1
2
3
$(document).ready(function() {
	$("body").addClass("JS");
});

For Javascript users a physique right away has a JS class, so in a CSS we can supplement styles identical to this:

ul.navigation{
	display:block;
}
.JS ul.navigation{
	display:none;
}

This gives us a good approach to shift styles formed on possibly or not Javascript is supported/enabled, as good as we can still keep a styling in a CSS file. Another engaging associated have have have have have have have have make make make make make use of of of of of of of of of of of of of of this technique is to supplement browser classes to a body, enabling easy browser-specific styling. You can review some-more about that here.

#21 – Optimize Your Performance

Experienced coders don’t have clients wait for – they write formula that runs fast! There have been multiform ways we can have your formula run faster like:

  • Reference id’s rsther than than classes (id preference is local as good as thus quicker)
  • Use for instead of each()
  • Limit DOM strategy by adding elements in a single large cube rsther than than a single at a time
  • Take worth of event delegation
  • Link to Google’s jQuery duplicate rsther than than hosting your own – it’s faster as good as regularly up to date

Basically, it all boils down to not creation jQuery do any some-more work than it has to (and regulating local abilites at your convenience possible). Giulio Bai wrote an excellent post on jQuery perfomance, if you’d identical to to puncture in deeper.

#22 – Adapt Your Scripts to Work Cross-Browser – The Right Way

Thankfully, jQuery’s cross-browser harmony unequivocally cuts down a need for browser hacks. Sometimes, though, it is good to be equates to to get report about a client, as good as we can do that clean as good as unobtrusively with jQuery.support:

1
2
3
4
5
//Does this customer follow a W3C box model?
var boxModel = $.support.boxModel;
 
//Does this customer await 'opacity'?
var opacity = $.support.opacity;

It’s really improved make make make make make use of of of of of to have have have have have have have have make make make make make use of of of of of of of of of of of of of feature-detection rsther than than browser sniffing, as good as this is a unequivocally fit approach to do it. Read some-more about jQuery.support’s properties here.

#23 – Configure jQuery to be Compatible with Other Libraries

We all find ourselves in situations where mixed libraries have been needed, as good as since jQuery isn’t a usually living room that uses a $ alias, compatiblity issues infrequently cocktail up. Thankfully, this is easy to repair regulating jQuery’s noConflict(). You can even conclude a law alias to reinstate a $:

1
2
3
4
var $j = jQuery.noConflict();
 
//Now we can have have have have have have have have make make make make make use of of of of of of of of of of of of of '$j' usually identical to '$'
$j("div").hide();

An swap technique is to hang jQuery calls in an unknown duty as good as pass jQuery in as a parameter. Then we can have have have have have have have have make make make make make use of of of of of of of of of of of of of whatever alias we want, together with a ‘$’. This is generally utilitarian for plugin authoring:

1
2
3
4
5
(function($){
	$(document).ready(function(){
		//You can have have have have have have have have make make make make make use of of of of of of of of of of of of of normal jQuery syntax here
	});
})(jQuery);

#24 – Efficiently Store Element-Specific Information with data()

data() is substantially a single of a obtuse used jQuery methods, nonetheless it positively shouldn’t be. It allows us to attach/retrieve as most interpretation as we wish to DOM elements yet misusing attributes, as good as is generally utilitarian for some-more formidable scripts. For example, Stefan Petre’s Colorpicker plugin uses interpretation a lot since it’s tracking lots of fields as good as colors, converting rgb to hex, etc. Here’s have been a small examples of how data() works:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$(document).ready(function() {
	//Set standing to 'unsaved'
    $("button:first").data("status", "unsaved");
 
	//Retrieve status
	var buttonStatus = $("button:first").data("status");
 
	//Change status, this time defining an intent literal
	$("button:first").data("status", {saved : true, index : 1});
 
	//Retrieve standing of index property
	var buttonStatusIndex = $("button:first").data("status").index;
 
	//Remove standing data
	$("button:first").removeData("status");
});

I’m certain we can suppose a outrageous border of possibilities this presents. Again, it’s worth celebration of a mass a documentation if we haven’t used data() before.

#25 – Extend/Modify Existing jQuery Functions

Nobody says we can’t have have have have have have have have make make make make make use of of of of of of of of of of of of of a existent jQuery height as a springboard for brand brand brand brand brand brand new ideas – as good as most have finished usually that regulating extend(), an additional smashing jQuery method. The renouned Easing plugin, for example, adds a small existence accumulation by fluctuating a easing object, an already existent intent that is upheld to animate() as good as others:

1
2
3
4
5
6
7
8
9
10
11
12
13
jQuery.extend({
	easing: {
		easein: function(x, t, b, c, d) {
			return c*(t/=d)*t + b; // in
		},
		easeinout: function(x, t, b, c, d) {
			if (t < d/2) return 2*c*t*t/(d*d) + b;
			var ts = t - d/2;
			return -2*c*ts*ts/(d*d) + 2*c*ts/d + c/2 + b;
		},
		easeout: function(x, t, b, c, d) {
			return -c*t*t/(d*d) + 2*c*t/d + b;
		}...

By fluctuating as good as mending jQuery’s default functionality, we can open up a total brand brand brand brand brand brand new universe of cold possibilities.

#26 – Reverse Engineer before() as good as after()

I regularly appreciated how jQuery supposing append()/prepend() and appendTo()/prependTo(), enabling us to simply perform an attach in possibly direction. I’ve wished, though, that a identical capability was supposing with before() as good as after(). To shift that, we can simply supplement dual functions called putBefore() as good as putAfter() that will perform that purpose. Here’s how:

1
2
3
4
5
6
7
8
9
10
11
12
$(function(){
	jQuery.fn.putBefore = function(dest){
		return this.each(function(){
			$(dest).before($(this));
		});
	}
	jQuery.fn.putAfter = function(dest){
		return this.each(function(){
			$(dest).after($(this));
		});
	}
});

#27 – Add an isChildOf() Test

I’m certain we all have found ourselves in this incident – wanting to know if an component is a successor of an additional element. The good headlines is, with a single line of formula we can magnify jQuery to concede this:

1
2
3
4
5
6
7
8
$(function(){
	jQuery.fn.isChildOf = function(b){return (this.parents(b).length > 0);};
 
	//Now we can weigh identical to this:
	if ( $("li").isChildOf("ul") ){
		//Obviously, a li is a kid of a ul so this formula is executed
	}
});

Thanks to Dan Switzer II for this contribution!

#28 – Add Custom Selectors

This is an additional a single that has been talked about a lot in a growth community, so we might have this already figured out. If not, get ready since this will open a small total brand brand brand brand brand brand new windows for jQuery efficiency. The reduced story is, jQuery allows us to magnify a countenance object, that equates to we can supplement whatever law selectors we want. For example, contend we longed for to supplement a selector chronicle of a isChildOf() process we wrote earlier:

1
2
3
4
5
6
7
8
9
10
$(function(){
	jQuery.extend(jQuery.expr[':'], {
		'child-of' : function(a,b,c) {
			return (jQuery(a).parents(c[3]).length > 0);
		}
	});
 
	//'child-of' is right away a current selector:
	$("li:child-of(ul.test)").css("background","#000");
});

Debuggable has a good post on this a single as well, if you’d identical to to review some-more about how a parameters work, etc.

#29 – Smooth Scrolling Without Plugin

Karl Swedberg posted this a single a whilst behind on a Learning jQuery site, as good as it is really worth a look. Of course, there have been a integrate of plugins to get ahead this (and they have some-more features), yet we consider a genuine worth in this is a excercise of we do it yourself. Plus, demeanour at how little it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
$(document).ready(function() {
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
      && location.hostname == this.hostname) {
       var $target = $(this.hash);
       $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
       if ($target.length) {
           $target.ScrollTo(400);
           return false;
       }
    };
  });
});

#30 – Add Tabs yet a Plugin

jQuery tabs have been mostly lonesome yet additionally mostly used, as good as identical to a scrolling pretence on top of it’s critical to know how to do these yet a plugin. The initial thing to do is write a markup, that should be ideally respectable in a deficiency of Javascript:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div class="widget">
	<h3>Popular</h3>
	<ul>
		<li>Item #1</li>
		<li>Item #2</li>
		<li>Item #3</li>
	</ul>
</div>
<div class="widget">
	<h3>Recent</h3>
	<ul>
		<li>Item #1</li>
		<li>Item #2</li>
		<li>Item #3</li>
	</ul>
</div>

With a bit of styling, this would demeanour usually fine, so we know a jQuery is starting to reduce gracefully. Now we can write a code:

1
2
3
4
5
6
7
8
9
10
11
$(document).ready(function() {
	$("div.widget").hide().filter(":first").before("<ul class='tabs'></ul><div class='tab-content'></div>").add("div.widget").each(function(){
		$(this).find("ul").appendTo(".tab-content");
		$("ul.tabs").append("<li>" +$(this).find(":header:first").text()+ "</li>");
	});
	$("ul.tabs li").click(function(){
		$(this).addClass("active");
		$(".tab-content ul").slideUp().eq($("ul.tabs li").index(this)).slideDown();
	});
	$("ul.tabs li:first").click();
});

Of course, that’s usually a single approach to do it. If you’d identical to to see a small alternative approaches, see Extra Tuts’ jQuery Tabs Tutorials collection.

Wrapping Up

Thanks for reading, we goal you’ve enjoyed it! In box you’re all dismissed up on jQuery now, here have been a small links to some-more good tips n’ tricks collections:

As we can see, there have been gigantic opportunities for extraordinary creation with jQuery. So keep experimenting, keep perplexing things, keep thinking, “What if?” You could be a subsequent jQuery supergeek!

 30 Pro jQuery Tips, Tricks and Strategies

The rest is here: 
30 Pro jQuery Tips, Tricks as good as Strategies


Get Auto Caffeinated Content for Your WordPress Blog



GET YOUR WORDPRESS THEMES FROM PLIABLEPRESS!

intro Get Your WordPress Themes from PliablePress!

Anyone following me on Twitter will already know this by now, nonetheless a large project, PliablePress, went live around twenty-four hours ago!

And it’s been great! It’s been crazy as good as I’ve been chasing things around everywhere as good as we meant to have this post published, well, twenty-four hours ago, nonetheless all of which aside, it’s been great.

We’ve had loads of great reactions to a designs, as good as even a initial happy customers!

In this post we wish to uncover we what we’ve finished so far, share a little videos of the framework in action, as good as offer we a discount if we wish to turn a customer!

Want to See Our Designs?

Click on any picture to see a full page (including a live demo link!) on PliablePress.

square-cs square-oracle

square-cs-minimalsquare-backdrop

long-chameleon   

With any purchase, you will get Chameleon for free (Chameleon is a framework, which all of a themes need to run on. They’re all kid themes of Chameleon)

The Framework in Action

I’ve used Screenr to jot down a little videos of a horizon in use. It boundary we to 5 mins a video nonetheless so I’ve separate it up in to 3 videos. Check out this post to see all 3 in a row!

(Or if we wish to be unequivocally quick; a initial gives we a ubiquitous thought of a framework, as good as a second shows we a little of a cooler facilities of it!)

Click here for a Chameleon demo videos.

Get a $30 Discount & A Free Theme!

Originally we betrothed everybody a $25 discount, nonetheless we upped which at a final notation to $30, as good as there’s a special suggest surrounding a subsequent theme.

The $30 banking expires in about thirty hours now, so you’ll need to action quick!

When we pointer up, only come in this coupon: LAUNCHDAY

If a $30 expires though, don’t worry, I’m still charity $25 off until a finish of subsequent week so we can still have a large saving!

In which case, only come in this banking on a signup page: LAUNCH2010

How Can You Get Our Next Theme For Free?

Our subsequent thesis is called MyBiz, as good as it’s a really complicated website as good as blog theme (You’ll see what we meant when we see a homepage below!).

Anyone who buys any thesis from us in a subsequent 2 weeks will get a giveaway duplicate of MyBiz (And all a tone variations!) when we launch it!

And now, here’s a brand new preview of MyBiz which we haven’t common anywhere yet!

mybiz-pbd

Quite opposite to a blue preview we might have seen in a newsletter yesterday, isn’t it? And there have been more variations on their way, so stay tuned!

That’s us live though! It’s been a rollercoaster float removing here, nonetheless I’m gay to eventually be means to share this all with you, as good as I’d adore to listen to what we consider of it all! (or improved yet, buy a theme as good as try it out on your site! And have certain we share a couple with me if we do!)

And final of all, if you’d similar to to take partial in a associate program, only sign up for an comment here! We’re charity a outrageous 33% for any sales referred by a single of your links, so it could be good value your while!

 Get Your WordPress Themes from PliablePress!

View strange here: 
Get Your WordPress Themes from PliablePress!


Get Auto Caffeinated Content for Your WordPress Blog



3 YEARS ON, TIME TO SHOW YOU WHO I AM?

3yearson 3 Years On, Time To Show You Who I am?

(This is some-more of a personal post than normal. If that’s not your thing, sorry, yet at smallest we warned you!)

My name’s Michael Martin, as well as I’m the chairman at a behind of Pro Blog Design. If you’ve ever emailed in, tweeted, or left a Facebook summary (or many likely, even if you’ve usually left a criticism here!) thereafter you’ve talked to me before.

And if you’ve been here at all before, you’ve unequivocally review articles I’ve written (and of march if you’ve worked with us, you’ve substantially had some-more emails from me than we essentially wanted!)

But you’ve never seen a print of me.

In a singular week from today, we launch a biggest plan of my life, as well as it usually doesn’t appear fair to ask we to squeeze something from me yet meaningful who we am.

So you’ll have to pardon this being a bit of lifeless post. It’s for those of we who unequivocally wish to get concerned with PliablePress as well as take partial in moulding what it becomes. The initial step towards which is introductions.

So Who Am I?

Michael Martin Well, that’s me over there on a right!

The reason you’ve never seen a print prior to is which we was sincerely immature when we proposed Pro Blog Design.

I’m twenty now, as well as have a repute of 3 years essay as well as conceptualizing at Pro Blog Design to behind me up.

When we proposed out though, we was seventeen as well as wondered if I’d have difficulty with people receiving me severely or not. we never lied about my age, we usually avoided bringing it up.

The overwhelming thing about a internet yet is which the unequivocally many appropriate people (ie. a ones we essentially wish to work with, as well as a ones we wish to be your customers) unequivocally couldn’t caring reduction what age we have been (Or where you’re from, or anything else for which matter). They usually wish we to know your stuff.

It took me a whilst to realize that, as well as we substantially could (and should!) have put photos online prior to now. Maybe a couple of people would have been put off, yet not a critical ones (A couple of generally keen clients even worked it out since of a times we sent many of my emails at, as well as nothing were bothered).

Kind of great to have finished which now, we consider we was a usually chairman in a universe to have Facebook as well as not have a singular print on it!

What All Do You Do?

I’m a full time tyro at Queen’s University, Belfast, study Computer Science (It’s great many of a time, yet if we were carrying concerns about Flash now, have we ever even listened of Adobe Director? Yawn…).

Pro Blog Design is where a genuine fun happens though. When we proposed out, as well as for utterly a whilst afterwards, this was all a a singular male show. we wrote all a posts, rubbed all a communications, as well as did all a pattern as well as formula work.

Now we still write a lot of posts as well as do all a communications, yet instead of essay each post, we mostly sinecure alternative writers as well as thereafter work as an editor. And instead of we do all of a pattern work by myself, we right away manage it as well as beam a plan (Though we do many of a coding myself, as well as all of a coding in Chameleon of course).

Why shift to a group effort? Well for a singular thing, we indispensable to. Productivity is a singular thing, yet there’s a indicate where even a many full of color of to-do lists as well as concentration tricks aren’t starting to take we any further…

The many appropriate reason yet is which we get to work with people who have been improved than me. If we sinecure us to pattern your website now, you’re starting to get a most improved site than if you’d hired usually me 3 years ago.

Why? Because we work with designers who have been improved than me. I’ve finished sufficient pattern work myself to know a illusory engineer when we see them, as well as that’s because at Pro Blog Design, we usually get a best.

Sorry if which seems similar to a copout as a freelancer, yet any one who thinks they’re a unequivocally many appropriate at all they do usually isn’t being honest with themselves. Everyone has strengths, as well as a usually approach to set up something overwhelming is to find people who stone at a areas you’re usually “good” in.

For me, which meant striking pattern in sold (Ever notice how we don’t write Photoshop tutorials? we can have your site as user-friendly as well as organic as we like, yet for unequivocally eye-grabbing graphics, we knew we indispensable to span up with an overwhelming designer)

The Exciting Part

So right away we know who we am as well as what we do, we have a small news to share with you. Up until now, I’ve regularly had something full time to work on in reserve from Pro Blog Design (i.e. university), yet that’s about to change.

The subsequent year in my march is ostensible to be outlayed operative in attention for a year. For me, it equates to which come Jun I’ll be operative full time on a web for (at least!) a subsequent sixteen months. And we can’t wait!

So if we suspicion all up until right away was good, usually wait for until I’m able to go at it full throttle! And naturally, PliablePress is starting to be a large partial of that.

If we finished it this distant down a post, interjection for receiving a time to review it all. Now which we know me, I’d adore to know you.

With PliablePress, we unequivocally have been starting to involve we in everything. We’ve finished sufficient work on a web to have a great thought of what we will like, yet it’s not probable to know which improved than we do.

If we wish to get concerned as well as assistance figure PliablePress, I’d be delighted. A large partial of which will be in discussions on a user forum when we launch, as well as on a blog, yet a initial step is usually joining a newsletter. We’re starting to have a small big questions on it soon as well as I’d adore to listen to your opinions.

And if you’ve been following along in a credentials in all this or we haven’t oral most before, please do deliver yourself in a comments (let me know who we have been as well as how we can assistance you!). I’m not fooling around in a smallest about wanting to get to know you.

It’s usually 7 days to a launch. we goal this post took we a small serve along a highway to trusting me to have your site rock!

 3 Years On, Time To Show You Who I am?

Read some-more from a strange source: 
3 Years On, Time To Show You Who we am?


Get Auto Caffeinated Content for Your WordPress Blog



MY IDEAL WORDPRESS FRAMEWORK

Chameleon

Last week, we pennyless a headlines which we’re releasing premium WordPress themes in 2 weeks from now.

Today, we wish to speak to we about the horizon we’ve built for all a themes to run on (and all of your themes too!).

When we combined this framework, we had unequivocally specific ideas about what we wanted. This is a horizon which we would wish to use, nonetheless it’s by no equates to perfect. Nothing is, so I’d unequivocally love to listen to what we think of it at a end.

And of course, this all ties without delay to PliablePress. If we wish to listen to some-more about it (and a framework), we should pointer up to the mailing list!

What is a Framework?

It sounds some-more formidable than it is. For us, a horizon is simply a theme. You can spin on it, save a couple of options as good as run your site only on a horizon (For any a single informed with Thesis, that’s fundamentally what you’re we do there).

(And naturally, each thesis has to have a name; ours is called Chameleon. That small picture at a tip have some-more clarity now?)

Of course, a genuine fun is when we begin to have brand brand new themes. Every thesis we suggest is built on Chameleon. That equates to we can supplement modernized functionality unequivocally simply in to all of a themes, as good as we get a same carry out row opposite them all.

So What Would The Ideal Framework Do?

That’s a subject we asked myself multiform months back, as good as here’s a answer we came up with.

The preferred horizon creates office building a (complex) site easier for a site owner, as good as easier for a developer.

The pass word there? “Easier.”

How to be Easier for a Site Owner?

The wily partial of this subject is which each site owners is at a opposite spin technologically. What we’re starting to do initial is have a elementary assumption:

Anyone peaceful to deposit a $70 or so for a thesis is meddlesome in how their site looks.

A satisfactory sufficient assumption, right? Now let’s have a second one:

Bloggers assimilate a “content” of their sites, many improved than they assimilate a “design.”

By “content,” we don’t only meant a articles. we meant which they know either their blog could do with a discerning key paragraph. Or either thumbnails have been a good idea. Or if a “Tweet This” would go down good with their readers.

But they don’t indispensably assimilate since a opening in in between a trademark as good as a navigation club is a stretch it is. Or since a stretch in in between paragraphs is a stretch which it is. Or since a single mainstay in your sidebar will work improved in this theme.

That arrogance was a bigger step, nonetheless still in accord with we believe. Now though, let’s finish with an additional stone plain one:

The easier it is do something, a some-more prone we will be to do which thing. And a happier you’ll be afterwards.

When we contend “happier”, we don’t meant in a proceed which we feel a clarity of fulfilment for we do something brand brand new as good as difficult. we meant a grin we get it when we consider “oh, which was easier than we expected,” as good as a peace of thoughts we get from meaningful we can’t presumably have finished anything wrong since there was no alternative probable proceed of we do it.

Putting It Into Practice

Those have been a 3 assumptions I’ve built Chameleon on. What does it all meant though?

Well, sincerely obviously, it equates to we’re going to have a carry out panel. And with which carry out panel, we can tweak as good as shift your thesis as we see fit.

Of course, other people have finished carry out panels already. Here’s what creates ours different:

  1. Simplicity is a feature. We won’t supplement facilities for a consequence of it, as good as we’ll be some-more than happy to mislay facilities we’ve already combined if they aren’t being used (We have dozens of options built-in, only no invalid ones hopefully!)
  2. No underline should need some-more “help” documentation than we can put next to it on a page. If it does, afterwards we need to rethink it.
  3. There should be elementary recommendation to assistance with decisions. This equates to explaining a “why” to those who wish it, not only a “how.”
  4. Should work similar to unchanging WordPress. Chameleon has a own blueprint for removing all of a options in comfortably, nonetheless it still looks as good as feels similar to each alternative WordPress page. In short, we already know how to have have have have have make use of of of of of of it.
  5. The thesis should work out of a box. You don’t essentially need to have have have have have make use of of of of of of a options row if we don’t wish to. It will fill in all a defaults for we anyway.
  6. There have been regularly starting to be people who wish to do more. If we put a thousand options in to a panel, someone would consider of a thousand as good as first. It’s easy to supplement an additional underline to a panel, nonetheless is it improved to force an additional choice in to everyone’s carry out panel, or to sense which a single chairman how to have their shift themselves?
  7. Content options have been some-more critical than design. In Chameleon, we can set a sequence of each partial of your post meta section, select either an author’s name should couple to his site, his writer page or zero at all, as good as set only how many seconds your featured slider takes prior to relocating on.

    You can’t shift your rise stretch to 13px though. That’s since if we’ve set it to 14px, it’s since 14px was a many clear stretch as good as a many wise for which design. If sufficient people wish to shift a rise size, we’ll supplement in a underline to let we select from Small, Medium or Large (Because afterwards we can take caring of a stretch of all else, similar to headers, line-height etc. as well).

    And if you’re still not happy, I’ll sense we how to do it with CSS as good as give we a expect line we need (Just similar to we pronounced we would in indicate 6).

The result? This horizon will let we do a immeasurable infancy of things we wanted, as good as it will let we do them with no bitch at all. And since it’s all so simple, we might even find yourself tweaking things we hadn’t suspicion of before (Like which small line of content which shows up when your post doesn’t have any comments yet?)

It won’t only chuck settings at we which leave we uncertain of what to do. If there’s a preference we can have for you, we’ll do it. That’s what we paid us for. Let us have things easier for you.

And if we really, unequivocally wish to shift something, we can. It only equates to treating things similar to a developer would.

How To Be Easier for a Developer?

The difficulty with frameworks for developers is which there’s a guidance bend which wasn’t there before. By nature, a horizon packs in a lot some-more functionality so it’s laid out a small differently, which a developer won’t be used to yet.

So how do we have this value your while?

  • Complex functionality, easily. What if we could supplement in a featured post slider only by essay “ply_slider()”? And of march which adds a required fields to a carry out row as well.
  • Standardize to revoke workload. When we have a thesis for Chameleon, I’ll suggest which we have your sidebar 300px wide. Why? Because afterwards a CSS I’ve already created will take caring of both 1 as good as 2 mainstay sidebars for you, along with a blueprint for all a default widgets (plus a 5 extras which Chameleon comes with). That’s a satisfactory cube of your work done.
  • Child themes have been great. Just essay “Template: Chameleon” at a tip of your theme’s stylesheet equates to which WordPress will have have have have have make use of of of of of of Chameleon as a basement of your site. You can afterwards have a functions.php jot down as good as tweak away. And anything we supplement in your stylesheet will overrule a Chameleon stylesheet.
  • Learn by example. One things which binds loyal for a lot of developers is which they sense improved by seeking at something which already works. All of a themes at PliablePress have been built on Chameleon. Just open a single up as good as you’ll see how easy it was for us to have themes which have been utterly different, even nonetheless they all have have have have have make use of of of of of of a same framework.
  • Action hooks have been easier than filters. Filters have been good as good as let we do a lot of things which we only couldn’t with actions. But for a immeasurable infancy of tweaks, actions have been all you’ll need. If we can let we have all of your changes with only actions, I’m we do flattering well.
  • Answer your questions. By nature, operative as a developer is some-more challenging. I’ll have a complement as easy to have have have have have make use of of of of of of as we can, as good as I’ll jot down copiousness of tutorials as good as write up assistance docs for you, nonetheless if which still doesn’t answer your questions, a forum is going to rock. Ask anything we want. We’ll work it out for you.

Want To See Chameleon Itself?

This Thursday I’m starting to be promulgation out a initial email to a PliablePress mailing list. It’s starting to give we an in-depth demeanour at Chameleon, uncover we a carry out row as good as how a thesis itself essentially looks on a site.

If we wish to see all that, only need to enter your email below (or if you’re in an RSS reader, go here).

(You’ll additionally get a $25 bonus when we launch!)

Now it’s your spin though. Have we got a right suspicion for this framework? Would we cite it let we do more? Or less? Or take a opposite proceed altogether?

 My Ideal WordPress Framework

View strange here: 
My Ideal WordPress Framework


Get Auto Caffeinated Content for Your WordPress Blog



AUTOMATIC WP THUMBNAILS & PROPORTIONAL EXCERPTS

pic1 Automatic WP Thumbnails & Proportional Excerpts

Automatically grabbing thumbnails from posts is cool. But what about involuntary mention lengths that compare a tallness of those photos?

I not prolonged ago redesigned a blog for a customer as well as it had an involuntary thumbnail for any post, with a bound length mention next to it. It was okay, though a customer didn’t similar to a actuality which it was “cutting” his cinema off sometimes. Our thought afterwards had 3 steps:

  • 1 – To set a thumbnail’s height proportionate to a strange picture, so which we would not cut tools of it off.
  • 2 – Use this height value to arrangement excerpts about a same size.
  • 3 – Set up an involuntary Lightbox on images which have been as well large for a calm area.

Of march all of this had to be automatic, law fields have been cold for us designers/programmers, though for clients it’s as well most hassle.

That’s what I’m starting to learn we to do in this post.

NB – This is starting to get utterly technical; you’ll need to have had a small experience modifying thesis files before, as well as a small HTML/CSS.

Examples

Let’s begin with an e.g. of usually what we have been starting to be done. Check out a screenshot below, or see the demo site (Notice how any mention is a opposite length, depending on a thumbnail?).

And here, is an e.g. of a involuntary lightbox effect.

All great now? Okay, let’s see how it goes.

The final thing to note; this total routine is formed on Fikri Rasyid’s post here at Pro Blog Design.

We will additionally need a TimThumb script in a WordPress theme. Just squeeze it from here as well as upload it to your thesis directory.

Index.php

In index.php or home.php, depending on we WordPress theme, you’ll have your WordPress loop. You’ll need to supplement in 2 divs for aligning a dual sections of a posts:

  1. One on a left side with a thumbnail.
  2. And a single a right side for a text.

pic2 Automatic WP Thumbnails & Proportional Excerpts

Here goes a formula we will have make have make use of of of of for a thumbnail:

<div class="thumbnail">
<a title="<?php the_title_attribute('before=Permalink para: '); ?>" href="<?php the_permalink(); ?>">
<img src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php getImage('1'); ?>&w=243&zc=1&q=70" alt="" />
</a></div>

We have make have make use of of of of a Timthumb book as well as a duty getImage (You’ll be adding which duty to your functions.php after on, don’t be concerned about it usually yet) to lapse a thumbnail of 243px breadth as well as a proportionate height.

The 243px is usually an e.g. which propitious my design, we can of march set any distance we wish inside of a Timthumb parameters: &w=243&zc=0&q=70.

And for a text:

<div class="excerpt_home">
<?php
$postid = $post->ID;
$query = sprintf("SELECT * FROM wp_posts WHERE id='%s'",
mysql_real_escape_string($postid));
$result = mysql_query($query);
$row = mysql_fetch_array($result);
 
$w = $row[post_content];
$w2 = explode("width="", $w);
$w3 = $w2[1];
$w4 = explode(""", $w3);
$width = $w4[0];
 
$h = $row[post_content];
$h2 = explode("height="", $h);
$h3 = $h2[1];
$h4 = explode(""", $h3);
$height = $h4[0];
 
if($height != 0 && $width != 0) {
 
$t1 = ($height*100)/$width;
$t2 = (243*$t1)/100;
$t3 = ($t2*28)/100;
 
the_excerpt_rereloaded($t3,'[&raquo;]','<strong><em><b>','span','no');
}
 
else {
the_excerpt_rereloaded(45,'[&raquo;]','<strong><em><b>','span','no');
}
 
?>
</div>

About this code:

  • We initial squeeze a ID of a stream post.
  • Then we poke a database for a strange picture’s size.
  • And we arrangement a text.

WordPress saves in a database a width as well as height of any pattern in a post. The thought is to squeeze those values to grasp a goal. We need a calm of post_content, in a list wp_posts. We afterwards poke for a calm width=’ to squeeze a worth until we encounter a shutting .

This is all completed with these lines of code:

$w = $row[post_content];
$w2 = explode("width="", $w);
$w3 = $w2[1];
$w4 = explode(""", $w3);
$width = $w4[0];

We do a same for a tallness of a picture:

$h = $row[post_content];
$h2 = explode("height="", $h);
$h3 = $h2[1];
$h4 = explode(""", $h3);
$height = $h4[0];

If those values have been not empty, it equates to which we have a picture.

We afterwards have make have make use of of of of a proportionate duty to give a non-static $t3 a worth for a the_excerpt_rereloaded function. we have make have make use of of of of this plugin to arrangement a law ‘Read more’ text: [»] (You’ll need to exercise a plugin to get a formula on top of to work since it is what lets us shift a length of a excerpt)

$t1 = ($height*100)/$width;
$t2 = (243*$t1)/100;
$t3 = ($t2*28)/100;

243 is a breadth of my final thumbnail, as well as twenty-eight is a suit for a text. Why? Because $t2 will give me a tallness of a picture in pixels as well as a parameter for the_excerpt_rereloaded is a number of words. Without this multiplication $t3 = ($t2*28)/100; my calm would be proportional, though approach as well long.

Feel giveaway to adjust those values to have a excerpts line up ideally with your own line lengths!

Finally if no pattern is found i arrangement a 45 word mention since it suits my default picture:

else {
the_excerpt_rereloaded(45,'[&raquo;]','<strong><em><b>','span','no');
      }

Of march if a calm of a post is as well short, it wouldnt fit a total div on a home page.

functions.php

Here is a duty getImage() to put in functions.php in a WordPress theme:

<?php
// retreives design from a post
function getImage($num) {
global $more;
$more = 1;
$content = get_the_content();
$count = substr_count($content, '<img');
$start = 0;
for($i=1;$i<=$count;$i++) {
$imgBeg = strpos($content, '<img', $start);
$post = substr($content, $imgBeg);
$imgEnd = strpos($post, '>');
$postOutput = substr($post, 0, $imgEnd+1);
$image[$i] = $postOutput;
$start=$imgEnd+1;
 
$cleanF = strpos($image[$num],'src="')+5;
$cleanB = strpos($image[$num],'"',$cleanF)-$cleanF;
$imgThumb = substr($image[$num],$cleanF,$cleanB);
 
}
if(stristr($image[$num],'<img')) { echo $imgThumb; }
else {echo bloginfo('template_url')."/images/padrao_w.png";}
$more = 0;
}
?>

As we pronounced before, this is from Fikri’s post.

I usually mutated it at a finish to supplement a default pattern if a post does not enclose any. In my case, a pattern is located in a images printed matter of my WordPress theme: /images/padrao_w.png. Again, adjust that to your own default design link!

Lightbox system

This final territory is most easier; we usually used a nCode Image Resizer plugin. It checks if a pattern in a post is bigger than 630px width. If yes, it does resize it proportionally to 630px breadth as well as puts couple on top of a design to wizz inside of a same page.

Lightbox link

Just go a WordPress admin row to set a breadth choice to whatever worth suits your theme.

Conclusion

This process competence not be a usually a single to grasp this as well as additionally not a most appropriate ever. I’m flattering certain it can be improved.

Do not demur to post comments about it, I’d be blissful to assistance as well as may be urge a system.

And of course, if we do exercise this on your site, share a couple with us!

 Automatic WP Thumbnails & Proportional Excerpts

See a rest here:
Automatic WP Thumbnails & Proportional Excerpts


Get Auto Caffeinated Content for Your WordPress Blog



INTRODUCING PLIABLEPRESS.

Want to know because so many of a clients in a past couple of months had to be incited away? Or because

Want to see a biggest plan I’ve ever worked on at Pro Blog Design?

PliablePress WordPress Themes

So what is it? At a simplest, PliablePress means WordPress themes. But we’ve put all in to this, these aren’t elementary small themes which we can spin out in a weekend.

We’ve built an positively kick-ass framework, as well as a designs will blow we away. Our law pattern services have been all a time sole out, as well as they proceed at $1500. That’s a turn of peculiarity we can expect… as well as afterwards some.

We have 3 elementary goals:

  1. To emanate stunning designs.
  2. To emanate them on a many user-friendly, stretchable (pliable!) horizon possible.
  3. To help we with any singular thing we can.

And we aren’t starting to do any of those in a normal way. PliablePress launches on 10th May, only 3 weeks from now, as well as in which time, we’re starting to take any idea a single at a time as well as uncover we how we’ll spike it.

Want To Be Part of It?

If we wish to stay concerned and  get a $25 discount when we launch, only enter your email here.

PliablePress We’ll additionally uncover we sneak previews of what’s to come as well as only what has done us so proud. We’ll even let we know what a chameleons have been all about.

And we’re on Twitter as well as Facebook of course! We’ll be talking as well as pity copiousness more about what we’re up to. We’d adore to discuss with we there!

And if we unequivocally wish to assistance us out, tell your friends about it too!

Either approach though, have certain we come in your email next for all a offers, competitions as well as sum on what’s to come! (Or if you’re in an RSS reader, check out a PliablePress site!)

(Your $25 bonus formula will be emailed to we at a time).

I goal you’re as vehement as we am, see we there!

 Introducing PliablePress.

Go here to see a original:
Introducing PliablePress.


Get Auto Caffeinated Content for Your WordPress Blog



HOW TO OPTIMIZE A WORDPRESS DATABASE

Optimize WordPress Database

Have we looked nearby your MySQL database since we initial set it up? If you’re similar to many of us, we substantially don’t go in there as good often.

MySQL is difficult as good as antipathetic to use, as good as well, your site functions as it is. So why bother?

If we do occur to try in there spasmodic though, we competence find there have been a couple of elementary tricks we can lift to have a many of your database usage. From headache-saving tricks for you, to cranking a small some-more opening out of your server, check out a 7 tips below.

Before we begin though, it will be utilitarian to have a apparatus similar to phpMyAdmin to have this all simpler (Ask your webhost about it, 99% of them already have it installed as good as accessible to you).

On tip of that, have certain we have a backup prior to ever we do anything with your database (In phpMyAdmin, have have make make make use of of of of of a “Export” tab).

MySQL “Optimize” is a Free Speed Boost

MySQL has a built-in optimize duty to clean up squandered space in your tables. It’s quite in effect when you’ve deleted a lot of interpretation (With blogs, which often equates to comments).

The many appropriate partial yet is which it’s simple to do. In phpMyAdmin, usually name a table, go to a “Operations” tab, as good as afterwards click “Optimize Table.”

Or if you’d rsther than run it manually, a syntax is:

OPTIMIZE TABLE 'wp_comments'

Backups which You can Set as good as Forget

Backing up your database is non-optional. All computers pile-up at a small point, as good as we don’t wish to risk losing all of your blogging history usually since we didn’t be concerned to set up a small backups.

To see how we can have this automatic as good as never have to be concerned about them again, review a perfect hands-free database backup tutorial.

Delete All Post Revisions

Post revisions (Where WordPress automatically keeps a story of all changes to your posts) have been deliberate a bother by many people, mostly since of the space it wastes in your database.

For me, it creates clarity to keep them enabled since we have multiple authors here. If we were usually blogging on my own though, I’d invalidate them.

To do that, we usually have to supplement this line to your wp-config.php file.

define('WP_POST_REVISIONS', false);

But which won’t assistance with revisions already stored in a database. To purify them, run a following command:

DELETE FROM wp_posts WHERE post_type = 'revision';

Multiple WordPress in a single Database

If we have a option, we should put any of your sites into a own database (And give any database a own user who usually has entrance to which database). That approach if anything happens to one, a rest of your sites will be unaffected.

Sadly though, that’s not an choice on all common hosts. On my aged host, MediaTemple, we were limited to usually a single database. In which case, you’ll need to do what we did as good as shift a prefix for your tables (i.e. a wp_ in wp_options etc.)

To do this, demeanour in your wp-config.php record for this line, as good as shift a prefix to something new:

$table_prefix = 'wp_';

Delete All Comments From a URL

Sometimes spammers do mangle through. It’s a shame, yet so prolonged as we locate on, we can undo it. You can do this all manually around WordPress of course, yet infrequently it’s easier to run a elementary MySQL command.

To undo all comments from a specific URL, you’d run this command:

DELETE FROM wp_comments WHERE comment_author_url = 'http://www.site.com';

Alternatively, if we longed for to undo all of a comments by email address, we could use:

DELETE FROM wp_comments WHERE comment_author_email = 'spammer@test.com';

 

Bonus: Delete All Unapproved Comments

On really renouned blogs, a lot of comments can set up up in a “Pending” territory (I’ve worked with clients who have hundreds of comments which have been there for months).

In those cases, you’re doubtful to work by them a single at a time (And even if we do, they’ve been there so prolonged which nobody is starting to notice).

Ideally though, we never wish to get in to this position. When comments need to be authorized here on Pro Blog Design, we have certain to authorize them right divided so a small opposite goes straight behind to 0.

If your opposite is at a couple of hundred though, we won’t notice when 2 or 3 some-more have been combined to it.

In which case, a many appropriate thing is usually to wipe a line-up purify as good as begin again. In which case, we can undo all of your unauthorised comments with this elementary MySQL statement:

DELETE FROM wp_comments WHERE comment_approved = '0';

Plugins Leave Data Behind

When we deactivate a plugin, it usually stops a plugin from functioning anymore. It doesn’t mislay any of a interpretation already in your database.

Some plugin authors have been committed as good as right away embody “Uninstall” buttons with their plugins which we can run prior to deactivating. The uninstalls will purify things out properly.

If your plugin didn’t come with an uninstall yet (Most don’t), you’ll have to clean it out yourself.

The easiest place to begin is plugins which create total tables. When we used to run a SEO Title Tag as good as Search Meter plugins here, they both combined their own tables in my database to store their settings.

Deleting them is easy, usually click “Drop” in phpMyAdmin after selecting a list (please do have certain you’ve comparison a list though. If we aren’t on a right page, you’ll “drop” a total database!).

Other plugins don’t have have make make make use of of of of of as many interpretation yet as good as usually store their settings in a wp_options table. The easiest approach to find these is usually to crop a list as good as undo a rows we don’t need (Again, a apparatus similar to phpMyAdmin creates this simple).

Deleting particular options similar to this competence not be value a bid though. It competence save we a couple of kilobytes, yet that’s all. I’ve never finished it personally, yet if we wish to be ultra clean, it won’t take many bid to do.

Copying Your Widget Data

All of your widget data is stored in your database, together with which widgets have been being used in which sidebars, as good as a settings for them.

If we wish to copy these over to a brand new site but manually we do it all around WordPress, afterwards run a poke in your wp_options list for (in a “Option Name” field).

The formula we get will enclose all of your settings for any widget.

Conclusion

Those have been a 7 many utilitarian tips which we have have make make make use of of of of of when handling WordPress installations. Are there any others which we have have make make make use of of of of of as well?

If we have a database tip to share, I’d adore to listen to it in a comments!

 How to Optimize a WordPress Database

Read more: 
How to Optimize a WordPress Database


Get Auto Caffeinated Content for Your WordPress Blog



ADVANCED WORDPRESS COMMENT STYLES AND TRICKS

Advanced WordPress Comment Styles

Comments have been gold. There’s tiny a blogger loves some-more than to see a sum list of comments posted on his/her article. It’s great to know people instruct to engage with you, as great as they can supplement a lot to an article.

However, if comments have been not accomplished well, they can be formidable to review as great as follow, or even usually downright boring.

What we’re starting to do initial is emanate a law criticism callback which allows us to mention a approach a comments have been output, afterwards lay out a have up for a criticism list as great as reply form, add additional functionality such as author-only styles, exercise criticism subscription options as great as spam protection, and, finally, we’ll supplement great CSS styling to all we’ve done.

We will be operative with a default WordPress theme in sequence to have all easy to follow, as great as to safeguard everybody can follow along. We will additionally be ignoring all styling elements until a unequivocally end, so if it looks bad, usually be patient!

An important note to recollect is which anytime we impute to line numbers, I’m referring to a line numbers of a formula we posted, not a line numbers in your files.

1 – Create Custom Comment Callback

The criticism callback is usually a approach of revelation WordPress what HTML to separate out for your comments.

Rather than perplexing to cgange a default theme’s existent criticism callback, we’re starting to emanate a own, by adding this to functions.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php //this duty will be called in a subsequent section
function advanced_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
 
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
   <div class="comment-author vcard">
     <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
       <div class="comment-meta"<a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a></div>
       <small><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','') ?></small>
     </div>
     <div class="clear"></div>
 
     <?php if ($comment->comment_approved == '0') : ?>
       <em><?php _e('Your criticism is available moderation.') ?></em>
       <br />
     <?php endif; ?>
 
     <div class="comment-text">
         <?php comment_text() ?>
     </div>
 
   <div class="reply">
      <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
   </div>
   <div class="clear"></div>
<?php } ?>

What this formula does is mention usually how we instruct each, particular criticism to be displayed. This allows us to conclude law class/id settings for any component as well, rsther than than being firm to a default theme’s settings.

2 – Lay Out Your Template File

The formula in a prior territory combined a have up for particular comments, right away we need to lay out a have up for a tangible comments page, on which all of a comments will be displayed (Including a criticism form).

If your comments.php has anything in it already, reinstate it with a formula below. we have included comments around a formula to insist a couple of critical details.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
 * @package WordPress
 * @subpackage Default_Theme
 */
 
// Do not undo these lines
	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('Please do not bucket this page directly. Thanks!');
 
	if ( post_password_required() ) { ?>
		<p class="nocomments">This post is cue protected. Enter a cue to perspective comments.</p>
	<?php
		return;
	}
?>
 
<!-- You can begin modifying here. -->
 
<?php if ( have_comments() ) : ?>
	<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
 
	<ol class="commentlist">
		<?php wp_list_comments('type=comment&callback=advanced_comment'); //this is a critical partial which ensures we call a law criticism blueprint tangible on top of 
                ?>
	</ol>
	<div class="clear"></div>
	<div class="comment-navigation">
		<div class="older"><?php previous_comments_link() ?></div>
		<div class="newer"><?php next_comments_link() ?></div>
	</div>
 <?php else : // this is displayed if there have been no comments so distant ?>
 
	<?php if ( comments_open() ) : ?>
		<!-- If comments have been open, yet there have been no comments. -->
 
	 <?php else : // comments have been sealed ?>
		<!-- If comments have been closed. -->
		<p class="nocomments">Comments have been closed.</p>
 
	<?php endif; ?>
<?php endif; ?>
 
 
<?php if ( comments_open() ) : ?>
 
<div id="respond">
 
<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
 
<div class="cancel-comment-reply">
	<small><?php cancel_comment_reply_link(); ?></small>
</div>
 
<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
<p>You contingency be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in</a> to post a comment.</p>
<?php else : ?>
 
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
 
<?php if ( is_user_logged_in() ) : ?>
 
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p>
 
<?php else : //this is where we setup a criticism submit forums ?>
 
<p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
 
<p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
 
<p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
 
<?php endif; ?>
 
<!--<p><small><strong>XHTML:</strong> You can have have use of of these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
 
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
 
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Post" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
 
</form>
 
<?php endif; // If registration compulsory as great as not logged in ?>
</div>
 
<?php endif; // if we undo this a sky will tumble on your conduct ?>

If we need assistance bargain a role of anything in comments.php, check out a essay on Net Tuts about unraveling comments.php.

3 – Enable Nested Comments

People have churned feelings about threaded comments, yet they can be utterly utilitarian in organizing a contention flow. This step is wholly discretionary as great as won’t mangle anything if we select not to capacitate nested comments.

Assuming we do instruct to capacitate them, we need to go to your WordPress Dashboard as great as click on Settings > Discussion > Enable threaded (nested) comments # levels low (i.e. how most times can we reply to a reply).

enable-nested1-e1269381555339 Advanced Wordpress Comment Styles and Tricks

4 – Make a Author Stand Out

Particularly utilitarian for people who write tutorials as great as need to answer questions from their readers, this bit of formula will have any criticism left by a writer of a essay mount out from a community’s comments.

Newer WordPress versions have this unequivocally easy. They will automatically supplement sure CSS classes to comments (Assuming which we used a <php comment_class(); ?> tab which we referred to in step 1).

To character a comments, usually supplement CSS manners for a following classes:

  • byuser - For comments left by any purebred user on a site.
  • bypostauthor – For comments left by a writer of a stream post (Very utilitarian for styling comments by guest authors on their own posts, yet not on any alternative posts)
  • comment-author-name – Where “name” is a user’s name. This can be great for styling comments from an particular user, e.g. comment-author-admin

For an comparison process of we do this manually (Allowing we to character comments formed on specific emails being used), check out this post.

5 – Disable Comments on Old Posts

This can be accomplished by a WordPress settings, underneath Discussion, yet in box you’d identical to to do this automatically from inside of a theme, place this formula in your functions.php:

1
2
3
4
5
6
7
8
9
10
11
<?php
function close_comments( $posts ) {
	if ( !is_single() ) { return $posts; }
	if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 30 * 24 * 60 * 60 ) ) {
		$posts[0]->comment_status = 'closed';
		$posts[0]->ping_status    = 'closed';
	}
	return $posts;
}
add_filter( 'the_posts', 'close_comments' );
?>

This dash was creatively posted by Jeff Star at Perishable Press.

The critical partial is a “30 * twenty-four * 60 * 60.” That equates to 60 seconds, time 60 minutes, times twenty-four hours, times thirty days. So if we longed for to have it occur after 3 months, we could shift a initial thirty to a 90.

This could be utilitarian for thesis developers who would identical to to have “Commenting on Old Posts Disabled” a underline of their theme.

6 – Subscribe to Comments

Often times a reader will ask a await subject around post comments. Receiving an email at your convenience an additional criticism is posted is a most simpler approach for which reader to know an answer has been posted than manually checking each right away as great as afterwards (if they even recollect to do that).

Subscribe to Comments by Mark Jaquith is a great plugin which adds a couple to concede to serve comments usually next a summary box of a comments page. It additionally includes a subscription physical education instructor which is placed underneath Tools in your WordPress Dashboard, permitting users to unsubscribe from posts at any time.

We will character this symbol in a final section.

7 – Add Extra Moderation Links

Even with anti-spam protection, we will spasmodic have comments which we need to symbol as spam or undo entirely, so lets supplement links which concede us to do so. This will concede us to assuage comments from a website itself, not usually a dashboard.

First supplement this to your functions.php

1
2
3
4
5
6
7
<?php function delete_comment_link($id) {
  if (current_user_can('edit_post')) {
    echo '<a href="'.admin_url("comment.php?action=cdc&c=$id").'">del</a> ';
    echo '<a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'">spam</a>';
  }
}
?>

Next, put this formula in functions.php after line 24 of a law callback duty we combined in section 1.

1
 <?php delete_comment_link(get_comment_ID()); ?>

like so:

1
2
3
4
<div class="reply">
  <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  <?php delete_comment_link(get_comment_ID()); ?>
</div>

Your outcome should demeanour something identical to this:

extra mod links

Thanks goes to Joost de Valk for this great snippet.

8 – Add an Extra Layer of Spam Protection

Spammers have been regularly a problem, even yet there have been a sum slew of plugins to strengthen opposite them. This square of formula will supplement an additional separator which they have to mangle through. Essentially what it does is retard any criticism which does not have a referrer (i.e. where a user came from previously) in a posting request, which is customarily demonstrative of bots.

Paste this in to your functions.php

1
2
3
4
5
6
7
8
<?php function check_referrer() {
    if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == “”) {
        wp_die( __('Please capacitate referrers in your browser, or, if you're a spammer, get out of here!') );
    }
}
 
add_action('check_comment_flood', 'check_referrer');
 ?>

This snipped was additionally from From Joost de Valk. There is a possibility we could retard a tiny bona fide users though, yet if spam is apropos a vital issue, it’s value considering.

9 – Add Comment Feed Link

To arrangement a couple to your comments RSS feed, pulp this somewhere in your comments.php file:

1
<?php comments_rss_link('Subscribe to Comments around RSS'); ?>

One of a most appropriate places would be rught away after a criticism submit forums.

1
2
3
4
5
6
7
8
9
10
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
<small>Allowed tags: <?php echo allowed_tags(); ?></small>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Post" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
 
</form>
 
<div class="comment-rss"><?php comments_rss_link('Subscribe to Comments around RSS'); ?></div>

10 – Display Allowed Tags

Bold content can unequivocally assistance people’s points stand out in their comments, usually as italics can be great for things identical to addresses as great as blunder messages (404: Not Found). Letting your readers know they have been authorised to have have use of of sure HTML tags in their messages can be a genuine help.

Paste this:

1
Allowed tags: <?php echo allowed_tags(); ?>

in your comments.php. we have put it usually on top of a textarea as great as placed “small” tags around it.

1
2
3
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
   <small>Allowed tags: <?php echo allowed_tags(); ?></small>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Post" />

It should come out seeking something identical to this:

allowed tags

This dash comes from Net Tuts.

11 – Show Total Number of Comments

If you’d identical to to arrangement a sum series of comments posted sitewide, put this dash anywhere in your theme’s template files, such as header.php

1
2
<?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
  if (0 < $numcomms) $numcomms = number_format($numcomms); echo "There's <span>".$numcomms."</span> sum comments on "; bloginfo('name'); ?>

It will be displayed as something identical to There’s 1534 sum comments on your website name. The “span” tags around “.$numcomms.” have been there so we can stress a series of comments with CSS later. we have additionally wrapped a formula in div tags identical to so:

1
2
3
4
<div class="comment-total">
   <?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
       if (0 < $numcomms) $numcomms = number_format($numcomms); echo "There's <span>".$numcomms."</span> sum comments on "; bloginfo('name');?>
</div>

This dash comes from Hiroshi at PHP Magic Book

12 – Add Some CSS

After all we have done, your outcome should demeanour flattering identical to a default thesis here.

Obviously this is no good, so we instruct to get a tiny happy with a CSS.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/****************
advanced criticism styles
****************/
 
h3#comments,.comment-navigation,.comment-navigation:after,#respond:after,.comment-rss{display:block}
ol.commentlist{width:100%}
h3#comments,#respond h3{height:25px;text-align:left;background:#4c7faa;color:#fff;padding:5px 0 0 5px}
ol.commentlist,li.authorcomment,li.comment,#respond h3,form#commentform,input#submit{margin:0}
ol.commentlist,ol.commentlist ul,form#commentform{padding:0}
ol.commentlist{border-bottom:1px solid #ccc}
ol.commentlist ul{margin:0 0 0 20px}
li.authorcomment,li.comment,form#commentform textarea,form#commentform input{border:1px solid #ccc}
li.authorcomment,li.comment{padding:10px 0 0 10px;list-style:none;border-bottom:none}
li.even{background:#fff}
li.odd{background:#efefef}
.authorcomment{background:#deebf9}
ul.children ul{margin-left:20px}
ul.children li{border-right:none}
.vcard img{float:left;background:#c4c4c4}
.vcard img,.comment-navigation .newer a,.comment-navigation .older a{padding:5px}
.comment-meta,ol.commentlist li small,p.subscribe-to-comments label{position:relative}
.comment-meta,ol.commentlist li small{top:10px;left:10px}
.comment-text{margin:0 10px 0 0}
.reply,.comment-navigation .newer,input#submit{float:right}
.reply,.comment-navigation .newer a,.comment-navigation .older a,input#submit{background:#4c7faa}
.reply{margin:0 10px 10px 0}
a.comment-reply-link,.reply a:link,
.comment-navigation .newer a,.comment-navigation .older a,input#submit{display:inline-block;text-align:center;cursor:pointer;color:#fff}
a.comment-reply-link,.reply a:link{padding:5px 0} a.comment-reply-link,.reply a:link,input#submit{width:70px}
a.comment-reply-link:hover,.reply a:hover,.comment-navigation .newer a:hover,
.comment-navigation .older a:hover,input#submit:hover{background:#e7e7e7;text-decoration:none;color:#4c7faa;font-weight:bold}
a.comment-reply-link:hover,.reply a:hover,input#submit:hover{width:68px}
a.comment-reply-link:hover,.reply a:hover{padding:4px 0}
a.comment-reply-link:hover,.reply a:hover,.comment-navigation .newer a:hover,.comment-navigation .older a:hover{border:1px solid #4c7faa}
.comment-navigation{margin:10px 0 10px 0} .comment-navigation:after,#respond:after{content:".";height:0;visibility:hidden}
.clear{clear:both}
.comment-navigation .newer a:hover,.comment-navigation .older a:hover{padding:4px}
form#commentform textarea,form#commentform input{padding:2px 3px}
form#commentform textarea{width:442px}
input#submit{padding:5px 0 !important;border:0 !important}
input#submit,p.subscribe-to-comments input{outline:0}
input#submit:hover{padding:4px 0 !important;border:1px solid #4c7faa !important}
p.subscribe-to-comments{background:url('images/email_32.png') no-repeat}
p.subscribe-to-comments,.comment-rss{height:32px;text-indent:42px;padding:5px 0 0 0}
p.subscribe-to-comments input{margin:5px 3px 3px 3px !important;border:0}
p.subscribe-to-comments label{top:-2px;color:#666}
.comment-rss{background:url('images/rss_32.png') no-repeat}
 
/*comment sum stlying*/
 
.comment-total{text-align: center;font-size: 1.5em;color: #fff;}
.comment-total span{font-size: 2em;color: #800000;}

You can see my accomplished alteration of a default thesis comments page here.

Because there have been a couple of things usually manifest to a site admin, here’s a screenshot of a logged-in admin view:

admin perspective of accomplished default thesis mod

The CSS on top of is created such which this could all be incorporated in to roughly any, if not all, themes though some-more than a couple of tiny modifications, so don’t feel identical to you’re stranded with a default theme!

To have it simpler on you, feel giveaway to download all a files for my modified default theme here.

13 – Going Further

We’ve lonesome a lot of belligerent here, yet if you’d identical to to go even serve with your site’s comments, here have been a tiny links for serve reading:

 Advanced Wordpress Comment Styles and Tricks

Go here to see a original:
Advanced Wordpress Comment Styles as great as Tricks


Get Auto Caffeinated Content for Your WordPress Blog



WRITE BETTER CSS WITH BEST PRACTICES

CSS Best Practices

Everyone has a somewhat opposite proceed to CSS. That’s partial of a reason it can be a calamity to revise someone else’s code.

But there have been a couple of good practices we can use in your CSS to have your stylesheets easier for we to read, as great as easier for any a single else which ends up modifying them in a future.

Single-line vs. Multi-line

The initial preference you’ll have to have in your CSS is either we wish to write it on multiple lines, similar to this:

.title {
        font-size:14px;
        line-height:20px;
        color:blue;
}

Or on one line, similar to this:

.title {font-size:14px;line-height:20px;color:blue;}

When we proposed out, we began with a initial method. By swelling a opposite CSS properties out onto opposite lines, we have them easier to read. That’s a great assistance when you’re still removing used to CSS.

As we got more confident with CSS though, we substituted to a second method.

Once you’re gentle with CSS, a greatest time waster becomes anticipating a component (the .title part) we need. When you’ve separate any skill in to a own line, a record becomes unequivocally prolonged as great as unwieldy. we find it easier to indicate down with a second method.

The file size is utterly dramatically cut down (more on which later).

Of course, a lot of people will remonstrate with me there! This preference comes down mostly to personal preference. If you’re happier with a single over a other, afterwards go with it.

Section Your File

Like we pronounced above, a single of a greatest hassles of operative with CSS is simply searching for a line we need to edit. To assistance with that, it’s value dividing your record up in to sections.

For example, we could have a “header” territory for all a manners relating to a head of your page. Then when we need to revise your slogan, we know where to look. A elementary criticism on tip of any territory is all we need:

/*** Header ***/

Start With a Reset

Every browser relates a own somewhat opposite styles to elements by default. The thought of a reset is to take divided all of a styles a browser competence add. It helps a great understanding when it comes to browser inconsistencies.

A reset can be as elementary as adding this at a begin of your stylesheet:

* {margin:0;padding:0;}

Or if we wish a some-more extensive reset record which will cover everything, check out Eric Meyer’s CSS Reset.

Use Shorthand CSS

Shorthand CSS is simply combining a couple of associated rules in to one. Let’s take an e.g. to see since it’s useful.

For example, if we longed for to set a blue credentials with an picture in a tip right corner, we competence routinely do something similar to this:

.example {
        background-color: blue;
        background-image: url(images/blue-bg.jpg);
        background-position: 100% 0;
        background-repeat: no-repeat;
}

But this could be total in to one elementary rule:

.example {background: blue url(images/blue-bg.jpg) 100% 0 no-repeat;}

It can take time to get used to a sequence of things in a shorthand rule, yet once we do, they turn second nature, as great as a value is clear!

You can review some-more about what shorthand CSS options there have been at Dustin Diaz’s site.

Multiple Classes on One Element

This is mostly an opposite aspect of CSS, yet it’s probable to add as many CSS classes to an element as we want.

The reason to do this is which we can define general CSS styles which can be practical to a series of elements.

Let’s contend we set up CSS styles for positioning as great as for info, afterwards we could do something similar to this in your HTML:

<p class="info left">Some e.g. calm in your info paragraph.</p>

That proceed a divide gets a coming of an info paragraph, as great as we don’t have to redefine a styles for aligning it to a left.

Generic CSS Styles

Positioning Header Elements is Easy

In many sites, a header is a set breadth as great as a set height. With a rest of your page, a tallness changes depending on a calm inside of (Long pages of calm = longer pages), yet with a header, the tallness never changes.

That equates to we can have have have have have make use of of of of of of comprehensive positioning for all in your header. Positioning is a single of a harder tools of CSS to hang your conduct around, as great as a tendency at a begin is to sense a single way (e.g. floats) as great as only have do with that.

Let me give we can e.g. of since absolute positioning is value learning:

#header {position:relative;width:960px;height:120px;}
.logo {position:absolute;top:20px;left:20px;}
.slogan {position:absolute;top:70px;left:20px;}
.searchform {position:absolute;top:20px;left:600px;}

And in 4 lines, you’ve positioned any partial of your header. It doesn’t get easier than that. That’s how we lay out any header we code.

Don’t Worry About Ems

There have been a couple of opposite units of rise measurement in CSS. Pixels, “em”s, as great as percentages. Ems as great as percentages have been a proceed of laying things out relations to a line-height.

An old square of advice was regularly to have have have have have make use of of of of of of ems since sure browsers (Have a theory which one…) couldn’t resize pixel fonts. That was a vital rain for office building an permitted blueprint for users who need incomparable rise sizes.

Nowadays though, any complicated browser can work with pixel fonts (Because many of them have have have have have make use of of of of of of zooming now, instead of only creation a fonts larger).

FireFox Zoom

Pixels have been much, many easier to work with in your CSS. And since which they work any bit as great as ems now, there’s no need to mystify things.

Unordered Lists Make Things Easier

Again, this was something we didn’t collect up on until I’d worked a lot with CSS. You’ll begin out by meditative of HTML unordered lists as a proceed of inventory bullet points, yet in reality, they’re a great proceed of imprinting up any arrange of “list” content.

Aside from unordered lists, what about a navigation club in your header? Or a set of subscription options after a post? Or a elements in your sidebar?

With your HTML great noted up, we can simply apply styles to all of a parts of your “list”, e.g. for your sidebar:

ul#sidebar li {margin: 0 0 20px 0; border:1px solid #000;}

Use Comments

Comments have been a proceed of adding a little explanations to your code. Thankfully, many CSS is self-explanatory as great as we won’t need to be concerned about commenting extensively.

You should however have have have have have make use of of of of of of comments for any wily tools whose role competence not be rught away obvious. For example, if we combined an additional order or dual to make sure things worked in IE, we competence wish to supplement a criticism observant since those manners have been there.

CSS Comments

Stay Consistent

A lot of a things we’ve talked about come down to personal character as great as choice. Once you’ve done your choices though, we should have an bid to be consistent.

If your character all a time changes from a single plan to another, afterwards when we go to edit a record again in 6 months time, we competence find it a headache even to work with your own formula now!

On tip of that, if we hang with a sure proceed for a while, it gives we time to unequivocally try it out as great as see if it functions for you (e.g. if we barter from multi-line CSS to single-line, we can pledge your subsequent plan is starting to be harder than normal. But in 3 or 4 projects time, we competence find you’re faster than ever before!)

Minify Your CSS

When you’ve accomplished laying out your CSS in a many human-friendly proceed possible, it’s time to consider about a machines.

If your record is smaller, it’s starting to download quicker. How do we have it smaller? By cutting out all of your comments as great as whitespace. You keep a human-friendly duplicate for we to edit, as great as afterwards have have have have have make use of of of of of of a machine-friendly a single as a tangible record to be downloaded.

For a elementary apparatus which takes caring of this, check out Minify CSS. For a some-more formidable tool, have a demeanour at a YUI Compressor.

Minify CSS

It’s up to we either or not we wish to do this. The value is faster loading times, yet a waste is which it’s a bother as great as we have to redo it any time we refurbish your CSS (Also, if you’re we do it for a WordPress theme, you’ll need to supplement a thesis info comments behind in any time).

For those reasons, we don’t do this all a time. For clients who wish to have slight CSS edits themselves occasionally, this is customarily a large no.

Even for my own site, we already have have have have have make use of of of of of of single-line CSS so using my stylesheet by a minify apparatus on tip of gives a 7% reduction. That’s about 1kb. It’s not value a bid there.

How Do You Write Your CSS?

The tips I’ve since on tip of have been all to do with how we write my CSS. Do we have any alternative tips you’d similar to to share? Or remonstrate with anything I’ve mentioned? I’d adore to listen to it in a comments!

Of course, if you’re operative with a CSS framework, your standards have been starting to have to enter into with theirs. There have been a lot of great frameworks out there, so take a time to find a single which we can work with easily. Check out this list at 1st Web Designer for an general outlook of multiform opposite frameworks.

 Write Better CSS With Best Practices

Read some-more here:
Write Better CSS With Best Practices


Get Auto Caffeinated Content for Your WordPress Blog

Pages