Commit 5ef65e38 authored by ale's avatar ale Committed by lucha

[auto] Plugin: flattr 1.2.1

parent 50e5362b
......@@ -2,11 +2,11 @@
/**
* @package Flattr
* @author Michael Henke
* @version 1.2.0
* @version 1.2.1
Plugin Name: Flattr
Plugin URI: http://wordpress.org/extend/plugins/flattr/
Description: Give your readers the opportunity to Flattr your effort
Version: 1.2.0
Version: 1.2.1
Author: Michael Henke
Author URI: http://www.codingmerc.com/tags/flattr/
License: This code is (un)licensed under the kopimi (copyme) non-license; http://www.kopimi.com. In other words you are free to copy it, taunt it, share it, fork it or whatever. :)
......@@ -22,7 +22,7 @@ class Flattr
const FLATTR_DOMAIN = 'flattr.com';
const VERSION = "1.2.0";
const VERSION = "1.2.1";
/**
* We should only create Flattr once - make it a singleton
......@@ -63,7 +63,7 @@ class Flattr
* prepare Frontend
*/
protected function frontend() {
if (!in_array(get_option('flattr_button_style'), array('text', 'image'))) {
if (!in_array(get_option('flattr_button_style'), array('text', 'image', 'image-white'))) {
add_action('wp_print_footer_scripts', array($this, 'insert_script'));
}
......@@ -533,8 +533,11 @@ class Flattr
$retval = '<a href="'. esc_attr($this->getAutosubmitUrl($buttonData)) .'" title="Flattr" target="_blank">Flattr this!</a>';
break;
case "image":
$retval = '<a href="'. esc_attr($this->getAutosubmitUrl($buttonData)) .'" title="Flattr" target="_blank"><img src="'. get_bloginfo('wpurl') . '/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a>';
$retval = '<a href="'. esc_attr($this->getAutosubmitUrl($buttonData)) .'" title="Flattr" target="_blank">'. Flattr::getStaticImageButton($type) .'</a>';
break;
case "image-white":
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank">'. Flattr::getStaticImageButton($type) .'</a>';
break;
case "autosubmitUrl":
$retval = $this->getAutosubmitUrl($buttonData);
break;
......@@ -628,8 +631,11 @@ class Flattr
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank">Flattr this!</a>';
break;
case "image":
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank"><img src="'. get_bloginfo('wpurl') . '/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a>';
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank">'. Flattr::getStaticImageButton($type) .'</a>';
break;
case "image-white":
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank">'. Flattr::getStaticImageButton($type) .'</a>';
break;
case "autosubmitUrl":
$retval = $this->getAutosubmitUrl($buttonData);
break;
......@@ -689,6 +695,39 @@ class Flattr
return 'https://' . self::FLATTR_DOMAIN . '/submit/auto?' . http_build_query($params);
}
public static function getStaticImageButton($type=null) {
$imgBaseURL = get_bloginfo('wpurl') . '/wp-content/plugins/flattr/img/';
$srcset = "";
$src = "";
switch (empty($type) ? get_option('flattr_button_style') : $type) {
case "image":
$src = $imgBaseURL . "flattr-badge-large.png";
$custom = get_option('flattrss_custom_image_url');
if ($src != $custom) {
$src = $custom;
}
$srcset .= $src;
break;
case "image-white":
$src = $imgBaseURL . "flattr-badge-white.png";
$srcset .= $src . ", " . $imgBaseURL . "flattr-badge-white@2x.png 2x";
$srcset .= $src . ", " . $imgBaseURL . "flattr-badge-white@3x.png 3x";
break;
}
$imgTag = '<img src="' . $src . '" srcset="'. $srcset . '" alt="Flattr this!"/>';
return $imgTag;
}
protected static $languages;
public static function getLanguages() {
......@@ -807,7 +846,16 @@ function flattr_post2rss($content) {
$postmeta = isset($meta['_flattr_btn_disable'])? $meta['_flattr_btn_disable'] : true;
if (($postmeta) && is_feed() && in_array(get_post_type(), $flattr_post_types)) {
$flattr.= ' <p><a href="'. static_flattr_url($post).'" title="Flattr" target="_blank"><img src="'. get_option('flattrss_custom_image_url') .'" alt="flattr this!"/></a></p>';
// Determine which button style to use. Default: image-white.
$button_style_pref = get_option('flattr_button_style');
$button_type = $button_style_pref;
if ($button_type != "image" && $button_type != "image-white") {
$button_type = "image-white";
}
$flattr.= '<p><a href="'. static_flattr_url($post) .'">' . Flattr::getStaticImageButton($button_type) . '</a></p>';
}
return ($content.$flattr);
}
......@@ -1031,6 +1079,7 @@ if (get_option('flattrss_autosubmit') && get_option('flattr_access_token')) {
/**
* prints the Flattr button
* Use this from your template
* @param type the button type. See Flattr->getButton for details.
*/
function the_flattr_permalink()
{
......
......@@ -3,8 +3,8 @@ Contributors: aphex3k, VoxPelli
Donate link: https://flattr.com/donation/give/to/der_michael
Tags: flattr, donate, micropayments
Requires at least: 3.3
Tested up to: 3.4
Stable tag: 1.2.0
Tested up to: 4.1.1
Stable tag: 1.2.1
This plugin allows you to easily add a Flattr donation buttons to your blog and blog posts.
......@@ -56,6 +56,9 @@ Flattr buttons now detectable by browsers, site itself can now be flattred, a ne
== Changelog ==
= 1.2.1 =
* New Feature: Nicer, modern-looking static buttons for both pages and feed with support for "HiDPI" displays.
= 1.2.0 =
* New Feature: The payment links in RSS/Atom can now be added without adding the graphical buttons and are now on by default
* New Feature: Payment links are now not only included in feed entries - they are now also by default included in the head-tag of entry pages which is usable for eg. browser extensions to detect the existence of a flattr button.
......
......@@ -135,9 +135,14 @@
</a>
<span class="description"><label for="flattr_button_style_js"><?php _e('Dynamic javascript version'); ?></label></span>
</li>
<li>
<input type="radio" name="flattr_button_style" value="image-white"<?=(get_option('flattr_button_style')=="image-white")?" checked":"";?>/>
<?= Flattr::getStaticImageButton($type='image-white') ?>
<span class="description"><?php _e('Static green-white image with with HiDPI support using srcset.'); ?></span>
</li>
<li>
<input type="radio" id="flattr_button_style_image" name="flattr_button_style" value="image"<?=(get_option('flattr_button_style')=="image")?" checked":"";?>/>
<img src="<?=get_option('flattrss_custom_image_url');?>"/>
<?= Flattr::getStaticImageButton('image') ?>
<span class="description"><label for="flattr_button_style_image"><?php _e('Static image version'); ?></label></span>
</li>
<li>
......@@ -169,7 +174,7 @@
Default Value:<br>
<input type="text" size="70" value="<?php echo get_bloginfo('wpurl') . '/wp-content/plugins/flattr/img/flattr-badge-large.png';?>" readonly><br />
<?php } ?>
<span class="description"><?php _e('Only applies to the static image button type and the feed buttons.'); ?></span>
<span class="description"><?php _e('Only applies to button on site and in feed if the static (non-white) image type is selected.'); ?></span>
</td>
</tr>
<tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment