Will Wonka asking you to tell him again what WordPress can't do.

Tweaking the WP Base JSON Data

We had a list of rampages sites in a Google Spreadsheet and wanted to know when they were created. I started to look that up but only managed to do it twice before I gave up and went in search of another way. In this case it took two little bits of code. This first piece is active on our generic site-wide plugin. It adds the blog’s creation date, last updated, and post count to the base JSON data. That’ll be handy in the future if we want to checkup on sites with only one query rather than multiple queries. This second piece is a Google Script that makes a function that I can call in the sheet by typing =getCreationDate(“http://someurl.com/”) The two together answer my immediate problem but the JSON modifications have some long-term value for us and might be useful to someone else.

Will Wonka asking you to tell him again what WordPress can't do.

Hiding Comment Emails

Obscuring emails in WordPress . . . the comments edition. This is likely overkill but given that VCU has concerns about student emails being divulged via group emails we figured it wouldn’t hurt. I don’t want a class requiring commenting on student sites and that resulting in student unintentionally divulging their VCU emails because they’re logged in. You can see more details on email concerns at VCU (and likely other Virginia universities) at the VCU House Bill 1 site. This is going to go into our production code soon but seems to be working fine in development land. If you’re not a super-admin you will no longer see emails in the main comments view. In the quick edit view, I opted to get a little more nuanced. Email addresses without VCU in them will show normally. I figured this might be useful for contacting outside people. VCU has three or four email patterns but all of them have VCU in the address so I opted to just look for VCU in the email string using strpos. If it finds VCU then it spits back a generic sanitized email, sanitized_email@vcu.edu.1 I thought this would make it more obvious that there wasn’t an error but that emails were being cleaned intentionally. And finally, the single comment edit view. Thanks to Jeremy Felt […]

A drawing of a small terrier dog jumping through a hoop held by a monkey.

WordPress Multisite Email Hider

Virginia recently passed some FOIA legislation (and even more legislation) that says essentially that institutions can’t release student emails without written consent. That includes student directories and other fairly traditional things done with student emails. It led us to look at our WordPress multisite install.1 While a VCU email address is required to sign up for rampages.us, the username can be whatever the person desires. Emails aren’t visible in the user directory. The one place we thought emails would be visible in way that might be unexpected was in the user view of individual sites. If a student is an admin, they’d be able to see the emails of other student users on that site. The following bit of code removes the email column from the users view for everyone that isn’t a super admin. If we see an uproar from teachers about the missing column, we can also add people by user ID by doing something like . . . 2 $ok_people = [1,2,4]; if ( is_array( $super_admins ) && in_array( $current_user->user_login, $super_admins ) || in_array($current_user->ID, $ok_people) ){ [\php] 1 Overkill? Happy to oblige. 2 I didn’t test this yet so …

22

Gravity Forms Rich Text Editor Grayed Out Fix

This isn’t clean and I have no idea why this is behaving this way but . . . this is a way around it. Sometimes Gravity Forms won’t let me choose the “Use the Rich Text Editor” option but I really, really want to choose that option. It’s grayed out as you can see below. In Chrome, I click “inspect element” on the grayed out checkbox and I can then see in the HTML that the word “disabled” is just sitting right there taunting me. What’s nice is I have the power to destroy that word. If I click on it and erase it things become good again and the checkbox is now available. And victory! I haven’t seen any ill effects for doing this and I’m not sure why it’s happening but this a way around it.

18

WordPress Dev Environment URL Helper

Tim moves our rampages database to our dev server roughly every month. Our database is big and awkward and uses Multi DB to deal with the scale. Because of the multiple databases some of the typical migration patterns to get the URLs right don’t work. We were suffering through that for a while but I’d find myself ported from the dev environment to the live site at times without realizing that’s what happened. That is not a fun way to live. Because Jeff was working on a really smart way to do this in the database I realized I didn’t know more than I thought I didn’t know. As a result I stumbled upon the ability to filter the site url and home options. That means we can make a tiny little network activated plugin that leaves our database alone and just filters things on the fly with a dab of regex.

13

Tweets as Presentation: Reflecting on #pressedconf18

I took the opportunity to participate in the #PressedConf yesterday. Described as “. . . a twitter conference (#pressedconf18) looking into how WordPress is used in teaching, pedagogy and research.” it was a pretty impressive number of people and topics covered on Twitter in roughly 20 minute “Tweet storms.”1 Presenting on Twitter was something new to me and I tried to think through some interesting ways to approach things. Given how limited Twitter was I tried to tackle complexity in a few different ways while taking advantage of the way Twitter treats different content integrations. The Post I ended up deciding to build out a WordPress post with various sections that were associated with a number of the Tweets I’d make. I used good ol’ anchor links in the Tweets to be able to link specifically to those sections without having to resort lots of little posts. For example – brings you to the Custom Composition section directly. Not very visual on the Twitter end and probably cheating in the scheme of things. The Videos I tried to tackle other complexity through videos. I made a number of new videos and took advantage of a few others I’d had to try to show more details. I kind of wonder if this worked well. They appeared in two different ways. Some […]

Will Wonka asking you to tell him again what WordPress can't do.

Form Follows Function – WordPress Authoring

This is my supporting documentation for the #PressEd WordPress conference that I’ll be doing via Twitter on Thursday. The Topic Given I’ve been playing around in WordPress since what feels like the dawn of time, I’ve heard lots of people say lots of things about it. I’ve heard it’s too complex. I’ve heard it’s too easy. I’ve been told it won’t allow you to map/GIS information and that it can’t be used for any number of other things. I’ve been told it won’t do things that you can do in this other CMS or that other LMS. As with most things, these boundaries are mostly imaginary and live more in people’s heads than they do in the software itself. My goal here will be to take you on a tour of what you can do to impact the authoring experience in WordPress. We’ll start by removing complexity from WordPress itself but staying within the typical authoring patterns. We’ll do that in the easiest ways first and then move to more involved interventions. After that, we’ll jump to non-standard authoring patterns and run around seeing where the edges are. Minimalism/Reducing Complexity Screen Options There’s quite a bit of control you have just within the Screen Options settings available to the author. If you can check/uncheck a box these options are available […]

H5P embed advanced options showing the dynamic sizing script option.

H5P Default Dynamic Sizing

If you’re running the H5P plugin in WordPress, you might notice that there’s an advanced settings option when you go to embed it. If you click on that you’ll see an additional script to add to enable dynamic sizing of embedded H5P content. I wanted that but that option doesn’t make much sense in our environment. If you read this blog a lot and have an amazing memory, you’ll know I have a plugin that’s network activated where I put little things that make sense but don’t need their own dedicated plugin. This seemed like one that fits that bill. It’s really simple. It asks if the site is running H5P and if the answer is yes, it enqueues the h5p-resizer.js.

Four people wandering up a large sand dune with a blue sky and some clouds.

WordPress Avoid Running save_post Functions on Trashed Posts

This may be one of those things that everyone knows but it was new to me. I’m also duplicating the information I found in the StackOverflow post because I think it’s good to have information in multiple places where it might be found by other people. Additionally, writing the post makes it easy for me to find later when I forget and the act of writing the post helps get it stuck in my own head. With all of that as the lead up . . . A common way to trigger events in WordPress is the save_post action. It runs any time the post is created, published, or updated. What I found out though was that it also runs when you try to delete the post. That makes sense. It is an update and it’s no big deal if the function is relatively small and/or if you’re not trying to get rid of a ton of posts. My current experiment had both a fairly involved function and a couple hundred posts I wanted deleted. Luckily, I found this post on StackOverflow. Now I can set a simple check at the beginning of the function that looks to make sure it’s the right post type (site) and it’s a trashed post. In either of those cases the function gets skipped.