Articles > Snippet

PHP

Turning a WordPress shortcode in to a Widget

In my last tutorial we created a shortcode for displaying recent Tweets using the Twitter API and OAuth2.0. Having thought about it a bit more, I think that it would be quite handy to have it as a widget as well. It's actually very easy to turn any shortcode in to a widget, and this logic could be used for lots of different shortcodes. Getting Started ... First up, we'll need to grab the source code from the previous tutorial. Underneath our previous class we're going to get the sample class from the WordPress...
PHP

Using wp_cron to disable commenting on old posts

One of the little known, but incredibly useful functions of WordPress is wp_cron. It allows you to schedule tasks for execution at a later time, the tasks can also be repeatable. It's not perfect and does have one serious problem, in that it is only executed while users are actually navigating the site. But on a popular site this won't make a difference, but it's still worth noting. Something I see regularly been asked for is the ability to disable commenting on or delete/hide older posts, generally for...

Adding a simple authentication using PHP require and includes

Please note that this tutorial has now been superseded by a later, more in-depth tutorial available here Continuing on with our to-do application, in this weeks snippet we're going to be using PHP's require_once function. The require_once function is similar to the require function, in that it will execute and include any php code with the calling file but with one vital difference. It will only execute once. This is important for us in this tutorial as we are going to use it to validate our user. There...

Turning a form element into JSON and submiting it via jQuery

Continuing on with our work on creating a To Do Application, this weeks snippet is on how to submit a form using jQuery. This snippet expands on what was covered in the previous tutorial, so if you've just joined us you might want to read it first. JSON - JavaScript Object Notation ... Last week we saw how to intercept the submit event of a form, this week we're going to complete that method and use jQuery to perform the submit for us. There are several ways to send data back, we're going to focus on JSON. JSON stands...
CSS

A Continuous CSS3 Animation

Introduction ... Static headers with boring backgrounds are everywhere... why don't you try and spice yours up with a simple CSS animation? I'd like you to meet Bob, he's my friendly static image and he'd really like to wave hello to you! Let's give him the chance. First up we'll need to do a quick operation and temporarily remove his arm (Sorry Bob!) Then we're going to rotate his arm (very gently) by 45 degrees. Now we can start re-assemble him using some simple HTML <div class="logo"> <div class="arm"></div>...
CSS

Recreating the Developer Drive logo with just CSS, no Javascript or Images

I quite like the developer drive logo animation. I remember seeing it a when I first found the site and thought it was simple, yet effective. I also wondered if it would be possible to replicate it using just CSS. In this snippet we'll cover CSS3 transitions and using @font-face to import some custom fonts. The first thing we need to do is import out fonts, I wasn't sure what the current 'd' font is so I have a similar font. The best place to go is www.fontsquirrel.com, you can pick from a wide selection of fonts...
CSS

A quick and simple CSS3 accordion menu!

Introduction ... Building on my previous tutorial, I thought it would an idea to show how to apply what we learned to the most basic of website features, the menu! I would strongly suggest reading my previous tutorial as we'll be jumping in at the deep end here. Once again, no JavaScript was used in the making of this tutorial! Every website has a menu, and there are lots of different styles that you can use. One style that is quiet popular in web applications and mini-sites is the accordion menu. The accordion...
CSS

CSS3 Stitched Effect

When it comes to design the key is to do more with less. Too much makes a page look cluttered, too little makes it look like you are back in the 90s. Luckily web developers can do some amazing things with CSS3 that give a page, or content within a page, that extra "pop" needed to make things stand out and look great without making the site look busy and thrown together. The next time you need to call attention to something on a page, try this cool effect in CSS3 that makes it look like an element has been sewn onto the...
Load more
Home CSS Deals DesignBombs HTML HTML5 JavaScript jQuery Miscellaneous Mobile MySQL News PHP Resources Security Snippet Tools Tutorial Web Development Web Services WordPress