Collection of WordPress Snippets and Hacks

Sep 29
2010

If you are a Wordpress developer there is no doubt you will have your own personal collection of code snippets, hacks or even short-codes that you can call upon in time of need. They are those little lifesavers that can solve complex problems with only a few lines code… they truly are indispensable no matter which host monster you use. In this design news round-up we have highlighted some recent articles and posts that will freshen-up your Wordpress toolbox.

Wordpress Snippets

Wordpress Snippets

The idea behind WordPress Snippets is simple; to provide small snippets of code, helping you to create a magic WordPress Theme. The original documentation of WordPress is excellent, but not as straight forward as you may want. Straight forward is the lead word for WP Snippets. No talk, just Snippets.
Wordpress Snippets

10 useful new WordPress hacks

dr_wp_010 useful new WordPress hacks

This WP hack list, from CatsWhoCode, has a whole of lot fresh new snippets to help with Wordpress dev. Want to remove comments autolinks? Or, are you looking for a hack that will display a Twitter style “time ago” date? If so, you will find the answers in this post.
10 useful new WordPress hacks

10 Useful Wordpress Search Code Snippets

10 Useful Wordpress Search Code Snippets

In this post will find 10 really useful code snippets that will help improve your WordPress Search functionality.
10 Useful Wordpress Search Code Snippets

By Paul Andrew (Speckyboyand speckyboy@twitter).

10 Tips for Writing Better PHP Code

Sep 15
2010

There are hundreds of ways to writing out code with hundreds of methods to achieve certain functionality. However, out of these many ways of writing code to get to the final product, there are many habits that are not great to the programmer or to the functionality of what you are trying to achieve. Furthermore, we discuss 10 tips for improving and writing better PHP code.

Development Style

Tabbing, double-spacing, all on one line; we all have our style of writing out code and there really is not a right or wrong way of laying your code out. However, many developers tend to fail at keeping their development style fluent throughout a project. I myself have been caught a few times adapting to new styles within one project.

Furthermore, it is best to keep your code laid out using one development style rather than several to keep your code easily readable and organized. If your development style sometimes evolves to something different, it is best to not use your new development style on a project that uses a different style, but rather implement your new development style on new projects you may start. This keeps all of your projects fluent and organized.

Good Variable and Function Naming

Many developers do not really care about proper variable and or function naming. However, good function and variable naming is key to have more organized code, which categorizes under better-written code as it becomes clearer to understand and comprehend.

Naming variables and functions properly is rather something easy to do and should be based on what the variable value is and what the function achieves. This not only provides easy to understand names, but it also helps you and other developers understand what each function or variable performs and holds by just reading the short name.

Commenting Your Code

Commenting your code is a major step to organized and readable code and actually compliments most of what you can do to organize your code, as it is a key aspect in organization and usability. When writing comments to describe certain actions, functions, or code, it is best to keep the comments strict and to the point without describing what everything is.

For example, if you have a code snippet that is quite obvious in terms of its functionality, it is best to either leave a few words about it or not to comment it at all, as too many comments can be obnoxious.

Do Most of the Work

Copying and pasting code is something we tend to do most of the time, from one project to another, or from code, we may find useful on the net that has been done for us. However, copying and pasting code can sometimes hurt you in the end as you may not be familiar with your project or code as much as you had hoped you were or as much as you need to be. Furthermore, copying and pasting a few snippets is fine, but you should do most of the work to freshen your memory.

Look Around

Sometimes we might be doing something new and do not know what the best route is to take in terms of speed and performance, thus, looking around at other code from people who created something similar to what you are creating is sometimes a great idea to do to obtain a general idea on how to approach it better. This does not necessarily mean copy and paste the code, but rather just get a general idea of how it works.

Understand the Language’s Limitations

We sometimes try to achieve many things the language was not designed for or is not capable of doing by creating workarounds. This is not a great idea, as your created workaround may not work sufficiently or effectively. Therefore, it is best to understand the language’s limitations, and to work within them.

Receive Structural Feedback

We sometimes think that we are the only ones, who know how to properly develop, but we are not and in fact, there is always someone out there better than us. My point is, it is always good to receive a second opinion on your code in terms of structure, as some feedback can be critical to enhance the performance of your script.

Testing Your Code Often

