I wanted a way to ad a Creative Commons notice at the bottom of each post and I wanted the plugin to be able to pick what license was used based on the post authors preference. That lead me, over the last few days, to create the Creative Commons Post plugin.
You can see an example of it at the bottom of this post (above the comments).
Basic Use -
When creating a post, create one of the following post meta data keys and set it with a value of one (1)(1) -
| Post Meta Data Key | Resulting License Displayed |
| cc_by | Creative Commons 3.0 Attribution Only (Commercial Use and Derivatives Allowed) license. |
| cc_by_nd | Creative Commons 3.0 Attribution, No Derivatives (Commercial Use Allowed) license. |
| cc_by_sa | Creative Commons 3.0 Attribution, Share Alike (Commercial Use Allowed) license. |
| cc_by_nc | Creative Commons 3.0 Attribution, Non-Commercial license. |
| cc_by_nc_sa | Creative Commons 3.0 Attribution, Non-Commercial, Share Alike license. |
| cc_by_nc_nd | Creative Commons 3.0 Attribution, Non-Commercial, No Derivatives license. |
| cc_public | Creative Commons Public Domain License. |
| cc_copyright | Inserts a full copyright notice. |
Not setting any of the above values will insert a default license for Creative Commons 3.0 Attribution, Non-Commercial, Share Alike (BY-NC-SA) license in the post. This can easily be changed to not display any license unless a value it set.
Notice: When setting one of the values above, SET ONLY ONE. Do not set multiple values for one post as it will screw up the system.
I had very specific needs when I created this plugin. As a result, there are no graphic elements present when the CC License is displayed on a post page.
This plugin works with WordPress 2.5.1 and should work with 2.3+.
To Do:
- Add an options page for the plugin.
- Tidy up / Streamline the code.
- Other minor tweaks.
I want to thank Alexander Dichev for his Add Me Dichev plugin that I used as the framework for this plugin.
-
< ?php
-
/*
-
Plugin Name: Creative Commons Post plugin
-
Version: 0.1
-
Plugin URI:Description: Wired Pigs Creative Commons plugin ads a user defined <a href="http://creativecommons.com">Creative Commons notice at the bottom of each post. The plugin was adapted from </a><a href="http://dichev.com/blog/webdesign/wordpress_social_bookmarks_buttons_plugin_howto/">Add Me Dichev</a> by Alexander Dichev. See plugin code for documentation.Author: Glenn HowellAuthor URI:Use:When creating a post, create one of the following post meta data keys and set it with a value of one (1) -cc_by for a Creative Commons 3.0 Attribution Only (Commercial Use and Derivatives Allowed) license.cc_by_nd for a Creative Commons 3.0 Attribution, No Derivatives (Commercial Use Allowed) license.cc_by_sa for a Creative Commons 3.0 Attribution, Share Alike (Commercial Use Allowed) license.cc_by_nc for a Creative Commons 3.0 Attribution, Non-Commercial license.cc_by_nc_sa for a Creative Commons 3.0 Attribution, Non-Commercial, Share Alike license.cc_by_nc_nd for a Creative Commons 3.0 Attribution, Non-Commercial, No Derivatives license.cc_public for a Creative Commons Public Domain Licensecc_copyright This inserts a full copyright notice.Not setting any of the above values will insert a default license for Creative Commons 3.0 Attribution, Non-Commercial, Share Alike (BY-NC-SA) license in the post.Notice: When setting one of the values above, SET ONLY ONE. Do not set multiple values for one post as it will screw up the system.I had very specific needs when I created this plugin. As a result, there are no graphic elements present when the CC License is displayed on a post page.***Copyright 2008 Wired Pig (email : wiredpig@gmail.com)This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA****/function cc_license_wp($content) {// Helloglobal $post;// CC BY-NC-SA 3.0 Licenses (Attribution, Non-Commercial, Share Alike) ** DEFAULT **$my_cc1 = ‘This <span>work</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License</a>.’;// CC BY-NC-ND 3.0 Licenses (Attribution, Non-Commercial, No Derivatives)$my_cc2 = ‘This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License</a>.’;// CC BY 3.0 Licenses (Attribution, Commercial Okay, Derivatives Okay)$my_cc3 = ‘This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons Attribution 3.0 United States License</a>.’;// CC BY 3.0 Licenses (Attribution, No Derivatives)$my_cc4 = ‘This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nd/3.0/us/">Creative Commons Attribution-No Derivative Works 3.0 United States License</a>.’;// CC BY 3.0 Licenses (Attribution, Non-Commercial)$my_cc5 = ‘This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/us/">Creative Commons Attribution-Noncommercial 3.0 United States License</a>.’;// CC BY 3.0 Licenses (Attribution, Non-Commercial, No Derivatives)$my_cc6 = ‘This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative Commons Attribution-Noncommercial 3.0 United States License</a>.’;// CC BY 3.0 Licenses (Attribution, Share Alike)$my_cc7 = ‘This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons Attribution-Noncommercial 3.0 United States License</a>.’;// DIV-width in percents or pixels (Example: "90%" or "450px")$my_width = ‘100%’;// Alignment of the buttons ("left", "right" or "center")$my_align = ‘center’;// Location of the folder with the icons of the buttons ** NOT USED **$my_images_folder = get_settings(‘home’) . ‘/wp-content/plugins/cc_license_wp/images/’;// We take the post details in the following variables$my_link = get_permalink($post->ID);$my_title = get_the_title($post->ID);// Do Not Edit Below This Line// Functions To Call Specific Notices Based On Post Meta Data// Sets the notice for: Creative Commons 3.0 Attribution, Non-Commercial, No Derivativesif ( get_post_meta($post->ID, ‘cc_by_nc_sa’, true) ) {if ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY-NC-ND –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc2 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_by’, true) ) {// Sets the notice for: Creative Commons 3.0 Attribution Only (Not for Commercial or Derivation)if ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc3 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_by_nd’, true) ) {// Sets the notice for: Creative Commons 3.0 Attribution, No Derivatives (Commercial Use Allowed)if ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY-ND –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc4 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_by_nc’, true) ) {// Sets the notice for: Creative Commons 3.0 Attribution, Non-Commercialif ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY-NC –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc5 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_by_nc_nd’, true) ) {// Sets the notice for: Creative Commons 3.0 Attribution, Non-Commercial, No Derivativesif ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY-NC-ND –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc6 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_by_sa’, true) ) {// Sets the notice for: Creative Commons 3.0 Attribution, Non-Commercial, No Derivativesif ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY-SA –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc7 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_public’, true) ) {// Sets the notice for: Creative Commons Public Domainif ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-PD –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". ‘This work is licensed under the <a href="http://creativecommons.org/licenses/publicdomain/">Creative Commons Public Domain</a>.’ . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}elseif ( get_post_meta($post->ID, ‘cc_copyright’, true) ) {// Sets the notice for: Full Copyrightif ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-CO –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". ‘This work is Copyrighted and may not be used without the express permission of the copyright holder.’ . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}else {// Sets the default notice for: Creative Commons 3.0 Attribution, Non-Commercial, Share Alikeif ( !is_feed() && !is_page() ) {$content .= "\n\n" . ‘<!– Begin Wired Pigs Creative Commons plugin CC-BY-NC-SA –>’ . "\n". ‘<!– blog.wiredpig.us/copyright –>’ . "\n". ‘<div style="padding: 16px 0pt;">’ . "\n". $my_cc1 . "\n". ‘</div>‘ . "\n". ‘<!– End Wired Pigs Creative Commons plugin –>’ . "\n\n";}return $content;}}add_filter(‘the_content’, ‘cc_license_wp’, 1097);?>
Footnotes:
Footnotes are for reference only and may have little, if anything to do with the text from the post.
- Or any value. What the meta data key is set to is not important. Just that the key is present. [↩]
Exciting, huh?Popularity: unranked [?]
































