[column lg=”8″ md=”8″ sm=”12″ xs=”12″ ]
Recently, I needed to create a downloads area that was going to be managed by a client. It’s a reasonably straight forward task, except for one snag: They wanted icons next to the links, denoting what filetype the download was. I could have created a few custom classes to add to the links, but the client is not at all technical, and I wanted to involve as little manual editing as possible.
Instead, I wrote a quick set of CSS selectors that filter the links by their href attributes, and provide the proper icon. I still provided override classes, in case it doesn’t always detect properly, but so far, it seems to be working perfectly.
I’ve included the CSS below. If you want to use it or modify it, feel free to do so. To use, just include FontAwesome in your project, include the css below, and add a “link-icon” to any link you want to display an icon for.
[column lg=”4″ md=”4″ sm=”12″ xs=”12″ ]
(note: the links below are fake, but you can inspect them to see how the icon is selected)
read more »
Buddypress is a great option for running closed social networks in WordPress. However, if it doesn’t perfectly fit your needs out of the box, you’ll soon realize that it has some serious shortcomings.
Consider a text-based company logo. It may have an aspect ratio of 3:1, but a square crop of the image would lose all meaning, and look sloppy. You could tell users to send it to a graphic designer to get a square version created, but that is a great way to lose users. Instead, I tackled the issue programmatically.
If you require the following script in your theme’s functions.php file, it will detect when users upload non-square profile photos, and will add padding to make them square, before displaying the crop interface. That way, if the image must remain complete, it can simply be displayed centered in the square, with padding surrounding it.
Sometimes a script needs to call a function that either uses a large amount of system resources, or that performs external calls to servers or APIs that place limits on requests. Often, however, the data returned by these functions isn’t highly volatile, and can be expected to remain the same for subsequent calls.
In these cases, it is necessary to implement a form of cache, to store the results of running the function once, and use the same results on subsequent calls (clearing the cache regularly, to prevent buildup).
Caching to disk is fairly easy to implement in PHP, but it is nice to have a prebuilt, general purpose solution that can be dropped in to any project.
read more »
This is less of a post, and more of a useful snippet. I’ve seen many posts online about sorting an array of names by surname, and they’ve all failed to be complete. Here is my addition to the pile. Keep in mind that it has known issues with compound last names that contain a space, like “Von Zinger”, “Mac Innis”, or “Di Vece”. However, it is a more robust solution than many others online today.
One of the more complicated things to handle in wordpress is creating a “team” page that is attractive and easy to maintain. Many designers use pre-packaged plugins that remove a level of control, or create these pages as flat pages with complicated custom layouts (sometimes with the assistance of Visual Composer or another complicated shortcode library).
The same issue tends to carry over to other ‘aggregate’ pages like “board of directors” or “testimonials”. However, it’s actually fairly simple to implement these pages as a Custom Post Type, giving content-editors a simple post interface to add and delete team members, and making front-end layout a simple job for a custom template and some css.
read more »