Part of making your scripts closer to bug free is to test your work often and as you go along. The problem with many developers is that they think what they develop should work fine the first time and decide not to test certain aspects of their script as they go along, and in the end, they end up with several bugs and many they may not catch immediately. With that said, it is in your best interest to test many aspects of your code or script for bugs as you go along in development, this is proven to reduce bugs in the long run.

Built-ins over Building Your Own

We sometimes tend to recreate a built-in function just to have it. The problem with unnecessary recreation of built-ins is that the performance is affected. Moreover, using built-ins when applicable is a better idea and not only does it increase performance, it also keeps your scripts clean from unneeded code.

Don’t Split Everything into Files

Splitting your code into several files is actually part of keeping your scripts or projects organized instead of having everything all in one file. However, many projects I have seen tend to split everything into many files, sometimes separating individual functions into individual files.

This overkill and not only affects the way your code is laid out but it also affects performance. For example, instead of splitting individual functions into individual files, create a functions file and store all of them there, or group them into files. This still keeps your project organized and it keeps things reasonable.

Remember, doing something beneficial is great, but overdoing it or not doing it at all causes a negative effect, thus, use your judgment, and use techniques and methods reasonably.

Using PHP Show Different Content to Visitors From a Specific Country

Aug 13
2010

Our topic for today’s Design Reviver Answers news round-up is a question that was recently asked on PHP. And to be more specific the question was How Do I Show Different Content to Visitors From a Specific Country Using PHP?

Do you have an alternative solution, maybe a fresher technique? You can leave your comment below, or you can leave a your answer on the original question on Answers here

How Do I Show Different Content to Visitors From a Specific Country Using PHP?

How Do I Show Different Content to Visitors From a Specific Country Using PHP?
This question was originally asked by a Devone, and you will find the best answer below:

The Best Answer came from an Unregistered User:

How Do I Show Different Content to Visitors From a Specific Country Using PHP?

The Next Answer came from a Pablo G:

How Do I Show Different Content to Visitors From a Specific Country Using PHP?

Unanswered Answers

That is now five weeks without any unanswered questions!!!

Thanks to everyone who asked a question, but most importantly thanks to everyone that took the time and effort to offer helpful and useful answers.

Round-Up of Fresh jQuery Tutorials

Aug 12
2010

There really is no limit to what can be achieved with jQuery. And when it is in the right hands those limits are challenged all the time, constantly pushing back its seemingly endless boundaries by developing fresh and creative techniques. In this design news round-up we have collected our favorite recent jQuery tutorials.

Super Ajax Polling/Voting System using JQuery, Ajax, PHP and MySQL

Super Ajax Polling/Voting System using JQuery, Ajax, PHP and MySQL

Super Ajax Polling/Voting System using JQuery, Ajax, PHP and MySQL →

jQuery Quickie: Slot Machine Style Navigation

jQuery Quickie: Slot Machine Style Navigation

jQuery Quickie: Slot Machine Style Navigation →

How To Create A Great Contact Form

How To Create A Great Contact Form

How To Create A Great Contact Form →

Music Portfolio Template with HTML5 and jQuery

Music Portfolio Template with HTML5 and jQuery

Music Portfolio Template with HTML5 and jQuery →

A Simple Movie Search App w/ jQuery UI

A Simple Movie Search App w/ jQuery UI

A Simple Movie Search App w/ jQuery UI →

By Paul Andrew (Speckyboyand speckyboy@twitter).

Why NetBeans IDE 6.9 Is An Awesome Editor

Jun 19
2010

A Tutorial Of PHP Frameworks

Apr 26
2010

First of all, we believe you should know what a PHP framework is before we move forward to a full tutorial of PHP frameworks. PHP is the most common scripting language in the world and there are many reasons for this. It is flexible and easy to use. There are times when coding in PHP or any other language can get a bit repetitive and droning. This is where a PHP framework comes in and this starts out a tutorial of PHP frameworks.

PHP frameworks help with the promotion of rapid application development. In turns, this helps save time and it also helps build applications that are more stable. Did we mention that it also reduces the quantity of recurring coding for those developers? This is one of the main reasons why so many developers enjoy using it. It is also good for beginners! In fact, it helps them build apps that are more stable by guaranteeing accurate database interaction and coding. Instead of wasting your time writing a code that is repetitive, you will now have more time to create the web application.

