Timthumb not showing images and throws “Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. ” error. [Solved]

timthumbRecently I faced a situation where the timthumb script was unable to crop the images and was throwing error messages. There are themes those still use timthumb even though its a bad practice to use in themes when we have already functions available in core WordPress. Anyway I had to fix the issue as I was not state to replace the timthumb functionality with core WordPress functions.

Here is the error message:

This issue occurs in several hosts, mainly the free hosts available these days. So, the trick is to find where the $docRoot variable was set and set it to my public_html folder manually in my home directory. In my file it was on line number 825. I did the following…

Obviously the /a9582221/ would be your username.

Where to make this changes ??
Search for the file timthumb.php and make the above changes. Thats it. The issue got resolved now.

Matt Mullenweg (the founder of WordPress) becomes the new CEO of Automattic

autmattic

Matt Mullenweg (the founder of  WordPress) becomes the new CEO of Automattic. 

Toni Schneider, a senior executive spearheading Yahoo’s Developer Network was on this position as CEO of Automattic (a company started by Matt Mullenweg of WordPressfor last eight years. 

After eight years, I’ve decided to hang up my CEO hat and ask Matt to take over the job.
— Toni

Find out more details here regarding the news “A new CEO for Automattic” : http://toni.org/2014/01/13/a-new-ceo-for-automattic/

 

How to disable responsiveness in the admin theme of WordPress 3.8

How to disable responsiveness in the admin theme of WordPress 3.8 ? How do I disable responsiveness of WP 3.8 admin ? Is there any way to disable responsiveness ? I want to disable the responsive hiding feature for tablets and mobile for the newly introduced WordPress 3.8 admin back end.

The question comes, Why do you need to disable the responsiveness ? So, here is a problem/situation that describes WHY ?
Stop Responsiveness WordPress 3.8
Problem/Situation:
I just updated my WordPress setup to WP 3.8 and most of my custom functionality are either inaccessible or very hard to manage on mobile devices. There are some things which doesn’t even get displayed on mobile devices. Earlier, I was able to manage my site’s functionality from backend on a mobile device too. Even though it was not responsive and not so cool. The problem is that I have installed some custom made plugins which were made keeping an eye on the old style admin theme and it provides me some custom made interface on the admin side. Obviously these were not made responsive. Now, with this new WordPress admin theme, all those custom interfaces are completely messed up. So I have two options:

  • Either revert back to WP 3.6/3.7 ( but I really like the look and feel of the new WP 3.8 theme yet I don’t need the responsive property 🙁 )
  • Or make changes to all the custom made screens/interfaces in the admin side to be responsive. ( I can do that, but it would take much time to accomplish. Also, does it worth doing just for the sake of a new responsive admin theme in mobile devices ? 😕 )

How can I keep the new, super cool, awesome theme of WordPress 3.8 yet disable responsiveness of the theme ? ❓ ❓ ❓

Solution:
I tried to search for any solution but didn’t find any. Here is a quick solution that I have done to get back my custom functionality in the admin screen.

  1. Create a plugin to add custom code.
  2. Take the css file that is responsible for the wp-admin side styling and responsiveness. Make changes to remove the responsive property out of it. Basically remove all the media queries written for mobile devices.
  3. De-register the default admin styling that comes with WordPress.
  4. Register and enqueue the changed css file again to apply the custom styling.

Download the code as a plugin: disable-responsive-admin

Code for disabling responsiveness:

Download the above code as a plugin: Plugin to disable responsiveness in WP 3.8 admin

Note: This never a proper/good way of doing changes to admin styling. Still, as I have upgraded and would like to keep the theme and remove responsiveness, I am using the above quick solution. If you are facing the same problem as I am, use the above procedure or download and install the plugin. You can modify the css file present inside the plugin directory too. Caution: Use with your own risk. 🙂 🙂

Do you need an admin interface to stop / disable auto update feature of WordPress ?

Now that the “Automatic update of WordPress core” has been introduced in WP version 3.7, there are some obvious questions those come into mind. Where can I control this automatic update functionality of WordPress 3.7 ? Is there any admin interface for it ? How can I disable auto update of WP ? So, before going to show you how can you control the automatic update feature on admin settings page, let me tell you some facts.

This newly introduced auto update of WordPress core files is only for security and maintenance releases which is considered to be MINOR releases. That means this auto-update feature won’t be affecting the major releases of WP.

automatic-update-wordpressMajor releases: 3.x –> 3.(x+1)  OR  3.x.x –> 3.(x+1)
Version 3.6 to Version 3.7 or Version 3.8

Minor releases: 3.7 –> 3.7.(x+1)  OR  3.7.x –> 3.7.(x+1)
Version 3.7 to Version 3.7.1 or Version 3.7.2 or Version 3.7.3

As this feature is not for major releases rather only for the minor ones, it won’t break your site and won’t create any major problems. So stay cool and don’t worry !!   🙂

Somehow, if you don’t need this auto-update feature for some reasons like:

  • You manage your site using version control.
  • You implement your own deployment mechanism.
  • You think there is no guarantees in this auto-update feature.
  • You want to upgrade manually with complete control and at you own convenience.
  • OR if you think there is any error in the stats provided by Nacin regarding zero failures 😉 

 

Now the Solution (Plugin that creates an settings interface for WordPress admin to manage & control auto updates):
By default, there is NO admin interface provided by WordPress to have control over this. However there are some hooks and config variables to manage this. Like:

 

Certainly there is a cool plugin called “Update Control” in the WordPress repo which provides a nice and easy interface to manage this newly introduced feature along with some more options. Plugin URL: http://wordpress.org/plugins/update-control/
 
disable auto update wordpress
Various features & controls provided by this plugin:

  • Enable/Disable automatic updates.
  • Set the level of releases for Auto Updates.
  • Enable/Disable automatic Plugin updates
  • Enable/Disable automatic Theme updates
  • Enable/Disable automatic Translation(languages) updates.
  • Enable/Disable the code versioning check
  • Enable/Disable sending emails for updates etc.

If you are developer and you want to do this in your existing code then read this answer by Chip Bennett at stackexchange. http://wordpress.stackexchange.com/a/120082/13615

How to setup PHP CodeSniffer on Windows machine ?

How to use CodeSniffer on Windows ? How to setup the PHP CodeSniffer on Windows ? These questions come to mind when you see various articles, tutorials which provides ways/steps to setup this on Linux. So here are simple steps to setup PHP CodeSniffer on Windows. Before going into this, for those who don’t know what is CodeSniffer? here is a simple answer.

If you are a developer or code reviewer and you want to check the code for any mistakes/if the code following particular coding standards, then CodeSniffer is a good tool to achieve that.

PHP_CodeSniffer is a PHP5 script that tokenises PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.

Now, lets setup CodeSniffer to check if our code follows a defined coding standard. 🙂

My setup environment:

  • Windows 7 Professional,
  • XAMPP for Windows( Apache, MySQL, PHP and Perl ) and the PHP install directory is C:xamppphp
Steps:
  • Open windows command prompt by going.
    Start -> Run -> type in ‘ cmd ‘ -> press Enter
  • Go to your php install directory.
  • Then type in the command to install PHP Code_Sniffer from the pear.php.net
  • subharanjan_codesniffer_installation

  • After completion, to check successfull installation run this command.
    if everything goes well, then it should show list of coding standard definitions found.

As the CodeSniffer is installed now, you can start using this to check files by using below commands. ( To run any commands, you should be inside C:xamppphp )

Checking a single file or folder:

Sample PHP_CodeSniffer output with no warnings:

Specifying a coding standard to use:

For more usage commands: http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php

How to add a new coding standard definition into PHP CodeSniffer ?

Lets take WordPress coding standard for demo purpose found here: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

Steps:
– If you have git installed on you machine, then run this command on git bash.

subharanjan_codesniffer_git_bash
OR

If you don’t have git on your machine, then

subharanjan_codesniffer_directory_structure
Now you can check any file for WordPress coding standard.

How to reduce 404 errors created by ++liker.profile_URL++

Are you getting lots of 404 errors in the log because of some urls having patterns like ” ++liker.profile_URL++ ” ? How to reduce 404 errors created by ++liker.profile_URL++ ? Here is the solution to stop those 404 errors and convert those urls to result in 301 permanent redirects to your homepage.

Problem:
Some days back, when I saw the log created by Better WP Security plugin installed on my blog, there were a lot of 404 errors because of some weird URLs something like this:

  1. subharanjan.com/subharanjan.com/subharanjan.com/remove-or-override-functions-attached-to-a-specified-filter-hook/++liker.profile_URL++
  2. subharanjan.com/++liker.profile_URL++

I tried to find out about this and seems like this is a link dropping spambot. I am not sure what exactly it does but here is a solution to stop this.

Solution:

  • Open you .htaccess file.
  • Add these lines below into your .htaccess file which can be found at the root of your WordPress installation.
    Add these lines before the lines( url rewrites ) added by WordPress for permalink support. It should look like this:
  • Save the .htaccess file and check by accessing one of the urls having ++liker.profile_URL++ and see if it results in a 404 Page not found error OR simply redirects to your home page.

Explanation of the above htaccess code snippet:
RewriteCond will be looking for the pattern “++liker.profile_URL++” in the requested urls. Once it finds that piece of text in the requested url, it will redirect the request to home page in place of creating a 404 error as mentioned in the RewriteRule section.

RewriteRule defines a particular rule.
The first string of characters after RewriteRule defines what the original URL looks like.
The second string after RewriteRule defines the new URL. This is in relation to the document root (html) directory. / means the html directory itself, and subfolders can also be specified.

  • ^ begins the line to match.
  • . stands for “any non-whitespace character”
  • * means that the previous character can be matched zero or more times.
    So, ^uploads.*$ matches uploads2009, uploads2010, etc.
    ^.*$ means “match anything and everything.” This is useful if you don’t know what your users might type for the URL.
  • () designates which portion to preserve for use again in the $1 variable in the second string. This is useful for handling requests for particular files that should be the same in the old and new versions of the URL.
  • [NC] matches both upper- and lower-case versions of the URL.
  • [R=301,L] – this performs a 301 redirect and also stops any later rewrite rules from affecting this URL. It’s on the same line as RewriteRule, at the end.

Source: https://kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs

Where to find the JSView Firefox Addon – Discontinued from Addons Repo.

Update: Date: 6th Sept. 2014

From Firefox 32(Version 32) onwards, this add-on JSView has stopped working and is no more compatible and won’t be in future versions of Firefox as well. However there is an alternative add-on which can be used for getting the list of JS and CSS file being loaded with web pages. Its the “Phoenix” add-on. 🙂

Phoenix will tell you how many CSS and JS files are loaded into a page, how big these are, it will let you edit, pack and de-obfuscate them too.

Download the “Phoenix” add-on, the alternative for “JSView”. https://addons.mozilla.org/de/firefox/addon/phoenix/

Where can I find the popular JSView firefox addon which I have been using since a long time. Today I formatted my system and reinstalled firefox. JSView Suddenly I found that the the most useful firefox addon to list/view/copy path/url of JS files and CSS files is discontinued from the official firefox addon repository. On the mozdev.org site, its mentioned that ” JSView appears to have been abandoned by the author. It hasn’t been updated since July 2008 ”
However, we can still use this addon( of-course with personal choice/risk ) by taking it directly from the stored location as it is no more displayed on the addons/extensions list.

To install this addon on your firefox browser, open the link on firefox and follow the procedure.
http://downloads.mozdev.org/xsidebar/mods/jsview-2.0.8-mod.xpi

Sources:

SQL query to get post and its meta_values as one row of record (single data grid)

EAV to Single row of Record with Separte Column

How to query EAV attributes into separate columns ? Here is the SQL query to get post and its meta_values as one row of record (single data grid). 🙂 🙂 WordPress stores the post data mainly in two tables (i.e. wp_posts and wp_postmeta). The first table stores the data which are common and apply to all the individual entities( like the entities of type post, page, media, attachment, custom post type etc..) Second table stores the attributes of those entities as key-value pair. So this is kind of following EAV model. For those who doesn’t know about EAV, it stands for Entity Attribute & Value. Generally when we are not following EAV style, we store the entity and its attributes as separate columns in one table, but in EAV each attribute is stored as rows. Usually it is done for a purpose: to allow columns to be added without having to make DDL changes . 6NF and EAV as principles and concepts offer substantial benefits, and performance increases.

But on certain scenarios we want the attributes stored as rows to be fetched and displayed as columns in single data grid. This is the most tedious part to select the data from two different tables and showing as single row of entity. However we can fetch and display the data by writing query somewhat like the following.SQL query to get post and its meta_values as one row of record.

This will display the posts which is having at least one of the above meta_keys set in the post_meta table. To display all the posts including those which doesn’t have any meta values in the post_meta tables.

EAV to Single row of Record with Separte Column

EAV to Single row of Record with Separte Column

Mashable changed its platform from WordPress to Ruby on Rails

Mashable New Look

Mashable New LookMashable, the latest in social media, tech, world news, business, entertainment related blog was based upon wordpress cms. Recently it has changed its look and feel with completely new style and fully responsive layout. Ruby on Rails with Backbone JS and Handlebarsare the platforms used to built the new site. Features like Adaptive Design, “Next Big Thing” and “Velocity” sections, Infinite scroll features inplace of old pagination and Microcontent facilty to share thing on the socual web have been added.

To see the design and layout of Mashable visit: Masahable

From Quora:
Read Quote of Chris Heald’s answer to Mashable: Is Mashable still using WordPress as the cms/platform ? What are the technologies behind this new look and feel? on Quora

Mashable is now running on a custom technology stack. The public-facing bits are a Ruby on Rails backend, with a lot of the templating work pushed to the front-end with Handlebars and Backbone. We’ll be doing a full writeup on the build in the near future.

http://qr.ae/pWOHf