Tag Archives: PHP

PHP random sentence spinning function

recycle_phpIn this article I'm presenting my solution for a very common PHP developer job interview task where it is required to create a random sentence spinning function. Input of this function is a PHP string that employs syntax telling our code where's the randomness and what are the possible substrings for each section of randomness. Basically it is required to create PHP code that's able to process strings like the following:

<?php
$string = '{Please|Just} make this {cool|awesome|random} test sentence {rotate {quickly|fast} and random|spin and be random}';
?>

As you can probably guess the input sentence uses braces to declare sections of randomness and the pipe character to delimit substrings that should be used randomly inside their sections. Code also must be able to process nested sections of randomness.

Continue reading

Install Magento on Ubuntu and fix PHP Extensions "0" must be loaded error with PHP 5.4

Magento LogoEvent though I follow MVC pattern in many of my web related projects, like every PHP web developer I came to the point when I have to dive into some well established MVC PHP framework. This is something backend developer must do if he wants to stop being a lone wolf and start working inside a team of developers. Web frameworks of my choice are fast Codeigniter and powerful Zend Framework. Getting to know about Codeigniter wasn't hard, but mastering Zend is still work in progress especially since Zend Framework 2 has been recently released. Talking about Zend, recently I got interested in getting to know about open source eCommerce solutions and I choose to get acquainted with Zend based Magento. In this article I'll show you how to install Magento on a Debian based distributions like Ubuntu and provide workaround for the PHP Extensions "0" must be loaded error thrown by Magento installer running on PHP 5.4.

Continue reading

Adding GeSHi/WP-Syntax compatible pre HTML tag button to WordPress Quicktags Javascript editor

Wordpress Logo BlueIf you're anything like me your blog is probably full of code snippets and you're using WordPress Quicktags editor to enter your posts content. You're also using GeSHi compatible syntax highliter like WP-Syntax to make your code snippets more readable.

In this article I'll give you Javascript and PHP code I've created to add GeSHi compatible pre button to my blog's Quicktags editor toolbar on both frontend and backend.

Continue reading

PHP function for adding admin menu separator inside WordPress backend

WordPress admin menu separatorOften your WordPress plugin or theme adds admin submenu inside WordPress admin interface using add_menu_page() functions on admin_menu hook or using WordPress Settings API. When your code adds multiple submenu items wouldn't it be nice to create section on admin menu to reduce clutter? Unfortunately WordPress currently doesn't support adding admin menu separators so you must do it manually by filtering $menu global variable. Here's function for doing that together with an example that should demonstrate it's use.

Continue reading

How to hide that you are using WordPress aka debranding WordPress

WordPress logo I like WordPress, really I do. I use it whenever possible to make my products path to my clients short and enjoyable. There's just one thing that pokes me in the eye whenever I need to deliver my project. WordPress developers have created greatest CMS ever conceived. They did that free of charge and the community is very grateful for all they've done, but do they really need to stick WordPress name and logo everywhere? Actually I already tried to remedy this situation inside one of my earlier articles. In this article I'll show you a few more tricks to remove some of WordPress branding from WordPress user interface.

Continue reading