So, why exactly should you use a PHP framework? That is the question that many individuals are looking for answers to. There are a number of different reasons as to why developers should use PHP frameworks. The number one reason is for speeding up the process of their development. Reusing the code when similar projects come along will save them from putting in extra time and effort. The framework allows the individual to use pre-built modules for performing those repetitive coding tasks. This way, the developer will be able to put more of their time towards developing the application instead of building a foundation with every project that they work on. Another pretty big reason as to why developers use frameworks is because of the stability. Simplicity is one of PHP’s biggest assets and for that reason, there are many individuals that prefer using the scripting language. However, this exact same thing can be one of its biggest downfalls. For those beginners, it is perfect, because it is easy to use, you can write bad code without even realizing that you did so.

With PHP, the application could still work, but you may have opened a big security hole in the coding without even realizing it. This could put you more at risk of attacks. It is important that you remember just how forgiving the language of PHP can be. It is always important to look at those lose ends of your coding and tie them up. Yes, even if your application is working perfectly on the outside. When it comes to PHP frameworks and the availability, it is pretty much widespread. You have many different frameworks that you will be able to pick out of. If you like and you have a creative touch, you will even be able to create your own.

Although, many of the developers out there choose to pick from one of the frameworks that are well-known because of the popularity, their forums and big support teams. The forums will allow you to chat with other developers that use the same kind of framework that you do. When it comes to your projects, you should first look at them and examine them in order to make sure you should be using a framework. There are a number of different questions that you should ask yourself. Below, we are going to go over some of those questions: 1.Is it going to save you or anyone else who uses it, effort and time? 2. Is it going to improve stability? Did you answer yes to one of these questions? If you did, then PHP framework may be the right choice for you.

For beginners and experienced individuals alike, framework can speed up the entire build process and help eliminate chances of bad coding. Many look at it as being a tool for those weak programmers that do not understand how to go about writing excellent, clean code. This may be true or it may not be, but the fact to it all is that PHP frameworks is a great tool that is useful to many successful people. It can help tighten up your coding and save time. When you are working on a project that has deadlines that are pretty tight, using this will be a huge benefit to you. Imagine being able to speed up the coding process. Therefore, if you are in a time crunch, PHP will be very useful to you and there is no denying this. If you are working on projects that have a large amount of repetitive coding, this will make the job less tedious.

Best 12 WordPress themes design&code tutorials

Apr 07
2010

Twitter API | Post Message To Twitter

Mar 28
2010

A Selection of Code Snippets from Design Reviver Answers

Feb 19
2010

Everyday Design Reviver Answers is offering solutions via useful snippets of code, helpful resources and general tips for all your web design issues. And as such we would like to share with you our favorite code snippets from this last week.

It has been yet another good week, thanks for your support!

Have you asked a question yet?

How Can I Display More Than One Twitter Feed On My WordPress Blog?

We do this by accessing the persons Twitter account RSS feed, then fetching it and embedding it on your site.

Replace the example RSS’s with the ones you’d like.

get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>

    <?php if ($maxitems == 0) echo '
  • No items.
  • ';
    else
    // Loop through each feed item and display each item as a hyperlink.
    Foreach ( $rss_items as $item ) : ?>

  • <a href='get_permalink(); ?>'>
    get_title(); ?>

I Have Multiple Authors On My Site, How Can I Display Their Info?

If you want to display their info at the bottom or beginning of the post, then use this and place it in the corresponding area of your WordPress files. (i.e. Single.PHP or Comments.PHP)

Edit the author box as necessary.

How Can I Display Someone Else’s FeedBurner Post On My Site?

You can add the following jQuery code anywhere you want on the site (i.e. Sidebar, footer, etc.) Just remember to replace and specify which feed you’ll be recalling.

$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://feeds.feedburner.com/examplefeed",
success: Function(data){
$("#date").text($(data).find("item:first>pubDate:first").text());
$("#title").html("link:first").text()+"'>"+$(data).
find("item:first>title:first").text()+"");
$("#description").html($(data).
find("item:first>description:first").text());
}

What Can I Use To Place A Shadow Behind My Images And Outlines?

If you’re refering to having your images and boxes with a drtop shadow, then you need the Box Shadow CSS feature to work for you. Here’s what you need to place in your CSS:

