Month: February 2008

WordPress : Safari

If you’ve been trying to write posts in the WordPress TinyMCE editor using the Safari web browser, you might have noticed that breaklines are not correctly treated and that your posts end up being a single block of text rather than paragraphs as expected. This is because of a conflict or a bug between Safari and TinyMCE. Whomever is to blame for this is unknown, but a fix or workaround has not been made available by either the webkit developers or the WordPress team itself. So this post will show you how to fix up TinyMCE in order to start writing WordPress posts using Safari. First off, go to "/wp-includes/js/tinymce/" and open up the "tiny_mce.js" file with your text editor. With the file open, go to line #4025 where you will see the following block of code. It is a simple IF statement. if (tinyMCE.isSafari && this.formElement)   this.formElement.innerText = htm; Now comment out those two lines of code inside the "tiny_mce.js" file so that it looks like this : //if (tinyMCE.isSafari && this.formElement) // this.formElement.innerText = htm; And that’s all there is to it. Re-upload the "tiny_mce.js" file to its original directory, overwriting the original file. You can now go to your WordPress "Write" section, but one you have opened this page, remember to clear your browser cache and refresh the page so that the new JS file...

Read More

CakePHP Crontab

Due to the way that CakePHP rewrites URL requests with its router, it might seem confusing to execute a Crontab to run a controller action. I will show you how to set up a cron dispatcher so that you can execute all your different controller action schedules on a single file and pass the controller and action as an argument to the file so that the dispatcher will know which action to fire. First off, you’ll need to create a duplicate of your index.php file inside of /app/webroot/. Once you have duplicated the file, rename it to cron_dispatcher.php and open it up for editing. On line #77 of your cron_dispatcher.php file, you will see the following : if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } The code shown above includes the CakePHP core bootstrap.php file and of course, if the include fails, it triggers an error. So we’ll add an ELSE statement to this code so that we can fire our dispatcher if in fact the boostrap was successfully included. After adding your ELSE statement and the appropriate code to initialize the dispatcher, your code from line #77 should now look...

Read More

PHP : Cannot use a scalar value as an array

I was working on a WordPress plugin today and came across the most disturbing PHP warning error which I have never seen before in all the time that I’ve worked with PHP. The warning error message was : Warning: Cannot use a scalar value as an array What caused this error was when I tried to append an array key, value pair to a variable equal to zero (0). I retrieved the global WordPress variable $errors and attempted to append a key, value pair to the variable, though the variable type was invalid. The type was INT (because it was set to null) and it didn’t make sense to treat it as an array. A solution to this would be to check if the variable is an array. In case it isn’t and it is empty, you can redefine it with the correct variable type. Usually, in PHP, this would not be the case and I cannot explain in detail exactly why this happened, but it had to have something to do with the fact that it was a pre-defined GLOBAL variable. So in my custom function, I did this : function myfunction() { global $errors; if (!is_array($errors)) { $errors = array(); } $errors['field_name'] = __('ERROR: Please fill in a value', $plugin_name); } And that fixed it! The warning error was gone and I am...

Read More

Xampp phpMyAdmin Problem

I started XAMPP today and tried to open phpMyAdmin (http://localhost/phpmyadmin/) in my browser in order to do some database management. Unfortunately I was presented with the following error message : cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly After playing around a bit, managed to figure out that there was a problem with the way PHP sessions are saved. Because of new security measurements in the Mac OS Leopard operating system, there was no way for PHP to save sessions. So I edited the PHP configuration file and uncommented the line which specifies the path where sessions logs are saved. Here comes the solution. This is for Mac OS X. Open up "/Applications/xampp/etc/php.ini" with Textedit or any other text editor for that matter. Search for the phrase "session.save_path" or simply just go immediately to line #839 where this is located. You’ll see : ;session.save_path = /tmp Now uncomment it by making it : session.save_path = /tmp And that’s it! Restart XAMPP by clicking the "Restart" button. You really just need to restart PHP for that matter so that the new configuration values can be loaded. Good...

Read More

Linux : Change file/folder owner

On a Unix based system, all files and folders belong to a group and a owner. Or rather, an owner and a group has specific permissions to read, write and execute files. So you might need to change the owner of certain files and folders so that you’ll be able to open them, edit them and write to them again. I’ll show you how to do this via SSH. You’ll need a login and password in order to access the shell. ssh -lroot Once logged in, change the directory to the one where the files/folders are located. cd /var/www/vhosts/ Then you might want to recursively change the owner for all files and folders inside that directory to another user. Lets set the owner of the files and folders to “peter” chown -R peter * That is all there is to it. You have just changed the owner of all files and folders recursively inside the specified directory to “peter”. You can now open the files (for example via FTP), edit them and write back to them again. Good...

Read More

Stay up to date

Get one email per month with latest news. You can unsubscribe at any time


"; -->

Pin It on Pinterest

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!