Skip to content
Snippets Groups Projects
Commit 0736fefa authored by lucha's avatar lucha
Browse files

[auto] Plugin: creative-commons-license-widget 0.7

parent f17ca174
Branches
Tags
No related merge requests found
<?php
/****************************************************************************
Plugin Name: creative commons license widget
Contributors: lcflores, Gyo (italian translation - http://gyo.ilbello.com), Sergi Barros (catalan translation)
Donate link: http://www.xperimentos.com/2007/05/11/creative-commons-license-widget-for-wordpress/
Author URI: http://www.xperimentos.com/2007/05/11/creative-commons-license-widget-for-wordpress/
Tags: license, creative commons
Requires at least: 2.0.2
Tested up to: 2.5
Stable tag: 0.7
Version: 0.7
Creation time: 12/05/2007
Last updated: 22/07/2008
Description: Adds a sidebar widget to display creative commons license (supports all 3.0 licenses)
****************************************************************************/
// This gets called at the plugins_loaded action
function widget_ccLicense_init() {
// check for sidebar existance
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
return;
// This saves options and prints the widget's config form.
function widget_ccLicense_control() {
$options = $newoptions = get_option('widget_ccLicense');
if ( $_POST['ccLicense-submit'] ) {
$newoptions['title'] = strip_tags(stripslashes($_POST['ccLicense-title']));
$newoptions['language'] = strip_tags(stripslashes($_POST['ccLicense-language']));
$newoptions['type'] = strip_tags(stripslashes($_POST['ccLicense-type']));
$newoptions['image'] = strip_tags(stripslashes($_POST['ccLicense-image']));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_ccLicense', $options);
}
?>
<p style="text-align:left;">
<label for="ccLicense-title" style="line-height:25px;display:block;"><?php _e('Title:', 'widgets'); ?>
<input type="text" id="ccLicense-title" name="ccLicense-title" value="<?php echo wp_specialchars($options['title'], true); ?>" />
</label>
<label for="ccLicense-language" style="line-height:25px;display:block;"><?php _e('Language:', 'widgets'); ?>
<select id="ccLicense-language" name="ccLicense-language">
<option value="English" <?php if ($options['language']=='English') {echo "selected=\"selected\""; }?> >English</option>
<option value="Spanish" <?php if ($options['language']=='Spanish') {echo "selected=\"selected\""; }?> >Spanish</option>
<option value="Italian" <?php if ($options['language']=='Italian') {echo "selected=\"selected\""; }?> >Italian</option>
<option value="Catalan" <?php if ($options['language']=='Catalan') {echo "selected=\"selected\""; }?> >Catalan</option>
</select>
</label>
<label for="ccLicense-type" style="line-height:25px;display:block;"><?php _e('License:', 'widgets'); ?>
<select id="ccLicense-type" name="ccLicense-type">
<option value="Attribution" <?php if ($options['type']=='Attribution') {echo "selected=\"selected\""; }?> >Attribution</option>
<option value="Attribution-NoDerivs" <?php if ($options['type']=='Attribution-NoDerivs') {echo "selected=\"selected\""; }?> >Attribution-NoDerivs</option>
<option value="Attribution-NonCommercial-NoDerivs" <?php if ($options['type']=='Attribution-NonCommercial-NoDerivs') {echo "selected=\"selected\""; }?> >Attribution-NonCommercial-NoDerivs</option>
<option value="Attribution-NonCommercial" <?php if ($options['type']=="Attribution-NonCommercial") {echo "selected=\"selected\""; }?> >Attribution-NonCommercial</option>
<option value="Attribution-NonCommercial-ShareAlike" <?php if ($options['type']=='Attribution-NonCommercial-ShareAlike') {echo "selected=\"selected\""; }?> >Attribution-NonCommercial-ShareAlike</option>
<option value="Attribution-ShareAlike" <?php if ($options['type']=='Attribution-ShareAlike') {echo "selected=\"selected\""; }?> >Attribution-ShareAlike</option>
</select>
</label>
<label for="ccLicense-image" style="line-height:25px;display:block;"><?php _e('Image:', 'widgets'); ?>
<select id="ccLicense-image" name="ccLicense-image">
<option value="somerights20" <?php if ($options['image']=='somerights20') {echo "selected=\"selected\""; }?> >somerights20</option>
<option value="80x15" <?php if ($options['image']=='80x15') {echo "selected=\"selected\""; }?> >80x15</option>
<option value="88x31" <?php if ($options['image']=='88x31') {echo "selected=\"selected\""; }?> >88x31</option>
</select>
</label>
<input type="hidden" name="ccLicense-submit" id="ccLicense-submit" value="1" />
</p>
<?php
}
// This prints the widget
function widget_ccLicense($args) {
extract($args);
$options = get_option('widget_ccLicense');
$title = $options['title'];
$language = $options['language'];
$type = $options['type'];
$image = $options['image'];
// Creates widget configuration
$text = '';
$licenseText = '';
$imageUrl = '';
$licenseUrl = '';
$url = '';
$licenseText = 'Creative Commons ' . $type . ' 3.0 License';
switch ($language) {
case 'Spanish':
$text = 'Blog bajo licencia';
$licenseUrl = 'deed.es_CL';
break;
case 'Italian':
$text = 'Blog sotto licenza';
$licenseUrl = 'deed.it';
break;
case 'English':
$text = 'Blog under the';
$licenseUrl = '';
break;
case 'Catalan':
$text = 'Blog sota llicncia';
$licenseUrl = 'deed.ca';
break;
default:
$text = 'Blog under the';
$licenseUrl = '';
break;
}
switch ($type) {
case 'Attribution':
$url = 'by';
break;
case 'Attribution-NoDerivs':
$url = 'by-nd';
break;
case 'Attribution-NonCommercial-NoDerivs':
$url = 'by-nc-nd';
break;
case 'Attribution-NonCommercial':
$url = 'by-nc';
break;
case 'Attribution-NonCommercial-ShareAlike':
$url = 'by-nc-sa';
break;
case 'Attribution-ShareAlike':
$url = 'by-sa';
break;
default:
$url = 'by';
break;
}
$licenseUrl = 'http://creativecommons.org/licenses/' . $url . '/3.0/' . $licenseUrl;
switch ($image) {
case 'somerights20':
$imageUrl = 'http://creativecommons.org/images/public/somerights20.png';
break;
case '80x15':
$imageUrl = 'http://i.creativecommons.org/l/' . $url . '/3.0/80x15.png';
break;
case '88x31':
$imageUrl = 'http://i.creativecommons.org/l/' . $url . '/3.0/88x31.png';
break;
default:
$imageUrl = 'http://creativecommons.org/images/public/somerights20.png';
break;
}
// prints the widget.
echo $before_widget . $before_title . $title . $after_title;
?>
<!--Creative Commons License-->
<div style="text-align: center; font-size: xx-small;">
<?php echo $text; ?>
<a rel="license" target="_blank" href="<?php echo $licenseUrl; ?>"> <?php echo $licenseText; ?><br/>
<img alt="Creative Commons License" border="0" src="<?php echo $imageUrl; ?>"/></a>
</div>
<!--/Creative Commons License-->
<?php
echo $after_widget;
}
// Tell Dynamic Sidebar about our new widget and its control
register_sidebar_widget(array('creativecommons License', 'widgets'), 'widget_ccLicense');
register_widget_control(array('creativecommons License', 'widgets'), 'widget_ccLicense_control');
}
// Delay plugin execution to ensure Dynamic Sidebar has a chance to load first
add_action('widgets_init', 'widget_ccLicense_init');
?>
=== creative commons license widget ===
Plugin Name: creative commons license widget
Contributors: lcflores, Gyo (italian translation), Sergi Barros (catalan translation)
Donate link: http://www.xperimentos.com/2007/05/11/creative-commons-license-widget-for-wordpress/
Author URI: http://www.xperimentos.com/2007/05/11/creative-commons-license-widget-for-wordpress/
Tags: license, creative commons
Requires at least: 2.0.2
Tested up to: 2.5
Stable tag: 0.7
Version: 0.7
Creation time: 12/05/2007
Last updated: 22/07/2008
Adds a sidebar widget to display creative commons license (supports all 3.0 licenses)
== Description ==
Adds a sidebar widget to display creative commons license:
Four languages:
* English
* Spanish
* Italian
* Catalan
All creative commons licenses:
* Attribution
* Attribution-NoDerivs
* Attribution-NonCommercial-NoDerivs
* Attribution-NonCommercial
* Attribution-NonCommercial-ShareAlike
* Attribution-ShareAlike
Three images types
* somerights20
* 80x15
* 88x31
== Screenshots ==
1. Widget configuration
2. Example
== Installation ==
1. Firstly, make sure you have the Widget plugin available at http://www.xperimentos.com/public/ccLicense.zip
2. Copy "ccLicense.php" to your plugins folder, "/wp-content/plugins/widgets/"
3. Click the "Activate" link for "creative commons license widget" on your Plugins page (in the WordPress admin interface)
4. Go to Themes->Sidebar Widgets and drag and drop the widget to wherever you want to show it.
5. Use the configuration menu to customise the widget.
\ No newline at end of file
wp-content/plugins/creative-commons-license-widget/screenshot-1.png

7.31 KiB

wp-content/plugins/creative-commons-license-widget/screenshot-2.png

3.2 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment