public function register_page() { $podcast = \Podlove\Model\Podcast::get(); $form_attributes = array('context' => 'podlove_flattr', 'action' => $this->get_url()); ?> <p> <?php echo __('This Flattr account will be associated with your Podcast. Flattr donations for e.g. new episodes will be linked with this account.', 'podlove'); ?> </p> <style type="text/css"> /* add linebreak after each radio button+label */ input[type="radio"] + label::after { content: " "; display: block; } </style> <?php \Podlove\Form\build_for((object) Flattr::get_setting(), $form_attributes, function ($form) { $wrapper = new \Podlove\Form\Input\TableWrapper($form); $podcast = $form->object; $wrapper->string('account', ['label' => __('Flattr Account', 'podlove'), 'html' => ['class' => 'regular-text required podlove-check-input']]); if (\Podlove\Modules\Base::is_active('contributors')) { $wrapper->radio('contributor_shortcode_default', ['label' => __('Default Parameter in Contributors Shortcodes', 'podlove'), 'description' => '<br>' . __('You can override this setting individually by passing along the <code>flattr="yes"</code> or <code>flattr="no"</code> parameter to the shortcodes.', 'podlove'), 'options' => ['yes' => 'yes, show Flattr buttons by default', 'no' => 'no, do not show Flattr buttons by default'], 'default' => 'no']); } }); }
/** * Flattr Button * * **Parameters** * * - **url:** URL of thing to flattr. Defaults to WordPress permalink. * - **style:** Button style."large", "compact" or "static". Default: "compact". * - **user:** Flattr user id. Defaults to Flattr account in podcast settings. * * **Examples** * * Simple button with defaults * * ```jinja * {{ flattr.button }} * ``` * * Large button * * ```jinja * {{ flattr.button({ style: 'large' }) }} * ``` * * Button for the Podlove Publisher plugin * * ```jinja * {{ flattr.button({ user: '******', url: 'http://wordpress.org/extend/plugins/podlove-podcasting-plugin-for-wordpress/' }) }} * ``` * * @accessor */ public function button($args = []) { $defaults = ['url' => get_permalink(), 'style' => 'compact', 'user' => \Podlove\Modules\Flattr\Flattr::get_setting('account')]; $args = wp_parse_args($args, $defaults); if ($args['style'] == 'static') { return self::static_button($args['url'], $args['user']); } else { return self::dynamic_button($args); } }
public static function episode_flattr_button($args = []) { return (new Template\Flattr())->button(['url' => get_permalink(), 'style' => isset($args['style']) ? $args['style'] : 'compact', 'user' => Flattr::get_setting('account')]); }