Showing posts with label WordPress. Show all posts
Showing posts with label WordPress. Show all posts
Friday, January 06, 2017
Out of gas
The Summer school holidays are traditionally a quiet time at work when, with so many on leave, one can focus on those small personal projects that you never have a chance to do during the rest of the year. You take things a little slower and wind down after the usually hectic period leading up to Christmas.
I am fortunate enough to be able to work from home over the Summer holidays, allowing me to keep an eye on Alex whilst still doing work. The lack of a four hour daily transit to work and the need to worry about school lunches and homework means there are more hours in the day to both work and play.
That's the theory. So why am I so bloody knackered?
After dithering for most of the year a certain fracking (and I use that as an epithet) group demanded that we make their website for them by the end of January. And I am off on holidays for most of January.
I never wanted to do this site. We should be decarbonising, making this research redundant. Plus it's industry funded so they can pay for an external site and developer. It's not like energy companies pay their fair share of taxes.
The only consolation is that at least much of the research is focused on mitigation and preventing damage to the environment from the operations.
But they didn't listen to me. Nor did they employ people with web experience to manage the project. So not only do I have to develop the site, but I also have to handhold the authors. And I and the rest of the team already have a lot of work on my plate.
We have a new graphic designer replacing the one I worked with on last year's fantastic Utopia project. This new guy is perfect for the organisation as he has a tendency to overcomplicate everything. I try to use WordPress' inbuilt functionality and structure as much as possible, allowing users flexibility at the expense of centralised control. Simplicity and flexibility are my mottoes.
It's one reason why our WordPress sites are far more popular for authors than our Sitecore websites.
User flexibility and control is an anathema to corporate operations.
So I'm presented with the need for a large number of templates, custom post types and fields (using Advanced Custom Fields). And there's no time to argue because they've been approved and the graphic designer is off on leave. And our front end developer has only a short time available too.
Naturally a lot of the elements and styles don't fit into WordPress' default generated HTML. So that means things like custom menu walkers and archive pages.
I find I have to do almost no training to get users up to speed with vanilla WordPress but customisation means additional training and the people responsible are on leave.
There's no way I can do everything in time, no time to train a contractor up and get them permissions, so I tell them they'll only have a subset of pages available for the initial launch lose the fancy searches for now.
And I begin working flat out before and after Christmas. I give them some custom page types so the authors can start entering content while I work on listing pages. I solve problems and churn code out. What I did was petty awesome, even if I do say so myself. Not just reusing other people's themes and plugins like some commercial developers do (because my clients are "special needs" so virtually nothing works out of the box).
I'd like to work on this on the evenings and spend time during the day looking after Alex. But no, in come the phone calls. Sometimes every ten minutes or so. Help entering content, changes to be made to templates, the odd bug discovered. One day I counted to ten and was about to open the door on a hiding Alex playing a game of hide and seek when the phone rang. Again.
You see, when a manager or communicator signs off on something it means very little. They want changes. Limitations are unacceptable.
But I want to spend some time with my kid. The year is too busy and he grows up so fast that any time together is precious.
I finally made the site live today. More bugs/changes. Eventually, at 4 pm (and if you think that's skiing off early I'd had 10 minutes off for lunch), when I was supposed to go and pick up Alex from a friend's place another change request came in and I lost it. Privately. My head was so exhausted that I couldn’t cope with any more changes. I told them no. That any further changes ran the risk of further bugs. They apologised, said thank you, and I fixed the last known bug.
Then I found this floating in our swimming pool and fished him out...
Another giant bug fixed!
Labels:
programming,
WordPress
Friday, July 15, 2016
WordPress shortcodes and line breaks.
WordPress automatically adds break tags to new lines. Normally this is useful behaviour but it can prove a major annoyance when combined with shortcodes.
Following user requests I had added a set of column shortcodes to my Utopia theme. The shortcodes are currently just a way of adding a Bootstrap grid to the content, but as we will be replace Bootstrap with an alternative grid system in future this is a way of future proofing the content.
I found a couple of really useful tutorials for adding a columns menu to the TinyMCE visual editor in WordPress:
Bad move! Suddenly my other shortcode output was messed up. So I had to remove those lines.
The solution? Write a custom filter using regular expressions to remove line breaks between the shortcode tags and run it before the normal WordPress line break filters kick in. A regex tester proved very useful here!
I had to use three expressions as there are shortcodes for rows and columns of different widths. Whilst WordPress is supposed to handle breaks between individual shortcodes, the issue here is that we are mixing different shortcodes together and the content between them should have paragraph and line break tags added. The code above only applies to the added shortcodes and seems to work well, so problem solved!
Following user requests I had added a set of column shortcodes to my Utopia theme. The shortcodes are currently just a way of adding a Bootstrap grid to the content, but as we will be replace Bootstrap with an alternative grid system in future this is a way of future proofing the content.
I found a couple of really useful tutorials for adding a columns menu to the TinyMCE visual editor in WordPress:
- https://www.gavick.com/blog/wordpress-tinymce-custom-buttons
- http://www.wpexplorer.com/wordpress-tinymce-tweaks/
All well and good, but when I published the content WordPress added break tags between the div
tags and the columns did not display.
My first solution was to change the order of WordPress' shortcode_unautop and wpautop filters, as per these instructions.
//move wpautop filter to AFTER shortcode is processed
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop',100 );Bad move! Suddenly my other shortcode output was messed up. So I had to remove those lines.
The solution? Write a custom filter using regular expressions to remove line breaks between the shortcode tags and run it before the normal WordPress line break filters kick in. A regex tester proved very useful here!
function utopia_cols_strip_breaks( $content ) {
$content = preg_replace('/(\[utopia_col_row\])([\s]*)(\[utopia_col)/i','$1$3',$content);
$content = preg_replace('/(\[\/utopia_col_)([\_\d]+)(\])([\s]*)(\[utopia_col)/i', '$1$2$3$5', $content);
$content = preg_replace('/(\[\/utopia_col_)([\_\d]+)(\])([\s]*)(\[\/utopia_col_row)/i', '$1$2$3$5', $content);
return $content;
}
add_filter( 'the_content', 'utopia_cols_strip_breaks', 0 );
$content = preg_replace('/(\[utopia_col_row\])([\s]*)(\[utopia_col)/i','$1$3',$content);
$content = preg_replace('/(\[\/utopia_col_)([\_\d]+)(\])([\s]*)(\[utopia_col)/i', '$1$2$3$5', $content);
$content = preg_replace('/(\[\/utopia_col_)([\_\d]+)(\])([\s]*)(\[\/utopia_col_row)/i', '$1$2$3$5', $content);
return $content;
}
add_filter( 'the_content', 'utopia_cols_strip_breaks', 0 );
I had to use three expressions as there are shortcodes for rows and columns of different widths. Whilst WordPress is supposed to handle breaks between individual shortcodes, the issue here is that we are mixing different shortcodes together and the content between them should have paragraph and line break tags added. The code above only applies to the added shortcodes and seems to work well, so problem solved!
Labels:
programming,
WordPress
Monday, February 15, 2016
Reaching Utopia
After many months of work I finally released my first complete WordPress theme Utopia today and I'm pretty proud of it.
Unlike some of my previous attempts which were based on the Underscores starter theme, Utopia was pretty much built from scratch. The theme, which will be used on CSIRO Research websites, is designed to address many of the feature requests and deficiencies of the previous themes we've used on the site and elsewhere.
My colleague Taranii, with some help from Kate, another member of the team, did the design and CSS markup while I was responsible for the PHP coding. It was a remote collaboration due to the distributed nature of our team, but I thought it worked really well, thanks to some of the fantastic tools on offer.
We used Atlassian's Bitbucket, Sourcetree and git for source code management, which made it really easy to deploy on both our Windows development machines and Linux servers. Atlassian's Jira was used for bug tracking, along with Jira Capture for test sessions. Finally, most of our contact was via Cisco Jabber.
The Utopia theme, along with the post grid plugin we developed alongside it, has a number of very cool (to me) features. These include different colour schemes, the ability to use page, post and category feature images in the individual page headers, social media buttons, a local contextual menu, support for different page and post templates and a page and post listing grid with lots of options and the ability to be included as a widget or shortcode.
Another group in our organisation went to an outside specialist WordPress development house to build a theme for their WordPress blog. The result, which took quite a while to complete, was a theme that relied mainly on a somewhat expensive base theme and set of commercial plugins whose licenses are still causing us grief, especially as the users want more features.
So I'm proud that we built our feature rich theme ourselves! We do use some third party plugins, but after I looked at following a similar development path to the blog I realised that it would never satisfy the myriad of little issues and needs that our users always seem to have. At least this way we really understand our code a lot better.
I was up until the early hours finishing off some basic usage documentation and building the new top level site for the release. Exhausting, but very satisfying to finally get it out there to the users.
So, does the name Utopia mean that theme is perfect? Nope, there's plenty left to build in future! In fact it's all about building. Or trying to.
Unlike some of my previous attempts which were based on the Underscores starter theme, Utopia was pretty much built from scratch. The theme, which will be used on CSIRO Research websites, is designed to address many of the feature requests and deficiencies of the previous themes we've used on the site and elsewhere.
My colleague Taranii, with some help from Kate, another member of the team, did the design and CSS markup while I was responsible for the PHP coding. It was a remote collaboration due to the distributed nature of our team, but I thought it worked really well, thanks to some of the fantastic tools on offer.
We used Atlassian's Bitbucket, Sourcetree and git for source code management, which made it really easy to deploy on both our Windows development machines and Linux servers. Atlassian's Jira was used for bug tracking, along with Jira Capture for test sessions. Finally, most of our contact was via Cisco Jabber.
The Utopia theme, along with the post grid plugin we developed alongside it, has a number of very cool (to me) features. These include different colour schemes, the ability to use page, post and category feature images in the individual page headers, social media buttons, a local contextual menu, support for different page and post templates and a page and post listing grid with lots of options and the ability to be included as a widget or shortcode.
Another group in our organisation went to an outside specialist WordPress development house to build a theme for their WordPress blog. The result, which took quite a while to complete, was a theme that relied mainly on a somewhat expensive base theme and set of commercial plugins whose licenses are still causing us grief, especially as the users want more features.
So I'm proud that we built our feature rich theme ourselves! We do use some third party plugins, but after I looked at following a similar development path to the blog I realised that it would never satisfy the myriad of little issues and needs that our users always seem to have. At least this way we really understand our code a lot better.
I was up until the early hours finishing off some basic usage documentation and building the new top level site for the release. Exhausting, but very satisfying to finally get it out there to the users.
So, does the name Utopia mean that theme is perfect? Nope, there's plenty left to build in future! In fact it's all about building. Or trying to.
Labels:
programming,
web,
WordPress
Thursday, December 24, 2015
One hour until Christmas
Better go to bed, don't want Santa to skip our house.
Going to bed before midnight would be nice. So would waking up to a quiet Christmas day spent with just the three of us (and dog). Sadly not. Instead it's a drive up to the Insular Peninsula for a party with one side and back south by the evening for a dinner with the other.
I'm exhausted. I've been pushing to get this super awesome WordPress theme ready for testing before my co-developer, the designer goes on holiday. Finally set up the test sites last night and then wrote up the authoring and admin instructions from about 7 am and sent them out an hour before work closes for the Christmas break.
Then there were all the other support requests.
Alex has been on holiday for a week now so I had to look after him at the same time, meaning a lot of the recent work was done late at night after he slept. Then there was Christmas shopping and preparing dishes for tomorrow.
I'm knackered!
Oh darn, I just remember I have to make another layer of jelly and let it cool before pouring.
Merry Christmas.
Going to bed before midnight would be nice. So would waking up to a quiet Christmas day spent with just the three of us (and dog). Sadly not. Instead it's a drive up to the Insular Peninsula for a party with one side and back south by the evening for a dinner with the other.
I'm exhausted. I've been pushing to get this super awesome WordPress theme ready for testing before my co-developer, the designer goes on holiday. Finally set up the test sites last night and then wrote up the authoring and admin instructions from about 7 am and sent them out an hour before work closes for the Christmas break.
Then there were all the other support requests.
Alex has been on holiday for a week now so I had to look after him at the same time, meaning a lot of the recent work was done late at night after he slept. Then there was Christmas shopping and preparing dishes for tomorrow.
I'm knackered!
Oh darn, I just remember I have to make another layer of jelly and let it cool before pouring.
Merry Christmas.
Labels:
life,
programming,
web,
WordPress
Tuesday, February 26, 2013
Inquire into enquire (Templatic)
WordPress madness yesterday. One of my colleagues purchased a Templatic WordPress theme and discovered that all the strings which should read enquiry were instead inquiry (similarly enquire was inquire). Templatic's support forums are available only to those who have purchased a theme - and Google's cache. To make the changes (and I recommend changing capitalisations as well) you need to edit the language.php file of the theme.
Do not do a simple blanket search and replace, because the constant names need to remain as INQUIRY. Only change the values.
define('SEND_INQUIRY',__('Send enquiry','templatic'));
I'm not sure if these changes will be overwritten if you update the theme.
Do not do a simple blanket search and replace, because the constant names need to remain as INQUIRY. Only change the values.
define('SEND_INQUIRY',__('Send enquiry','templatic'));
I'm not sure if these changes will be overwritten if you update the theme.
Labels:
programming,
WordPress
Subscribe to:
Posts (Atom)
Popular Posts
-
What's that, an even smaller Sony computer than my VAIO P? No! It's my Sony Xperia S mobile phone paired up with a Elecom TK-FBP029 ...
-
One of my dreams has been to take Alex, who is now 2 years and 9 months, to see and hear a symphony orchestra play live and preferably be pl...
-
Today my employer arranged a guest speaker ostensibly to talk about resilience. Actually, what he mainly discussed was thrillsee...


