Add Terms and Conditions to Restrict Content Pro

TL;DR – I wrote a WordPress plugin to add Terms and Conditions to the registration form when using the Restrict Content Pro plugin .

I just recently built a WordPress membership site using the Restrict Content Pro plugin and a few add-ons. However since they were taking money (via Stripe) in the registration process the user wanted a terms and conditions checkbox to ensure the customer knew what they were getting with the membership.

I figured this might come in handy so I built and released a plugin for it.

Upon installation and activation, you will see a new submenu item under “Restrict” called “Terms”.

RCP - Terms and Conditions

Under “Terms” you will see a simple admin settings page that allows you to set the label for the Terms and Conditions checkbox that shows up on the registration form as well as the link to your terms and conditions (whether that’s a page on your site or a PDF on a CDN).

RCP Terms Settings

The code and idea for the plugin is loosely based on this blog post Add a Agree to Our Terms of Use Field to Restrict Content Pro from @pippinsplugins.

Plugin code on Github: Restrict Content Pro Terms and Conditions

Install via WordPress Plugin repo: Restrict Content Pro – Terms and Conditions

Using WordPressSharp To Publish A Post

This is a brief intro to using WordPressSharp to publish a post with C# via the WordPress XML-RPC API.

A few notes… the ‘PostType’ property of the Post class can be set to either “post” or “page” depending on which WordPress type you want to publish. And the ‘Status’ property can be set to either “publish” or “draft” depending on whether you want to publish your new post/page right away or not. In the future I’d like to make these enums or something extendable. But WordPress has them as strings so you can define new ones (ie Custom Post Types) on your own.

Keep in mind this class is merely a simple example. In most cases you might want this in a service layer where you can inject the WordPressSiteConfig class as you need it.

Des Moines WordPress User Group

If you are in Central Iowa and love WordPress – please let me know if you’d like to attend a monthly user group. I am currently organizing an early 2015 launch – gathering interest and getting some direction from other user group organizers.

Get more information and let me know you are interested

Featured Image via Heisenberg Media

WordPress Plugin: Open Files In New Tab or Window

On a recent WordPress project I had a requirement that any files be opened in a new tab or window. Now this can be easily accomplished by the users when they create the post or page by linking to the file and marking the checkbox “Open Link In A New Window/Tab”. But we all know users can’t be trusted so in order to “double check” them I wrote a WordPress plugin that will hunt the page for anchor tags that link to something with a file extension, and simply add “target=’_blank'” to them.

Basically all the plugin does is enqueue a jQuery script that does the work. I got the idea to use the jQuery .filter() method from @nickf and the regular expression (because I suck at them) from @már-Örlygsson.

jQuery Open Files In New Tab Or Window

Links and References

Fork On Github

WordPress Plugin Page

jQuery Script

Stackoverflow: Javascript regex for matching/extracting file extension

Stackoverflow: jQuery Selector Regular Expressions

Easy KnockoutJS Pagination with Data Tables

Data Tables makes it super easy to add pagination, searching, and sorting to tabular data bound with KnockoutJS

TL;DR: DataTables provides simple pagination, sorting, and searching capabilties to tabular data bound with KnockoutJS – DEMO

So I was working on a WordPress plugin that pulled data from a SQL Server database via ASP.Net Web API and was using KnockoutJS to make the binding super easy. This worked great and was surprisingly simple to accomplish. However some of the data that was coming back was over 1,000 rows. This obviously didn’t look great to the users and was not really practical nor usable.

So I started down the path of handling paging at the API level and passing the page as a parameter… Yada Yada Yada you’ve been there.

But then I found DataTables … an excellent table plugin for jQuery.

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, and will add advanced interaction controls to any HTML table.

Hey I need that!

DataTables provides extremely simple pagination, searching, sorting and more functionality to any HTML table. So in order to get this to work you can use the declarative foreach feature of Knockout to build out your table with the JSON data coming back from your API.

Enough of the boring stuff, here’s the code.. And here’s the demo in action using JSON data from the Donor’s Choose API.