This plugin will add the ability to choose different Creative Commons licensing structures for different posts that you publish to your WordPress blog.
As far as i could tell, there are currently 2 other CC plugins for WordPress – wpLicense and cc-configurator – however both of them only let you set your license on a global level. That is, they let you pick one license for all your posts and pages throughout your entire site. I thought it might be useful if each WP user/author could choose between different CC licenses and be able to set them on a post-by-post basis. So, i modified the wpLicense plugin to do just that.
“The main purpose of this plugin is to give WP admins who run sites with multiple users/authors the option let these users/authors set specific CC licensing terms on a post by post basis.”
How it works:
It uses the CC api and the JsWidget to add a new section to the write/edit post page and then displays a small CC graphic/button and text on your published posts for all to see. The widget lets you choose the appropriate licensing structure and then your choice is automatically saved to a custom field the next time you click “Save and Continue Editing”, “Save”, or “Publish”. Then, it uses the CC api (details-license-uri-uri) to call some javascript that displays a small graphic/button and some text linking back to the definitions for the license you have chosen. Jquery was used to insert the new CC license section to the write/edit post pages as well as to open/close the new section. I also had to use Jquery to fix the tooltips for the JsWidget. Lastly, this plugin is optimized so that it will add only 1 DB query (the cc_js_result_uri) to each post that has set a CC license and stores it to a custom field for that given post – whereas the wpLicense plugin seemed to use 3 seperate db queries to set the global licencing for the site.
Screenshots:
Check out the plugin in action.
Image may be NSFW.
Clik here to view.Image may be NSFW.
Clik here to view.
Download:
Click on the following link to download the plugin: per-post-license_v.02.zip
Requirements:
1. This plugin has been testing and works on WP 2.3.x using the default theme (but it is still a work in progess / comments and suggestions are welcome).
2. Your web server needs either curl (most have it installed and it’s the default setting used in this plugin) or URL file-access enabled (to be able to run file_get_contents() instead of curl).
Install:
1. Unzip and Copy the per-post-license folder to your plugins directiory and activate it.
2. Add the template function (see next paragraph) to where you’d like the CC image/button and text to appear on your post (this might be the single.php or footer.php template file).
3. Go to the Write post page or Edit an existing post.
4. Look for the new section marked “CC License” and click the small “plus” sign to open the section.
5. Select “A Creative Commons license” and choose the appropriate licensing structure.
6. Save the post and You’re Done!
WP Template Function:
Add the following function to the WP template file (like single.php, or footer.php) to get the CC license to appear on your post.
< ?php if(function_exists('cc_insert_html')) { cc_insert_html($display=true); } /* get cc code */ ?>
Template Options:
Right now, there are only 2 options that you can use with the cc_insert_html() template function.
1. The first is the $display variable. [$display=true ---> will show the CC license , $display=false will not]
2. The second is the $use_curl variable [default is set to --> $use_curl=true , if you explicitly set $use_curl=false the plugin will revert to the php function file_get_contents() which is not always enabled on all web servers]
CSS styles:
Here is a sample style you can use to center, add padding and margins, as well as a horizontal dashed separator (you can ofcourse use any style you like). You would add this code to your style.css file in your template directory.
#cc_code { text-align:center; font-size:11px; width:450px; margin-top:25px; padding-top:25px; border-top:1px dashed #ccc; }
You could also just use inline css and replace the < div id="cc_code" > and add these styles directly – something like < div style="text-align:center; font-size:11px;" >.
To Do:
- get rss/atom feeds showing CC license
- possibly add CC to header (if appropriate)
- option to set per author licensing (for all an author’s posts)
- option to set global default license for entire site
- option to turn off graphic/button and just show text
- option to choose/add an existing licensing structure (other than CC) by providing a URL
- create another template function to gather and list all posts with CC licensing (by title)