Plugin Directory

Changeset 1258811


Ignore:
Timestamp:
10/03/2015 02:29:40 PM (10 years ago)
Author:
thumbar
Message:

admin page, persists settings, excerpt support

Location:
thumbar/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • thumbar/trunk/readme.txt

    r1257056 r1258811  
    55Requires at least: 2.6
    66Tested up to: 4.3
    7 Stable tag: 2.001
     7Stable tag: 3.000
    88License: GPLv2 or later
    99
     
    2626== Installation ==
    2727
    28 1. Download plugin (path will be /wp-content/plugins/thumbar/thumbar-wp.php).
     281. Download plugin and click on Activate Plugin.
    2929
    30 2. At Thumbar.com, click SIGN IN - JOIN to provide email where to send your plugin activation uid.
     302. At Thumbar.com, click SIGN IN - JOIN to provide email where to send your plugin activation User ID.
    3131
    32 3. In WordPress Dashboard / Plugins, under Thumbar click Edit, set uid="x" to your uid, and click Update File.
     323. Under WordPress Dashboard \ Settings \ Thumbar, set Thumbar User ID to your uid (sent in your signup email) and click Save Changes.
    3333
    34 4. Customize your up and down bar colors by changing uc=99cc99 and dc=ff9999, and click Update File.
     344. Optionally, customize your Up and Down Bar Colors and click Save Changes.
    3535
    36 5. Still in WordPress Dashboard / Plugins, under Thumbar click Activate.
    37 
    38 6. Refresh your blog's home page and rate one of your posts - done!
     365. Refresh your blog's home page and rate one of your posts - done!
    3937
    4038== Changelog ==
     
    195193= 2.001 =
    196194* flat security model
     195
     196= 3.000 =
     197* plugin admin page
     198* persists plugin settings
     199* supports excerpts
  • thumbar/trunk/thumbar-wp.php

    r1256068 r1258811  
    44Plugin URI: https://www.thumbar.com
    55Description: Rates your posts and mirrors them and their ratings in real time for free at Thumbar.com to maximize their exposure. Replaces search engines and SEO for generating traffic.
    6 Version: 2.000
     6Version: 3.000
    77Author: Thumbar, Inc.
    88Author URI: https://www.thumbar.com
    99*/
    1010
     11add_filter('the_excerpt', 'thumbar');
    1112add_filter('the_content', 'thumbar');
    1213add_action('init', 'register_tb_script');
    1314add_action('wp_footer', 'print_tb_script');
    1415
     16add_action('admin_init', 'tb_options_init');
     17add_action('admin_menu', 'tb_options_add_page');
     18
     19// Init plugin options to white list our options
     20function tb_options_init(){
     21  register_setting('wp_tb_options', 'tb_option', 'tb_options_validate');
     22}
     23
     24// Add menu page
     25function tb_options_add_page() {
     26  add_options_page('Thumbar Settings', 'Thumbar', 'manage_options', 'tb_options', 'tb_options_do_page');
     27}
     28
     29// Draw the menu page
     30function tb_options_do_page() {
     31    ?>
     32    <div class="wrap">
     33      <h2>Thumbar Settings</h2>
     34    <form method="post" action="options.php">
     35      <?php settings_fields('wp_tb_options'); ?>
     36      <?php $options = get_option('tb_option'); ?>
     37      <table class="form-table">
     38        <tr valign="top"><th scope="row">Thumbar User ID</th>
     39          <td><input type="text" name="tb_option[uid]" value="<?php echo $options['uid'] ? $options['uid'] : 'x'; ?>" /></td>
     40        </tr>
     41        <tr valign="top"><th scope="row">Up Bar Color</th>
     42          <td><input type="text" name="tb_option[uc]" value="<?php echo $options['uc'] ? $options['uc'] : '99cc99'; ?>" /></td>
     43        </tr>
     44        <tr valign="top"><th scope="row">Down Bar Color</th>
     45          <td><input type="text" name="tb_option[dc]" value="<?php echo $options['dc'] ? $options['dc'] : 'ff9999'; ?>" /></td>
     46        </tr>
     47      </table>
     48      <p class="submit">
     49      <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
     50      </p>
     51    </form>
     52  </div>
     53  <?php 
     54}
     55
     56// Sanitize input array and return sanitized array
     57function tb_options_validate($input) {
     58  // Our first value is either 0 or 1
     59  $input['option1'] = ( $input['option1'] == 1 ? 1 : 0 );
     60   
     61  // Say our second option must be safe text with no HTML tags
     62  $input['sometext'] =  wp_filter_nohtml_kses($input['sometext']);
     63 
     64  return $input;
     65}
     66
    1567function thumbar($content) {
    1668  global $add_tb_script;
     69  global $wp_query;
    1770
    18   $thumbar_add_on = '<style type="text/css"> .thumbar {margin:0px;border:0px;padding:0px;width:150px;height:25px;}</style><div class="thumbar" uid="x" uc=99cc99 dc=ff9999></div><br>';
     71  $options = get_option('tb_option');
     72
     73  $uid = $options['uid'];
     74  $uc  = $options['uc'];
     75  $dc  = $options['dc'];
     76  $post = $wp_query->post;
     77  $id = $post->ID;
     78  $shim = is_singular() ? '' : '<br>';
     79 
     80  $thumbar_add_on = '<style type="text/css"> .thumbar {margin:0px;border:0px;padding:0px;width:150px;height:25px;}</style>'.$shim.'<div class="thumbar" uid='.$uid.' uc="'.$uc.'" dc="'.$dc.'" id="tb-post-'.$id.'"></div><br>';
    1981  $theContent = $content.$thumbar_add_on;
    2082  $add_tb_script = true;
     
    3193
    3294  while (!$add_tb_script)
    33         return;
     95    return;
    3496
    3597  wp_print_scripts('tb-script');
Note: See TracChangeset for help on using the changeset viewer.