How to fix “unexpected T_FUNCTION” error in PHP
I tested one of my plugins yesterday and was shocked to see a nasty error message: What was going on? I could have sworn this worked fine last time I tried! Then I remembered that I changed my PHP Version in MAMP, from 5.5.3 back to 5.2.17. And exactly therein lies the problem, because the code that was amiss was something like this: $zendash_updates = function ($a) { return null; }; This is what’s known as an anonymous function in JavaScript, and it didn’t exist in PHP until Version 5.3. If we wanted to be backward compatible, we...
read moreYou are a real guru my friend!
He find the code, he show the right way for editing it and it is working great now ! You are a real guru my friend ! :)) I really appreciate it. Thanks a lot…
read moreHow to change the admin footer bar in WordPress
The admin footer bar is the one line of text displayed at the very bottom of your admin interface. By default it reads “Thank you for creating with WordPress” on the left, and shows the current WordPress version on the right. You can however change this if you like. Perhaps you want to provide additional links to services you provide to your clients, or you may want to hide the version or WordPress branding – or you just want to de-clutter and feel that “less is more”. I head you! The two areas can be targeted...
read moreHow to get a link to a specific WordPress admin page
To get a reference to a specific admin page (such as Dashboard), we can use the admin_url(), network_admin_url() or get_admin_url() functions, like so: get_admin_url( ‘index.php’ ); You will need to pass the reference to the page you’d like to display. To find out how, simply click on the menu page in question, then look at the URL. Anything after wp-admin/ is the parameter. Those functions are described in detail in the WordPress Codex: http://codex.wordpress.org/Function_Reference/admin_url...
read moreHow to use custom CSS in the WordPress admin interface
A bit related to my previous post about using jQuery UI elements in the WordPress admin interface, it’s likely that at some point you want to load your own CSS styles to your plugin or theme’s admin pages. Lucky for us that’s a lot easier that loading JavaScript! Here’s how – works without adding an action, anywhere outside your main function: // link some styles to the admin page $starterstyles = plugins_url (‘starter-styles.css’, __FILE__); wp_enqueue_style (‘starterstyles’,...
read moreHow to use jQuery UI elements in the WordPress admin interface
One thing I’ve been struggling with was to use jQuery UI elements in my plugins, for example jQuery UI Tabs. Even though the libraries are included with WordPress, I couldn’t get them to work. Thanks to Pippin’s Plugins I could figure it out – thanks, Pippin! My initial mistake was the way I created the admin page. WordPress provides so called wrapper functions that make creating an admin page very easy. For example, adding an admin page under the Dashboard works like this: // Add a new submenu under DASHBOARD using...
read moreHow to hide Menu Options in the WordPress admin interface
This is surprisingly easy thanks to a function called remove_menu_page(); To remove the Dashboard item for example, you can use the function like this: // remove Dashboard remove_menu_page(‘index.php’); The parameter is the filename of the item you’d like to hide. To find out what that is, simply hover over the menu options in the admin interface and watch URL your browser displays at the bottom. If your browser doesn’t display anything, click on the menu item in question and see that the URL looks like. The parameter...
read moreHow to add drop down categories to Automattic’s P2 Theme
You know I love P2. I always have, and I always will. It’s the perfect theme that turns my WordPress installation into a notebook site. Many users – me included – have often wished for the addition of categories to P2, so that when you write a post, you can add it to the category from the front page, perhaps via a convenient drop down menu. Here’s how to do it with P2 Version 1.5.1. And if you don’t want to hack the code yourself, I’ve got a full working project on GitHub that’s ready to rock....
read moreHow to auto redirect to the front page after login
Sometimes I’d like to go straight to my front page after logging in. This is extremely useful with themes like P2 which allow you to post from the front page, but may also come in handy if you don’t want your users to be put off by the admin interface. There’s a very effective solution built right into WordPress. Usually you’d login with something like this: http://yourdomain.com/wp-admin This in turn is a shortcut that really calls the actual php file: http://yourdomain.com/wp-login.php To redirect to the front page...
read moreIntroducing The P2 Header Ad Plugin
I always loved Automattic’s P2 theme: it’s one of the most innovative ideas for blogging I could find. I’m using it on several of my notebook websites, including this one. I’ve been tweaking P2 for quite some time, and one thing I wanted to do is display an advert inside the P2 header. As you may know, P2 doesn’t like child themes very much, so I wrote a future proof solution as this handy plugin. P2 Header Ad let’s you display an advert of your choice inside the header. And when the theme is updated, your...
read more