Developer // Accessing WordPress URL Function Values Within Javascript

During my custom WordPress theme development I often find that it would be really useful if I could just use the WordPress get_template_directory_uri() or home_url() functions from within Javascript.

For example when trying to set the url of an Ajax request in jQuery, or setting the path to an icon image file on a Google Map.

Thankfully, if you’re using WordPress in the way it’s intended, there is a very simple way to make this possible. Continue reading “Developer // Accessing WordPress URL Function Values Within Javascript”

Developer // ACF: Counting Repeater Rows Inside Flexible Content

So I was trying to count the number of repeater rows for a ACF repeater field in my WordPress theme, something which I figured would be a simple use of the count() function on the returned field.

In turns out though, that the following code doesn’t work with a repeater field if it is part of a flexible content block. Continue reading “Developer // ACF: Counting Repeater Rows Inside Flexible Content”

Developer // Adding Categories and Tags Functionality To WordPress Custom Post Types

Had a request from a client to add categories and tags to their resources custom post type in WordPress.

Obviously I assumed there were predefined WP functions to implement this, but I found it hard to pin down a complete solution, so thought I would share mine here. Continue reading “Developer // Adding Categories and Tags Functionality To WordPress Custom Post Types”

Mysql not found by PHP

In the middle of a Drupal install on my localhost I received the following error

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) i…

2AM and in need of a quick fix I just created an alias in the location PHP was looking for mysql.

Replacing accented character with it’s standard character in PHP

When writing a function to save audio files with a user friendly filename , as well as a regex to remove any unwanted spaces and punctuation, I needed to replace any accented characters with their standard format.

e.g If I was saving a Beyoncé album I needed the ‘é’ in her name to be replaced with an ‘e’.

The following works perfectly:

iconv("utf-8","ascii//TRANSLIT",$filename);

Using Zend session with an HTML framset

Trying to incorporate a Zend session on a page being viewed as part of a frameset caused me a headache yesterday.

I couldn’t understand how everytime I refreshed the page to try and test the session it seemed to be reset. Var_dumping the session before and after the data was getting assigned showed that everything was getting stored as expected, but each time the page loaded, the session returned NULL again. Continue reading “Using Zend session with an HTML framset”