Skip to content
Snippets Groups Projects
Commit eb2ee268 authored by lucha's avatar lucha Committed by lechuck
Browse files

Flattr plugin version 1.2.0

parent 74359033
Branches
No related tags found
No related merge requests found
Showing
with 1113 additions and 960 deletions
<?php
if ( isset ($_REQUEST['oauth_token']) && isset ($_REQUEST['oauth_verifier']) && isset($_REQUEST['page']) && ($_REQUEST['page']=="flattr/settings.php")) {
if (session_id() == '') { session_start(); }
include_once "oAuth/flattr_rest.php";
$api_key = get_option('flattrss_api_key');
$api_secret = get_option('flattrss_api_secret');
$flattr = new Flattr_Rest($api_key, $api_secret, $_SESSION['flattrss_current_token']['oauth_token'], $_SESSION['flattrss_current_token']['oauth_token_secret']);
$access_token = $flattr->getAccessToken($_REQUEST['oauth_verifier']);
if ($flattr->http_code == 200) {
add_option('flattrss_api_oauth_token', $access_token['oauth_token']);
update_option('flattrss_api_oauth_token', $access_token['oauth_token']);
add_option('flattrss_api_oauth_token_secret', $access_token['oauth_token_secret']);
update_option('flattrss_api_oauth_token_secret', $access_token['oauth_token_secret']);
require_once( ABSPATH . WPINC . '/registration.php');
$user_id = get_current_user_id( );
update_user_meta( $user_id, "user_flattrss_api_oauth_token", $access_token['oauth_token'] );
update_user_meta( $user_id, "user_flattrss_api_oauth_token_secret", $access_token['oauth_token_secret'] );
} else {
wp_die("<h1>Callback Error.</h1><p>Please clear browser cach and cookies, then try again. Sorry for the inconvenience.</p><p align='right'>Michael Henke</p>");
}
header("Status: 307");
header("Location: ". get_bloginfo('wpurl') .'/wp-admin/admin.php?page=flattr/settings.php');
exit(307);
}
\ No newline at end of file
/*
Document : flattr
Created on : Dec 27, 2011, 2:28:15 AM
Author : Michael
*/
#icon-options-general.icon32.flattr {
background-image: url('img/flattr_button.png');
background-position: center center;
background-repeat: no-repeat;
}
th {
text-align: right;
vertical-align: top;
}
td {
vertical-align: top;
}
td input {
margin-right: 8px;
}
.flattr-wrap table.form-table li iframe,
.flattr-wrap table.form-table li img {
vertical-align: middle;
}
.flattr-wrap span.inactive {
color: gray;
}
.flattr-wrap span.active:before {
content : " ";
}
.flattr-wrap div#dialog {
display: none;
}
.flattr-server-check {
font-weight: bold;
}
.flattr-server-check.failed {
color: red;
}
.flattr-server-check.passed {
color: green;
}
.flattr-server-check.warn {
color: yellow;
}
#dialog ol li {
list-style-type :decimal-leading-zero;
}
\ No newline at end of file
This diff is collapsed.
<?php
add_action( 'admin_notices','flattrAdminNotice' );
function flattrAdminNotice() {
echo '<div id="message" class="error">';
echo '<p><strong>Warning:</strong> The Flattr plugin requires PHP5. You are currently using '. PHP_VERSION .'</p>';
echo '</div>';
}
/**
* returns the Flattr button
* Use this from your template
*/
function get_the_flattr_permalink()
{
return '';
}
/**
* prints the Flattr button
* Use this from your template
*/
function the_flattr_permalink()
{
}
This diff is collapsed.
<?php
require_once dirname(__FILE__) . '/lib/httpconnection.php';
require_once dirname(__FILE__) . '/lib/httpresponse.php';
require_once dirname(__FILE__) . '/lib/oauth2client.php';
\ No newline at end of file
# Sample code to use the Flattr v2 web API
to get up and running:
the oauth2client uses httpconnection and httpresponse which wrapps the curl php bindings.
if you are using a server with apt you can install it by
apt-get install php5-curl
## public api call
$client = new OAuth2Client(array('base_url' => 'https://api.flattr.com/rest/v2'));
$thing = $client->getParsed('/things/423405/');
var_dump($thing); // array
## minimal sample code
create an API key at https://flattr.com/apps
make sure you add a correct callback\_url it should be something like http://url-to-your-vhost/callback.php
Copy /config.template.php to /config.php and enter your api credentials.
Point a apache/lighttpd/nginx vhost to the minimal/ directory and restart.
Open http://url-to-your-vhost
## connect with flattr sample
sample app that implements a connect with flattr (based on sessions, no database, using coltrane framework)
see connect\_with\_flattr/
----
Documentation at [http://developers.flattr.net/](http://developers.flattr.net/)
Questions: [StackOverflow](http://stackoverflow.com/questions/tagged/flattr)
Feedback: [twitter](https://twitter.com/#!/flattr)
<?php
if (!function_exists('flattrwidget_control')) {
function new_flattrwidget_control() {
$options = get_option("flattrwidget");
if (!is_array( $options )) {
$options = array(
'title' => 'Flattr',
'text' => '',
'above' => true,
'compact' => false,
'html' => false
);
}
if ($_POST['flattrwidget-submit']) {
$options['title'] = htmlspecialchars($_POST['flattrwidget-title']);
if($options['html']) {
$options['text'] = $_POST['flattrwidget-text'];
} else {
$options['text'] = htmlspecialchars($_POST['flattrwidget-text']);
};
$options['above'] = $_POST['flattrwidget-above'];
$options['compact'] = $_POST['flattrwidget-compact'];
$options['html'] = $_POST['flattrwidget-html'];
update_option("flattrwidget", $options);
}
?>
<p>
<label for="flattrwidget-title">Title: </label><br />
<input class="widefat" type="text" id="flattrwidget-title" name="flattrwidget-title" value="<?php echo $options['title'];?>" />
<label for="flattrwidget-text">Text: </label><br />
<textarea class="widefat" rows="16" cols="10" type="text" id="flattrwidget-text" name="flattrwidget-text"><?php echo stripslashes($options['text']);?></textarea>
<input type="checkbox" id="flattrwidget-above" name="flattrwidget-above"<?php if ($options['above']) { echo " checked"; } ?> />
<label for="flattrwidget-above">Check to display the text above the Flattr button. (leave unchecked to display below)</label><br />
<input type="checkbox" id="flattrwidget-html" name="flattrwidget-html"<?php if ($options['html']) { echo " checked"; } ?> />
<label for="flattrwidget-html">Check to allow HTML in text.</label><br />
<input type="checkbox" id="flattrwidget-compact" name="flattrwidget-compact"<?php if ($options['compact']) { echo " checked"; } ?> />
<label for="flattrwidget-compact">Check to use compact style Flattr button.</label><br />
<input type="hidden" id="flattrwidget-submit" name="flattrwidget-submit" value="1" />
<?php
if (!get_option('flattr_uid')) {
$url = get_bloginfo('wpurl') .'/wp-admin/plugin-install.php?tab=plugin-information&plugin=flattr&TB_iframe=true&width=640&height=840';
echo "<p>You need the <a href=\"$url\">official Flattr plugin</a> installed, activated and configured for the widget to work!</p>";
echo "<p>Nothing will be displayed in your sidebar right now.</p>";
}
}
function new_flattrwidget_widget($args) {
if (!get_option('flattr_uid')) { return; }
extract($args);
$options = get_option("flattrwidget");
echo $before_widget;
echo $before_title;
echo $options['title'];
echo $after_title;
if ($options['above']) { echo "<p>". stripslashes($options['text']) ."</p>"; }
echo "<p align=\"center\">";
$uid = get_option('flattr_uid');
$cat = get_option('flattr_cat');
$lang = get_option('flattr_lng');
$category = $cat;
$title = get_bloginfo('name');
$description = get_bloginfo('description');
$tags = 'blog,wordpress,widget';
$url = get_bloginfo('url');
$language = $lang;
$userID = $uid;
$compact = compact;
if (!$options['compact']) { $compact = 'large'; }
$cleaner = create_function('$expression', "return trim(preg_replace('~\r\n|\r|\n~', ' ', addslashes(\$expression)));");
# button: compact | default
/*
* <a class="FlattrButton" style="display:none;"
title="Detta är min post titel"
data-flattr-uid="kjell"
data-flattr-tags="tag1, tag2"
data-flattr-category="text"
href="http://wp.local/?p=444">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing
Maecenas aliquet aliquam leo quis fringilla.
</a>
*/
$output = "<a class='FlattrButton' style='display:none;'".
' href="'.$cleaner($url).'"'.
' title="'.$cleaner($title).'"'.
' data-flattr-uid="'.$cleaner($userID).'"'.
' data-flattr-tags="'.$tags.'"'.
' data-flattr-button="'.$compact.'"'.
' data-flattr-category="'.$cleaner($category).'">'.
$cleaner($description).
'</a>';
/*
$output = "<script type=\"text/javascript\">\n";
if ( defined('Flattr::VERSION')) {
$output .= "var flattr_wp_ver = '" . Flattr::VERSION . "';\n";
}
$output .= "var flattr_uid = '" . $cleaner($userID) . "';\n";
$output .= "var flattr_url = '" . $cleaner($url) . "';\n";
$output .= "var flattr_lng = '" . $cleaner($language) . "';\n";
$output .= "var flattr_cat = '" . $cleaner($category) . "';\n";
if($tags) { $output .= "var flattr_tag = '". $cleaner($tags) ."';\n"; }
if ($options['compact']) { $output .= "var flattr_btn = 'compact';\n"; } else {
$output .= "var flattr_btn = 'large';\n";
}
$output .= "var flattr_tle = '". $cleaner($title) ."';\n";
$output .= "var flattr_dsc = '". $cleaner($description) ."';\n";
$output .= "</script>\n";
if ( defined('Flattr::API_SCRIPT')) {
$output .= '<script src="' . Flattr::API_SCRIPT . '" type="text/javascript"></script>';
}
*
*/
echo $output;
echo "</p>";
if (!$options['above']) { echo "<p>". stripslashes($options['text']) ."</p>"; }
echo $after_widget;
}
register_sidebar_widget ( "Flattr Widget", new_flattrwidget_widget );
register_widget_control ( "Flattr Widget", new_flattrwidget_control );
} else {
}
?>
wp-content/plugins/flattr/images/ui-bg_diagonals-thick_18_b81900_40x40.png

260 B

wp-content/plugins/flattr/images/ui-bg_diagonals-thick_20_666666_40x40.png

251 B

wp-content/plugins/flattr/images/ui-bg_flat_10_000000_40x100.png

178 B

wp-content/plugins/flattr/images/ui-bg_glass_100_f6f6f6_1x400.png

104 B

wp-content/plugins/flattr/images/ui-bg_glass_100_fdf5ce_1x400.png

125 B

wp-content/plugins/flattr/images/ui-bg_glass_65_ffffff_1x400.png

105 B

wp-content/plugins/flattr/images/ui-bg_gloss-wave_35_f6a828_500x100.png

3.67 KiB

wp-content/plugins/flattr/images/ui-bg_highlight-soft_100_eeeeee_1x100.png

90 B

wp-content/plugins/flattr/images/ui-bg_highlight-soft_75_ffe45c_1x100.png

129 B

wp-content/plugins/flattr/images/ui-icons_222222_256x240.png

4.27 KiB

wp-content/plugins/flattr/images/ui-icons_228ef1_256x240.png

4.27 KiB

wp-content/plugins/flattr/images/ui-icons_ef8c08_256x240.png

4.27 KiB

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