[cc-commits] [SCM] Integrates CC licensing into media manager and posts (branch nkinkade) updated. 0.5-29-g8a6efb3
git version control
git at a7.creativecommons.org
Wed Jul 14 18:32:01 EDT 2010
The branch, nkinkade has been updated
via 8a6efb39ebeb27ff0451fd5b03022ffe92f26922 (commit)
via de765802d982a76d944d6d3b7388b7890bb92d1d (commit)
via a445af7d1d7dd49c98d0a85039f0d6e2ff52ce3d (commit)
via e25f7cf7244fcdcbbb63ace63f8114ab8c8bd447 (commit)
via ca8ee9e5f013157267276ed1fc31c881010b199d (commit)
via 0569e1b878d03bdff618c5e0b30fdddba4607f30 (commit)
via ed51247874905f341ec1a56fee082a1398c8aae8 (commit)
via 6e5637d055d4729212aa60724ce5e9a8ac5695e1 (commit)
via c028d68e168d89adbbf0ddae72e350c35d6e3d59 (commit)
via 59713115d271d5c61e913ba629616c694b080519 (commit)
via c849961147c44ed81e74905eb59075e37c929c78 (commit)
via 23f3054ab0a03b2a44f181a7d8c620af8f13e7d6 (commit)
via 06a4526045b87d090e3bd8069762ff999f1eb51f (commit)
via bb7a155951ae8acb1bea5deb60c5c8d4b4df653e (commit)
via 410ae78d09f2dc971e5f2431a53a10a649fa9e4d (commit)
via 3d0491092c79bb8236f16bb04c3e906cb7dc17d5 (commit)
via a7e5d76482a7bfb7c2b4278ce16103186d6e456d (commit)
via b4efaa12d37d4ad7510e80b1d95b7663d77068dc (commit)
via ce821ec688b27e515050d2a82a6d54cc36856096 (commit)
via 03fc35bb23d859c4431c3bcc27429ceaa7bcf930 (commit)
via 3be028e9ad9555bee06411576bb546e9dd6c3d88 (commit)
via 1b959b6d4fd4d1b9ad854027d0fc0bfadee28147 (commit)
via 8e92c21a76f2294990edd2fc74ab02c4a3de8e8a (commit)
via 240914e95f3a1ce92f6d6598542ef8e6eff4d2ce (commit)
via ea7e95854284a6eac52974ff122fbecb3e05c8f2 (commit)
via dbad622d3cd6a1ff322e8fb78bfe04ef4ff60c20 (commit)
via ffdb75fe36a2baf322a3442012f5c72aaed3b292 (commit)
via 88f55f4cee819792a3a57828dd4753733c8f5b85 (commit)
from 9b8115249948dfae2bf673c5b444dd24065e3cf4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8a6efb39ebeb27ff0451fd5b03022ffe92f26922
Author: Nathan Kinkade <nkinkade at creativecommons.org>
Date: Wed Jul 14 18:31:33 2010 -0400
Use clean loops where possible. Code is smaller and easier to read.
-----------------------------------------------------------------------
Summary of changes (followed by patch):
icons/80x15/by-nc-nd.crushed.png | Bin 0 -> 343 bytes
icons/80x15/by-nc-nd.png | Bin 0 -> 688 bytes
icons/80x15/by-nc-sa.crushed.png | Bin 0 -> 354 bytes
icons/80x15/by-nc-sa.png | Bin 0 -> 697 bytes
icons/80x15/by-nc.crushed.png | Bin 0 -> 336 bytes
icons/80x15/by-nc.png | Bin 0 -> 672 bytes
icons/80x15/by-nd.crushed.png | Bin 0 -> 335 bytes
icons/80x15/by-nd.png | Bin 0 -> 665 bytes
icons/80x15/by-sa.crushed.png | Bin 0 -> 335 bytes
icons/80x15/by-sa.png | Bin 0 -> 672 bytes
icons/80x15/by.crushed.png | Bin 0 -> 314 bytes
icons/80x15/by.png | Bin 0 -> 640 bytes
tests/test-rdfa.xhtml | 1 +
wordpress-cc-plugin/css-preview/grau-icon.png | Bin 0 -> 15457 bytes
wordpress-cc-plugin/css/grau-icon.css | 59 ++++++
wordpress-cc-plugin/css/spreeblick.css | 6 +-
wordpress-cc-plugin/css/wetter.css | 3 +
wordpress-cc-plugin/wordpress-cc-plugin.php | 251 +++++++++++++++++--------
18 files changed, 242 insertions(+), 78 deletions(-)
create mode 100644 icons/80x15/by-nc-nd.crushed.png
create mode 100644 icons/80x15/by-nc-nd.png
create mode 100644 icons/80x15/by-nc-sa.crushed.png
create mode 100644 icons/80x15/by-nc-sa.png
create mode 100644 icons/80x15/by-nc.crushed.png
create mode 100644 icons/80x15/by-nc.png
create mode 100644 icons/80x15/by-nd.crushed.png
create mode 100644 icons/80x15/by-nd.png
create mode 100644 icons/80x15/by-sa.crushed.png
create mode 100644 icons/80x15/by-sa.png
create mode 100644 icons/80x15/by.crushed.png
create mode 100644 icons/80x15/by.png
create mode 100644 wordpress-cc-plugin/css-preview/grau-icon.png
create mode 100644 wordpress-cc-plugin/css/grau-icon.css
diff --git a/icons/80x15/by-nc-nd.crushed.png b/icons/80x15/by-nc-nd.crushed.png
new file mode 100644
index 0000000..73e65b0
Binary files /dev/null and b/icons/80x15/by-nc-nd.crushed.png differ
diff --git a/icons/80x15/by-nc-nd.png b/icons/80x15/by-nc-nd.png
new file mode 100644
index 0000000..072f8cd
Binary files /dev/null and b/icons/80x15/by-nc-nd.png differ
diff --git a/icons/80x15/by-nc-sa.crushed.png b/icons/80x15/by-nc-sa.crushed.png
new file mode 100644
index 0000000..3167260
Binary files /dev/null and b/icons/80x15/by-nc-sa.crushed.png differ
diff --git a/icons/80x15/by-nc-sa.png b/icons/80x15/by-nc-sa.png
new file mode 100644
index 0000000..ed028fe
Binary files /dev/null and b/icons/80x15/by-nc-sa.png differ
diff --git a/icons/80x15/by-nc.crushed.png b/icons/80x15/by-nc.crushed.png
new file mode 100644
index 0000000..d6944b3
Binary files /dev/null and b/icons/80x15/by-nc.crushed.png differ
diff --git a/icons/80x15/by-nc.png b/icons/80x15/by-nc.png
new file mode 100644
index 0000000..54ebdfb
Binary files /dev/null and b/icons/80x15/by-nc.png differ
diff --git a/icons/80x15/by-nd.crushed.png b/icons/80x15/by-nd.crushed.png
new file mode 100644
index 0000000..37949b4
Binary files /dev/null and b/icons/80x15/by-nd.crushed.png differ
diff --git a/icons/80x15/by-nd.png b/icons/80x15/by-nd.png
new file mode 100644
index 0000000..35eca20
Binary files /dev/null and b/icons/80x15/by-nd.png differ
diff --git a/icons/80x15/by-sa.crushed.png b/icons/80x15/by-sa.crushed.png
new file mode 100644
index 0000000..2472d59
Binary files /dev/null and b/icons/80x15/by-sa.crushed.png differ
diff --git a/icons/80x15/by-sa.png b/icons/80x15/by-sa.png
new file mode 100644
index 0000000..c67509f
Binary files /dev/null and b/icons/80x15/by-sa.png differ
diff --git a/icons/80x15/by.crushed.png b/icons/80x15/by.crushed.png
new file mode 100644
index 0000000..5a57aaf
Binary files /dev/null and b/icons/80x15/by.crushed.png differ
diff --git a/icons/80x15/by.png b/icons/80x15/by.png
new file mode 100644
index 0000000..ecd2abc
Binary files /dev/null and b/icons/80x15/by.png differ
diff --git a/tests/test-rdfa.xhtml b/tests/test-rdfa.xhtml
index 2f9bc56..e960f7f 100644
--- a/tests/test-rdfa.xhtml
+++ b/tests/test-rdfa.xhtml
@@ -7,6 +7,7 @@
<title>Creative Commons Markup Test File</title>
<link rel="alternate stylesheet" href="../wordpress-cc-plugin/css/grau.css" title="grau" type="text/css"/>
+ <link rel="alternate stylesheet" href="../wordpress-cc-plugin/css/grau-icon.css" title="grau (with icon)" type="text/css"/>
<link rel="alternate stylesheet" href="../wordpress-cc-plugin/css/spreeblick.css" title="spreeblick" type="text/css"/>
<link rel="alternate stylesheet" href="../wordpress-cc-plugin/css/wetter.css" title="wetter" type="text/css"/>
diff --git a/wordpress-cc-plugin/css-preview/grau-icon.png b/wordpress-cc-plugin/css-preview/grau-icon.png
new file mode 100644
index 0000000..d5ad201
Binary files /dev/null and b/wordpress-cc-plugin/css-preview/grau-icon.png differ
diff --git a/wordpress-cc-plugin/css/grau-icon.css b/wordpress-cc-plugin/css/grau-icon.css
new file mode 100644
index 0000000..630b289
--- /dev/null
+++ b/wordpress-cc-plugin/css/grau-icon.css
@@ -0,0 +1,59 @@
+figure[about] {
+ border: 1px solid #888a85;
+ background: #eeeeec;
+ overflow-x: hidden;
+ padding: 11px;
+ text-align: center;
+}
+
+figure[about],
+figure[about] > figcaption {
+ display: block;
+}
+
+figure[about] > figcaption {
+ margin: 0.25em auto 0 auto;
+}
+
+figure[about] > img,
+figure[about] > audio,
+figure[about] > video {
+ border: 1px solid #888A85;
+}
+
+ figure[about] > figcaption small * {
+ background-position: left center;
+ background-repeat: no-repeat;
+ border: none !important;
+ color: transparent !important;
+ display: inline-block;
+ height: 15px;
+ width: 80px;
+ overflow: hidden;
+ text-shadow: none !important;
+ vertical-align: text-bottom;
+ }
+
+ figure[about] > figcaption small a[href*="by"] {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAAAAABWohdTAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADMSURBVDjLY2CgOvhPVQAycD0IZDJ0QIVc+GasX3+Wh0zXwQycwdcBt8RFbf36fQ0UGmitiHD1GYbY9etPe1NmIG/H/zNKDC7vXBiUzvx3MQL6uR8avlBFJBrYwLD7v1Lo//JywXczV/0v5wX6+ShUHoz+k+rCEoYz70CxEmoM8nM53/r1207CXUi8+zBc6JIm+K58JoYLyTAQFIarBBnSgGFofPe/sy5KGJJloJUClWN5Bk873EAnZSqkQ2C0tEHNc5SkNKdQOy9TGQAAtpJj4J+LbDEAAAAASUVORK5CYII=");
+ }
+
+ figure[about] > figcaption small a[href*="by-nc"] {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAAAAABWohdTAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADiSURBVDjLY2CgOvhPVQAycD0IZDJ0QIVc+GasX3+Wh0zXwQycwdcBt8RFbf36fQ0UGmitiHD1GYbY9etPe1NmIG/H/zNKDC7vXBiUzvx3MQL6uR8avlBFSOpBwoQMbGDY/V8p9H95ueC7mav+l/MC/XwUKg9G/+ERCOX9J2BgCcOZd6BYCTUG+bmcb/36bSfhLoQqgxn2H6dpmC50SRN8Vz4Tw4UIEyDeJcKFoDBcJciQBgxD47v/nXVRwhDVQOLCcL2VApVjeQZPO9xAJ2UqpENgtLRBzXOUpDSnUDsvUxkAAPl+fMch56rjAAAAAElFTkSuQmCC");
+ }
+
+ figure[about] > figcaption small a[href*="by-nd"] {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAAAAABWohdTAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADhSURBVDjLY2CgOvhPVQAycD0IZDJ0QIVc+GasX3+Wh0zXwQycwdcBt8RFbf36fQ0UGmitiHD1GYbY9etPe1NmIG/H/zNKDC7vXBiUzvx3MQL6uR8avlBFSOohovgNbGDY/V8p9H95ueC7mav+l/MC/XwUKg9G/+ERCOX9J2BgCcOZd6BYCTUG+bmcb/36bSfhLoQqgxlGlIFQF7qkCb4rn4nhQoT2/2BHEmEgKAxXCTKkAcPQ+O5/Z12UMEQ1kLgwXG+lQOVYnsHTDjfQSZkK6RAYLW1Q8xwlKc0p1M7LVAYA6+5/xBEaMlEAAAAASUVORK5CYII=");
+ }
+
+ figure[about] > figcaption small a[href*="by-sa"] {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAAAAABWohdTAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADhSURBVDjLY2CgOvhPVQAycD0IZDJ0QIVc+GasX3+Wh0zXwQycwdcBt8RFbf36fQ0UGmitiHD1GYbY9etPe1NmIG/H/zNKDC7vXBiUzvx3MQL6uR8avlBFiAAHEQQNbGDY/V8p9H95ueC7mav+l/MC/XwUKg9G/5HUQwXxG1jCcOYdKFZCjUF+Ludbv37bSbiDoMogMfgfkiyIdKFLmuC78pkYLkRx0H+iXAgKw1WCDGnAMDS++99ZFyUMkfTDwpSwgVYKVI7lGTztcAOdlKmQDoHR0gY1z1GS0pxC7bxMZQAA+H98xwgOlxMAAAAASUVORK5CYII=");
+ }
+
+ figure[about] > figcaption small a[href*="by-nc-nd"] {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAAAAABWohdTAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADpSURBVDjLY2CgOvhPVQAycD0IZDJ0QIVc+GasX3+Wh0zXwQycwdcBt8RFbf36fQ0UGmitiHD1GYbY9etPe1NmIG/H/zNKDC7vXBiUzvx3MQL6uR8avlBFSOpBwigGQJShGNjAsPu/Uuj/8nLBdzNX/S/nBfr5KFQejODqYTxcAjADSxjOvAPFSqgxyM/lfOvXbzsJdyFUGUwvzHhUgf9YXeiSJviufCaGCxmQffgf1YVoAshhuEqQIQ0YhsZ3/zvrooQhqoHEheF6KwUqx/IMnna4gU7KVEiHwGhpg5rnKElpTqF2XqYyAABUp5irV+pVjgAAAABJRU5ErkJggg==");
+ }
+
+ figure[about] > figcaption small a[href*="by-nc-sa"] {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAAAAABWohdTAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAD0SURBVDjLY2CgOvhPVQAycD0IZDJ0QIVc+GasX3+Wh0zXwQycwdcBt8RFbf36fQ0UGmitiHD1GYbY9etPe1NmIG/H/zNKDC7vXBiUzvx3MQL6uR8avlBFSOpBwsgxgMyHGdjAsPu/Uuj/8nLBdzNX/S/nBfr5KFQejP7DtUN5/5EMQOeDDCxhOPMOFCuhxiA/l/OtX7/tJNx+qDKYYTDjoVH6H5JOsLvQJU3wXflMDBcyIPvoP4oLGbC4GBaGqwQZ0oBhaHz3v7MuShiiGogahrBAxjDQSoHKsTyDpx1uoJMyFdIhMFraoOY5SlKaU6idl6kMAJQFla4A8k4xAAAAAElFTkSuQmCC");
+ }
diff --git a/wordpress-cc-plugin/css/spreeblick.css b/wordpress-cc-plugin/css/spreeblick.css
index 33c1332..914f552 100644
--- a/wordpress-cc-plugin/css/spreeblick.css
+++ b/wordpress-cc-plugin/css/spreeblick.css
@@ -36,7 +36,7 @@ figure[about] figcaption:hover {
figure[about] figcaption [property*=attributionName] {
border: none;
- color: inherit;
+ color: black;
display: block;
font-size: 12px;
height: 22px;
@@ -45,6 +45,7 @@ figure[about] figcaption:hover {
padding: 0 0.5em;
position: relative;
text-decoration: underline;
+ text-shadow: none;
}
figure[about] figcaption small {
@@ -55,12 +56,13 @@ figure[about] figcaption:hover {
figure[about] figcaption small,
figure[about] figcaption small a,
figure[about] figcaption small a abbr {
- color: transparent;
+ color: transparent !important;
border: none;
display: block;
height: 22px;
margin: 0;
padding: 0;
+ text-shadow: none !important;
width: 22px;
}
diff --git a/wordpress-cc-plugin/css/wetter.css b/wordpress-cc-plugin/css/wetter.css
index 58d2177..4253614 100644
--- a/wordpress-cc-plugin/css/wetter.css
+++ b/wordpress-cc-plugin/css/wetter.css
@@ -15,6 +15,7 @@ figure[about] > video {
figure[about] > figcaption {
border: 1px solid #888a85;
display: block;
+ line-height: 1.5em;
padding: 11px 11px 11px 110px;
}
@@ -45,6 +46,7 @@ figure[about] > figcaption {
left:-110px;
top:-33px;
margin-bottom:-33px;
+ text-shadow: none !important;
}
figure[about] > figcaption small a[href*="by"] {
@@ -85,6 +87,7 @@ figure[about] > figcaption {
figure[about] > figcaption small a abbr {
border: none !important;
+ cursor: pointer;
display: block;
height: 100%;
width: 100%;
diff --git a/wordpress-cc-plugin/wordpress-cc-plugin.php b/wordpress-cc-plugin/wordpress-cc-plugin.php
index 4a5f338..fcffb8f 100644
--- a/wordpress-cc-plugin/wordpress-cc-plugin.php
+++ b/wordpress-cc-plugin/wordpress-cc-plugin.php
@@ -13,16 +13,31 @@ Version: 0.5
Author URI: http://dieweltistgarnichtso.net
*/
+// A handy list of licenses and full names.
+$license_list = array(
+ 'reserved' => 'All rights reserved.',
+ 'by' => 'Attribution',
+ 'by-nc' => 'Attribution Non-Commerical',
+ 'by-nc-nd' => 'Attribution Non-Commercial No Derivatives',
+ 'by-nc-sa' => 'Attribution Non-Commercial Share Alike',
+ 'by-nd' => 'Attribution No Derivatives',
+ 'by-sa' => 'Attribution Share Alike'
+);
+
/* install and uninstall */
// create database entry on install
function cc_wordpress_register_settings() {
register_setting('cc_wordpress_options', 'cc_wordpress_css');
+ register_setting('cc_wordpress_options', 'cc_wordpress_default_license');
+ register_setting('cc_wordpress_options', 'cc_wordpress_post_thumbnail_filter');
}
// delete database entry on uninstall
function cc_wordpress_uninstall(){
- delete_option('cc_wordpress_css');
+ unregister_setting('cc_wordpress_options', 'cc_wordpress_css');
+ unregister_setting('cc_wordpress_options', 'cc_wordpress_default_license');
+ unregister_setting('cc_wordpress_options', 'cc_wordpress_post_thumbnail_filter');
}
// install hook
@@ -43,8 +58,7 @@ function cc_wordpress_admin_checked($key, $value) {
// generate list of css files
function cc_wordpress_admin_css_list() {
- // FIXME: get path the proper way
- $path = '../wp-content/plugins/wordpress-cc-plugin/css/';
+ $path = WP_PLUGIN_DIR .'/wordpress-cc-plugin/css/';
$directory = opendir($path);
$html = '';
@@ -59,7 +73,7 @@ function cc_wordpress_admin_css_list() {
$html .= cc_wordpress_admin_checked('cc_wordpress_css', $file);
$html .= '/><i>'. substr($file, 0, -4) .'</i></label>
- <img src="'. substr($path, 0, -4) .'css-preview/'. substr($file, 0, -3) .'png"/>
+ <img src="'. WP_PLUGIN_URL .'/wordpress-cc-plugin/css-preview/'. substr($file, 0, -3) .'png"/>
</li>';
// maybe use real path editing facilities ? but then, this already works.
}
@@ -71,6 +85,41 @@ function cc_wordpress_admin_css_list() {
return $html;
}
+// generate license dropdown
+function cc_wordpress_license_select($current_license, $name, $mark_default) {
+
+ global $license_list;
+
+ $html = '<select id="cc_license" name="'. $name .'"">';
+
+ foreach ($license_list as $abbr => $license) {
+ $selected = ($abbr == $current_license) ? ' selected="selected"' : '';
+ $license_name = cc_wordpress_license_name($abbr, $mark_default);
+ $html .= '<option value="'. $abbr .'"'. $selected .'>'. $license_name .'</option>';
+ }
+
+ $html .= '</select>';
+
+ return $html;
+}
+
+//generate license name
+function cc_wordpress_license_name($license, $mark_default) {
+ $default_license = get_option('cc_wordpress_default_license');
+
+ if ($license == 'reserved') {
+ $license_name = __('All rights reserved.');
+ } else {
+ $license_name = strtoupper($license);
+
+ if ($license == $default_license and $mark_default == true) {
+ $license_name .= ' ' .__('(Default)');
+ }
+ }
+
+ return $license_name;
+}
+
// admin page
function cc_wordpress_admin_page() {
?>
@@ -98,6 +147,35 @@ label input {
settings_fields('cc_wordpress_options');
?>
+ <h2>Default License</h2>
+ <p>
+ Setting a default license pre-fills the license chooser form field with the chosen license.
+ </p>
+
+ <p>
+ <label>
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAQAAABuvaSwAAAAAnNCSVQICFXsRgQAAAAJcEhZcwAABJ0AAASdAXw0a6EAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAABmklEQVQoz5XTPWiTURTG8d8b/GjEii2VKoqKi2DFwU9wUkTdFIeKIEWcpIOTiA4OLgVdXFJwEZHoIII0TiJipZJFrIgGKXQQCRg6RKREjEjMcQnmTVPB3jNc7j1/7nk49zlJ+P+1rPsqydqFD1HvSkUq9MkpaQihoWRcfzqftGUkx9y10Yy33vlttz2GzBmNQtfLrmqqGu6odNKccOvvubXt1/Da+tAZBkwKx1OwHjNqti1EQ7DBN2Vr2vBl4cJiaAjOCdfbcMF3mWC7O6qmDFntms9KzgYZNU/bcFkxBM+UjXjiilFNl4yZsCIoqrRgA0IuGNRws1W66H1KSE5YFzKoa+pFTV0/ydYk66s+kt5kE1ilqd7qs49KIcj75bEfxp0RJn0yKxtMm21rzmtYG6x0Wt5Fy4ODbhuzJejx06M2PCzc+2frbgjn0z9YEE4tih7Q8FyShgdVzRvpQk+omLe5wxvBIV+ECTtkQpCx00Oh4ugCI7XcfF8INa9MqQnhQdrRSedYJYcdsc9eTHvjRbzsyC5lBjNLYP0B5PQk1O2dJT8AAAAASUVORK5CYII=" alt="Creative Commons"/>
+
+ <?php
+ $current_license = get_option('cc_wordpress_default_license');
+ echo cc_wordpress_license_select($current_license, 'cc_wordpress_default_license', false);
+ ?>
+ </label>
+ </p>
+
+ <h2>Post Thumbnail Filter</h2>
+ <p>
+ Specify if post thumbnail images should be replaced with <i><figure></i> elements.
+ </p>
+ <p>
+ <label>
+ Filter post thumbnails
+ <input type="checkbox" name="cc_wordpress_post_thumbnail_filter"<?php
+ echo cc_wordpress_admin_checked('cc_wordpress_post_thumbnail_filter','on');
+ ?>/>
+ </label>
+ </p>
+
<h2>Stylesheet</h2>
<p>
A stylesheet changes the look of the license attribution.
@@ -144,7 +222,7 @@ if(is_admin()) {
// output link to chosen CSS
function cc_wordpress_add_css() {
if (get_option('cc_wordpress_css')) {
- echo '<link rel="stylesheet" href="'. get_bloginfo('url') .'/wp-content/plugins/wordpress-cc-plugin/css/'. get_option('cc_wordpress_css') .'" type="text/css"/>';
+ echo '<link rel="stylesheet" href="'. WP_PLUGIN_URL .'/wordpress-cc-plugin/css/'. get_option('cc_wordpress_css') .'" type="text/css"/>';
}
}
@@ -213,20 +291,17 @@ table {
$id = $post->ID;
+ $default_license = get_option('cc_wordpress_default_license');
$current_license = get_post_meta($id, 'cc_license', true);
-
- $html = "<select id='cc_license' name='attachments[$id][cc_license]'>\n";
- $html .= " <option value=''>All rights reserved.</option>\n";
- $licenses = array('by', 'by-nc', 'by-nc-nd', 'by-nc-sa', 'by-nd', 'by-sa');
- foreach ( $licenses as $license ) {
- $selected = ( $license == $current_license ) ? "selected='selected'" : '';
- $license_upper = strtoupper($license);
- $html .= " <option value='$license' $selected>$license_upper</option>\n";
+ if ($current_license == '') {
+ $current_license = $default_license;
}
- $html .= "</select>";
+
+ $name = 'attachments['. $id .'][cc_license]';
+ $html = cc_wordpress_license_select($current_license, $name, true);
$form_fields['cc_license'] = array(
- 'label' => '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAQAAABuvaSwAAAAAnNCSVQICFXsRgQAAAAJcEhZcwAABJ0AAASdAXw0a6EAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAABmklEQVQoz5XTPWiTURTG8d8b/GjEii2VKoqKi2DFwU9wUkTdFIeKIEWcpIOTiA4OLgVdXFJwEZHoIII0TiJipZJFrIgGKXQQCRg6RKREjEjMcQnmTVPB3jNc7j1/7nk49zlJ+P+1rPsqydqFD1HvSkUq9MkpaQihoWRcfzqftGUkx9y10Yy33vlttz2GzBmNQtfLrmqqGu6odNKccOvvubXt1/Da+tAZBkwKx1OwHjNqti1EQ7DBN2Vr2vBl4cJiaAjOCdfbcMF3mWC7O6qmDFntms9KzgYZNU/bcFkxBM+UjXjiilFNl4yZsCIoqrRgA0IuGNRws1W66H1KSE5YFzKoa+pFTV0/ydYk66s+kt5kE1ilqd7qs49KIcj75bEfxp0RJn0yKxtMm21rzmtYG6x0Wt5Fy4ODbhuzJejx06M2PCzc+2frbgjn0z9YEE4tih7Q8FyShgdVzRvpQk+omLe5wxvBIV+ECTtkQpCx00Oh4ugCI7XcfF8INa9MqQnhQdrRSedYJYcdsc9eTHvjRbzsyC5lBjNLYP0B5PQk1O2dJT8AAAAASUVORK5CYII="/ alt="Creative Commons"> '. __('License'),
+ 'label' => '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAQAAABuvaSwAAAAAnNCSVQICFXsRgQAAAAJcEhZcwAABJ0AAASdAXw0a6EAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAABmklEQVQoz5XTPWiTURTG8d8b/GjEii2VKoqKi2DFwU9wUkTdFIeKIEWcpIOTiA4OLgVdXFJwEZHoIII0TiJipZJFrIgGKXQQCRg6RKREjEjMcQnmTVPB3jNc7j1/7nk49zlJ+P+1rPsqydqFD1HvSkUq9MkpaQihoWRcfzqftGUkx9y10Yy33vlttz2GzBmNQtfLrmqqGu6odNKccOvvubXt1/Da+tAZBkwKx1OwHjNqti1EQ7DBN2Vr2vBl4cJiaAjOCdfbcMF3mWC7O6qmDFntms9KzgYZNU/bcFkxBM+UjXjiilFNl4yZsCIoqrRgA0IuGNRws1W66H1KSE5YFzKoa+pFTV0/ydYk66s+kt5kE1ilqd7qs49KIcj75bEfxp0RJn0yKxtMm21rzmtYG6x0Wt5Fy4ODbhuzJejx06M2PCzc+2frbgjn0z9YEE4tih7Q8FyShgdVzRvpQk+omLe5wxvBIV+ECTtkQpCx00Oh4ugCI7XcfF8INa9MqQnhQdrRSedYJYcdsc9eTHvjRbzsyC5lBjNLYP0B5PQk1O2dJT8AAAAASUVORK5CYII=" alt="Creative Commons"> '. __('License'),
'input' => 'html',
'html' => $html,
'helps' => __('Choose a Creative Commons License.')
@@ -269,101 +344,125 @@ function cc_wordpress_attachment_fields_to_save($post, $attachment) {
cc_wordpress_update_or_add_or_delete($id, 'cc_rights_holder', $attachment['cc_rights_holder']);
cc_wordpress_update_or_add_or_delete($id, 'cc_attribution_url', $attachment['cc_attribution_url']);
+ // grab license information through CC API
+ $rest = file_get_contents('http://api.creativecommons.org/rest/1.5/license/standard/get');
+ $license = get_post_meta($id, 'cc_license', true);
+
+ if ($rest) {
+ preg_match('/<license-uri>(.*?)<\/license-uri>/', $rest, $matches);
+ $license_url = str_replace('/by/', '/'. $license .'/' , $matches[1]);
+ } else {
+ $license_url = 'http://creativecommons.org/licenses/'. $license .'/3.0/';
+ }
+
+ cc_wordpress_update_or_add_or_delete($id, 'cc_license_url', $license_url);
+
return $post;
}
function cc_wordpress_media_send_to_editor($html, $attachment_id, $attachment) {
+ $post =& get_post($attachment_id, ARRAY_A);
+ $id = $post['ID'];
+
+ // save licensing information before sending to editor
+ cc_wordpress_attachment_fields_to_save($post, $attachment);
+
+ $title = $attachment['post_excerpt'];
+
+ # example output: "[[cc:18|some caption]]"
+ $embed_code = '[[cc:' . $attachment_id .'|' .$title. ']]';
+ return $embed_code;
+}
+
+function cc_wordpress_create_figure($attachment_id, $title, $size = '', $is_post_thumbnail = false) {
+
+ global $license_list;
+
$post =& get_post($attachment_id);
$id = $post->ID;
- // save licensing information before sending to editor
- cc_wordpress_update_or_add_or_delete($id, 'cc_license', $attachment['cc_license']);
- cc_wordpress_update_or_add_or_delete($id, 'cc_rights_holder', $attachment['cc_rights_holder']);
- cc_wordpress_update_or_add_or_delete($id, 'cc_attribution_url', $attachment['cc_attribution_url']);
+ if ($title == '') {
+ $title = $post->post_excerpt;
+ }
$type = substr($post->post_mime_type, 0, 5);
- // TODO: get proper URL
- $url = $attachment['url'];
- $alt = $attachment['image_alt'];
+ $url = wp_get_attachment_url($id);
+ $alt = get_post_meta($id, '_wp_attachment_image_alt', true);
if ($type == 'image') {
$dmci_type_url = 'http://purl.org/dc/dcmitype/Image';
- $media_html = '<img src="'. $url .'" alt="'. $alt .'"/>';
+ if ($size == '') {
+ $media_html = '<img src="'. $url .'" alt="'. $alt .'"/>';
+ } else {
+ $image = wp_get_attachment_image_src($id);
+ $media_html = '<img src="'. $image[0] .'" alt="'. $alt .'"/>';
+ }
} elseif ($type == 'audio') {
$dmci_type_url = 'http://purl.org/dc/dcmitype/Sound';
- $media_html = '<audio src="'. $url . '"/>';
+ $media_html = '<audio src="'. $url . '"><a href="'. $url .'">audio download</a></audio>';
} elseif ($type == 'video') {
$dmci_type_url = 'http://purl.org/dc/dcmitype/MovingImage';
- $media_html = '<video src="'. $url .'"/>';
+ $media_html = '<video src="'. $url .'"><a href="'. $url .'">video download</a></video>';
} else {
- $media_html = '<object src="'. $url .'"/>';
+ $media_html = '<object src="'. $url .'"><a href="'. $url .'">download</a></object>';
}
- $attribution_name = $attachment['cc_rights_holder'];
- $attribution_url = $attachment['cc_attribution_url'];
+ $attribution_name = get_post_meta($id, 'cc_rights_holder', true);
+ $attribution_url = get_post_meta($id, 'cc_attribution_url', true);
// TODO: license version and jurisdiction
- $license = $attachment['cc_license'];
+ $license = get_post_meta($id, 'cc_license', true);
+ $license_url = get_post_meta($id, 'cc_license_url', true);
- // grab license information through CC API
- $rest = file_get_contents('http://api.creativecommons.org/rest/1.5/license/standard/get');
-
- if ($rest) {
- preg_match('/<license-uri>(.*?)<\/license-uri>/', $rest, $matches);
- $license_url = str_replace('/by/', '/'. $license .'/' , $matches[1]);
+ if ( $license ) {
+ $license_abbr = 'CC' . strtoupper($license);
+ $license_full = 'Creative Commons'. __($license_list($license));
} else {
- $license_url = 'http://creativecommons.org/licenses/'. $license .'/3.0/';
+ // no license, just return standard markup
+ return wp_get_attachment_image($id);
}
- switch ($license) {
- case "":
- // no license, just return standard markup
- return $html;
- case "by":
- $license_abbr = 'CC BY';
- $license_full = 'Creative Commons'. __('Attribution');
- break;
-
- case "by-nc":
- $license_abbr = 'CC BY-NC';
- $license_full = 'Creative Commons'. __('Attribution-Noncommercial');
- break;
-
- case "by-nd":
- $license_abbr = 'CC BY-ND';
- $license_full = 'Creative Commons'. __('Attribution-No Derivative Works');
- break;
-
- case "by-sa":
- $license_abbr = 'CC BY-SA';
- $license_full = 'Creative Commons'. __('Attribution-ShareAlike');
- break;
-
- case "by-nc-nd":
- $license_abbr = 'CC BY-NC-ND';
- $license_full = 'Creative Commons'. __('Attribution-Noncommercial-No Derivative Works');
- break;
-
- case "by-nc-sa":
- $license_abbr = 'CC BY-NC-SA';
- $license_full = 'Creative Commons'. __('Attribution-Noncommercial-Share Alike');
- break;
- }
-
- $title = $attachment['post_excerpt'];
-
- // TODO: RDFa / Microdata switch (currently only RDFa supported)
-
// produce caption
$caption_html = '<span href="'. $dmci_type_url .'" property="dc:title" rel="dc:type">'. $title .'</span> <a href="'. $attribution_url .'" property="cc:attributionName" rel="cc:attributionURL">'. $attribution_name .'</a> <small> <a href="'. $license_url .'" rel="license"> <abbr title="'. $license_full .'">'. $license_abbr .'</abbr> </a> </small>';
+ // add specific thumbnail class
+ if ($is_post_thumbnail == true) {
+ $post_thumbnail_class = 'class="post-thumbnail" ';
+ }
+
// add figure element
- $html = '<figure about="'. $url .'" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/terms/"> '. $media_html .' <figcaption> '. $caption_html .'</figcaption> </figure>';
+ $html = '<figure '. $post_thumbnail_class .'about="'. $url .'" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/terms/"> '. $media_html .' <figcaption> '. $caption_html .'</figcaption> </figure>';
return $html;
}
+function cc_wordpress_article_filter($article) {
+ # example match: "[[cc:18|some caption]]"
+ preg_match_all('/\[\[cc:([0-9].*?)\|(.*?)\]\]/', $article, $matches, PREG_SET_ORDER);
+
+ foreach ($matches as $match) {
+ $figure = cc_wordpress_create_figure($match[1], $match[2]);
+ $article = str_replace($match[0], $figure, $article);
+ }
+
+ return $article;
+}
+
+function cc_wordpress_post_thumbnail_filter($html, $post_id, $post_thumbnail_id, $size, $attr) {
+ if (get_option('cc_wordpress_post_thumbnail_filter') == 'on') {
+ $html = cc_wordpress_create_figure($post_thumbnail_id, '', $size, true);
+ }
+
+ return $html;
+}
+
+// apply filter to articles before they are displayed
+add_action('the_content', 'cc_wordpress_article_filter');
+
+// apply filter to post thumbnail html
+add_filter( 'post_thumbnail_html', 'cc_wordpress_post_thumbnail_filter', 11, 5);
+
// add attachment fields
add_filter('attachment_fields_to_edit', 'cc_wordpress_fields_to_edit', 11, 2);
hooks/post-receive
--
Integrates CC licensing into media manager and posts
More information about the cc-commits
mailing list