Auto post to Pinterest from WordPress

Posted by & filed under Coding, WordPress.

A few months ago I needed a way to cross post from a WordPress blog to a Pinterest board. Yes, there are plugins that claim to do this. But the few free ones that I tried never actually posted, and I didn’t want to spend money on a paid plugin that might not work. So… Read more »

Regex for Twitter username

Posted by & filed under Coding.

Working on a small weekend project I needed an easy way to validate that a string contained a valid Twitter username. Not necessarily an active account, but that could be an account. Found the rules on Twitter’s site that a username can be between 1 and 15 characters and can contain only the characters A-Z,… Read more »

Check if a string exists in Moodle

Posted by & filed under Code Tips.

For a Moodle plugin I’m writing I needed a way to check if a String exists. Normally, if a string doesn’t exist then Moodle just outputs [[missing_string]] (replace missing_string with whatever you’re calling the string) and moves on. But, in developer or debug mode it also displays a stack trace. What I needed was a… Read more »

Sort get_users by last name

Posted by & filed under Code Tips.

Not sure why, but it looks like sorting on last name and first name is not built into the WordPress get_users method. Seems like it would be a pretty basic need, but it’s not there. So, it’s on to PHP to make it happen. This bit of code assumes that $user_list has already been filled… Read more »

One line preg_match for PHP

Posted by & filed under Code Tips.

For a project I’ve been working on I needed to use preg_match quite a bit. But I got really tired of having to punch in several lines, so I cooked up this little snippet to pull out a specific match group. $pattern and $search work just like normal preg_match. The $group parameter tells it which… Read more »

Redirect after WordPress comment

Posted by & filed under Code Tips.

Quick little snippet to redirect your visitors to another page after they leave a comment. Normally after leaving a comment in WordPress you’re sent back to the page where you left the comment. By using the comment_post_redirect filter you’ll be able to control where they go. As it’s written, this code will redirect back to… Read more »

Blocking WordPress comments

Posted by & filed under Code Tips.

For a site I’m working on I needed a way to intercept a comment and block if a specific condition wasn’t met. This is what I wound up with. This hooks into the preprocess_comment filter which normally lets you edit comment data before it’s submitted to the database. In this case we’re not doing anything… Read more »

XAMPP Slow on Windows 10

Posted by & filed under Programming.

Is XAMPP slow? I’ve used XAMPP for pretty much as long as I’ve been doing web development. It makes it trivial to get Apache, MySQL, and PHP set up.Since upgrading from Windows 7 to Windows 10 though I’ve noticed it was running much slower. I just assumed that XAMPP is slow. There was also an… Read more »

Fading an image with PHP, GD, and Jaguar

Posted by & filed under Coding.

For a project that I’m working on I needed a way to fade out an image before overlaying text on to it. Text I’ve done. That’s not an issue. But I haven’t ever done anything with PHP with fading out an image. Turns out there’s a library called Jaguar that makes it, and other image… Read more »