.shadow {
box-shadow: 3px 3px 3px #f2f2f2;
-moz-box-shadow: 3px 3px 3px #f2f2f2;
-webkit-box-shadow: 3px 3px 3px #f2f2f2;
}

What’s The Easiest Way To Redirect A Specific Page On My Site?

If you want to redirect users to another site once they enter a specific area on your site then you just have to use some of this Javascript code in the page to be redirected from:

Replace the www.google.com with the URL address you wish to redirect to.

Unanswered Questions

There are always some questions that seem to get through the net, can you help us answer them?

  1. What Is A Good Resource To Create Style Sheets For Multiple Web Browsers?
  2. How To Create A Profile Which Can Be Navigated, Without Using HTML Or Flash?
  3. How Do You Find New Clients?
  4. What Are Your Top Usability Tips For Web Designs?
  5. What’s A Good Mobile Framework To Use?
  6. How Can I Integrate ECommerce On My Site Without Any Coding?

Thanks again, firstly to everyone who asked a question, but most importantly thanks to everyone that took the time to offer always helpful and useful answers.

5 Interactive and Creative Uses for PHP

Jan 28
2010

PHP is a powerful and widely recognized scripting language that enables you to build interactive applications and websites. If you’re new to using PHP, then you’ll most likely benefit from know how you can use it to make your website or applications more interactive and aesthetically pleasing.

With PHP you’re rarely limited to functionality and restrictions, if you can code it, you can build it. Below we’ll touch base on 5 Interactive and Creative Uses for PHP web and desktop oriented.

Graphical User Interface

There are instances were web developers make the switch from only knowing how to create apps for the web, to building desktop applications. And they use PHP as a transitional vehicle since many are already familiar with the programming language.

Creating a GUI made for your desktop requires extensive knowledge of PHP and various extensions. Once you’re able to really master the language by coding for desktops, designing for the web using PHP will be much easier.

Here are a few PHP extensions to get you started:

  • PHP GTK – This is an open source extension with a nice toolkit.
  • ZZEE PHP GUI – This solution allows you to convert your PHP scripts into functional Windows applications.

Building Facebook Apps

You can utilize PHP to integrate Facebook with a website. Before you begin developing Facebook applications with PHP you must first become acquainted with Facebook’s Developer Guide. It’ll help you get a much better feel of what you need to get started, and it also goes in-depth on the Facebook PHP client library subject.

It also provides detailed instructions on how to install and utilize the files included within the library. This is definitely a great resource to check out, especially if you have or plan on having clients that may want you to build a Facebook application for them.

Creating Mailing Lists

With PHP you can write your very own script allowing you to send e-mail newsletters to your clients and anyone else you’d like. You can also use a ready-made script. PHP mailing lists are generally used as a way to keep your anyone you’d like up-to-date with whatever information you need them to know.

The most important feature is mass mailing. This PHP online documentation explains PHP mailing functions in-depth. You can also download all-ready made scripts such as this one for your website.

Online Communities

A good way to promote and create self-awareness for your business, product, or service is to make your customers and users feel as though a supportive community has their back. You can create a forum, or a small social network that will allow your customers to interact and find out more about your products.

Many times a users is looking for a quick and effective median to receive quality support, creating an online community can reassure the user that choosing your service was/is the best choice. It will also help you receive feedback so that you’re able to improve the quality of your service.

There are various scripts available for building your online community, however, the most popular choice would be a PHP Framework such as Codeigntor or CakePHP. You can also use a variety of PHP tools that are efficient in their own ways, here are a few: php BB, vBulletin, and Pun BB.

Developing an E-Commerce

Implementing an E-commerce solution is one of the most sought-out uses for PHP. No matter the level of business or type of client base you may be pulling, having an E-Commerce solution at your fingertips is a powerful way to grow your business.

Of course, most of the effective solutions you’ve come across utilize PHP for its accuracy and stability. Whether you’re building from scratch or you’re adding new features to an existing one, PHP is the logical choice.

Building your own shopping cart application means you’ll be doing a lot of coding, especially if your creating one entirely from scratch. One of the best ways to successfully accomplish this is to use a framework (as mentioned above) such as CodeIgniter or CakePHP. CakePHP has a bakery section that contain a large selection of extensions and features for E-Commerce developers. You can integrate various payment solutions as well.