WordPress.org

Plugin Directory

Changeset 509618


Ignore:
Timestamp:
02/24/12 02:18:21 (2 years ago)
Author:
goldenapples
Message:

Version 0.4; bookmarklet, new options pages, and new sort options and display functions

Location:
recommended-links
Files:
10 added
1 deleted
15 edited
14 copied

Legend:

Unmodified
Added
Removed
  • recommended-links/tags/0.4/admin-functions.php

    r492236 r509618  
    44 
    55function reclinks_admin_pages() { 
    6 //  add_menu_page('Recommended Links Plugin Settings','RecLinks','activate_plugins','reclinks_plugin_settings','reclinks_plugin_settings',RECLINKS_DIRECTORY.'/images/icon16.png'); 
    76    add_submenu_page('edit.php?post_type=reclink',__( 'Recommended Links Plugin Settings', 'gad_reclinks' ),'Plugin Settings','activate_plugins','reclinks_plugin_settings','reclinks_plugin_settings'); 
    87} 
    98 
    109function reclinks_plugin_settings() { 
     10    $tabs = array( 
     11        'general' => __( 'General Settings', 'reclinks' ), 
     12        'archives' => __( 'Archive Pages', 'reclinks' ), 
     13        'bookmarklet' => __( 'Bookmarklet', 'reclinks' ), 
     14        'about' => __( 'About this plugin', 'reclinks' ) 
     15    ); 
     16    $page = ( isset($_GET['tab']) && in_array( $_GET['tab'], array_keys( $tabs ) ) ) ? $_GET['tab'] : 'general'; 
     17 
     18    $current_settings = get_option( 'reclinks_options' ); 
    1119    if ( !empty( $_POST ) && check_admin_referer( 'gad-reclinks-settings', '_wpnonce') ) 
    12         update_reclinks_settings(); 
     20        update_reclinks_settings( $page ); 
    1321    $current_settings = get_option( 'reclinks_plugin_options' ); 
    1422?> 
    1523    <div class="wrap"> 
    16         <h2><?php _e( 'Recommended Links Plugin Settings', 'gad_reclinks' ); ?></h2> 
     24<h2><?php _e( 'Recommended Links Plugin Settings', 'reclinks' ); ?></h2> 
     25 
     26<div id="icon-themes" class="icon32"><br /></div> 
     27<h3 class="nav-tab-wrapper"> 
     28<?php foreach ( $tabs as $tab => $title ) { 
     29    $tab_active_class = ( $tab == $page ) ? ' nav-tab-active' : ''; 
     30    echo '<a class="nav-tab'.$tab_active_class.'" href="?post_type=reclink&page=reclinks_plugin_settings&tab='.$tab.'">'; 
     31    echo $title; 
     32    echo '</a>'; 
     33} ?> 
     34</h3> 
     35        <?php if ( 'about' == $page ) { 
     36                require( 'admin/options-about.php' );  
     37            } else { ?> 
    1738        <form method="post"> 
    1839            <table class="form-table"> 
    19                 <tr> 
    20                     <th scope="row"> 
    21                         <label for="page_for_reclinks"><?php _e( 'Page for Recommended Links Archive:', 'gad_reclinks' ); ?></label> 
    22                     </th> 
    23                     <td> 
    24                         <?php wp_dropdown_pages( 
    25                             array( 
    26                                 'show_option_none' => __('None (use default archive)', 'gad_reclinks'), 
    27                                 'exclude' => array( get_option('page_for_posts') ), 
    28                                 'selected' => $current_settings['page_for_reclinks'] 
    29                             ) 
    30                         ); ?> 
    31     <p class="description"><?php _e( 'Note: if you choose a custom page to hold your archive, you can add content above the archive.<br>The page template you select will be used for styling purposes.', 'gad_reclinks' ); ?></p> 
    32                     </td> 
    33                 </tr> 
    34                 <tr> 
    35                     <th scope="row"> 
    36                         <label for="page_for_reclinks"><?php _e( 'Default Sort Order:', 'gad_reclinks' ); ?></label> 
    37                     </th> 
    38                     <td> 
    39                         <select id="sort_order" name="sort_order"> 
    40                             <?php $options = array(  
    41                                 'current' => __( 'Current: Top score this week', 'gad_reclinks' ), 
    42                                 'hot' => __( 'Hot: Top score in the past 24 hours', 'gad_reclinks' ), 
    43                                 'score' => __( 'Highest overall score', 'gad_reclinks' ), 
    44                                 'newest' => __( 'Most recently submitted', 'gad_reclinks' ) 
    45                             ); 
    46                             foreach ( $options as $opt => $descrip ) { 
    47                                 echo '<option value="'.$opt.'" '.selected( $opt, $current_settings['sort_order'], 0 ).'>'.$descrip.'</option>'; 
    48                             } ?> 
    49                         </select> 
    50                     </td> 
    51                 </tr> 
    52         <tr> 
    53             <th scope="row"> 
    54                 <label for="taxonomies"><?php _e( 'Taxonomies to enable for recommended links:', 'gad_reclinks' ); ?></label> 
    55             </th> 
    56             <td> 
    57             <?php $taxes = get_taxonomies( null, 'objects' ); 
    58                     foreach ($taxes as $name => $tax)  
    59                         if (!in_array( $name, array( 'nav_menu', 'link_category', 'post_format' ) ) ) 
    60                             echo '<p><input type="checkbox" name="tax['.$name.']" '.checked( ( isset( $current_settings['tax'][$name] ) && $current_settings['tax'][$name] ), true, false ).'> '.$tax->labels->name .'</p>'; 
    61             ?> 
    62             </td> 
    63         </tr> 
    64             <tr> 
    65                 <th scope="row"> 
    66                     <label><?php _e( 'User registration options:', 'gad_reclinks' ); ?></label> 
    67                 </th> 
    68                 <td> 
    69                     <p> 
    70                         <input type="checkbox" name="allow-unregistered-vote" <?php checked( $current_settings['allow-unregistered-vote'] ); ?>/> 
    71                         <label for="allow-unregistered-vote"><?php _e( 'Allow unregistered users to vote?', 'gad_reclinks' ); ?></label> 
    72                         <br><span class="description"><?php _e('(Votes will be logged by IP address.)', 'gad_reclinks' ); ?></span> 
    73                     </p> 
    74 <!--- 
    75                     <p> 
    76                         <input type="checkbox" name="allow-unregistered-post" <?php checked( $current_settings['allow-unregistered-post'] ); ?>/> 
    77                         <label for="allow-unregistered-post"><?php _e( 'Allow unregistered users to post new links?', 'gad_reclinks' ); ?></label> 
    78                     </p> 
    79 --> 
    80                 </td> 
    81             </tr> 
    82         <tr> 
    83             <th scope="row"> 
    84                 <label><?php _e( 'Comments:', 'gad_reclinks' ); ?></label> 
    85             </th> 
    86             <td> 
    87                 <p> 
    88                     <input type="checkbox" name="vote-on-comments" <?php checked( $current_settings['vote-on-comments'] ); ?> /> 
    89                     <label for="vote-on-comments"><?php _e( 'Enable voting / points tally on comments?', 'gad_reclinks' ); ?></label> 
    90                 </p> 
    91             </td> 
    92         </tr> 
    93         <tr> 
    94             <th></th> 
    95             <td> 
    96                 <?php wp_nonce_field( 'gad-reclinks-settings' ); ?> 
    97                 <p> 
    98                     <input type="submit" class="button-primary" value="Save changes"/> 
    99                 </p> 
    100             </td> 
    101         </tr> 
     40            <?php require( "admin/options-$page.php" ); ?> 
    10241            </table> 
    10342        </form> 
     43    <?php } ?> 
    10444    </div> 
    10545 
     
    10747} 
    10848 
    109 function update_reclinks_settings() { 
     49function update_reclinks_settings( $page ) { 
    11050 
    111     // needs sanitization and whitelisting, of course 
    112     // this is just bare minimum 
    113     update_option( 'reclinks_plugin_options',  
    114         array( 
    115             'page_for_reclinks' => intval( $_POST['page_id'] ), 
    116             'sort_order' => $_POST['sort_order'], 
    117             'tax' => ( isset( $_POST['tax'] ) ) ? $_POST['tax'] : array(), 
    118             'allow-unregistered-vote' => (isset($_POST['allow-unregistered-vote']) && true == $_POST['allow-unregistered-vote']), 
    119             'allow-unregistered-post' => (isset($_POST['allow-unregistered-post']) && true == $_POST['allow-unregistered-post']), 
    120             'vote-on-comments' => (isset($_POST['vote-on-comments']) && true == $_POST['vote-on-comments']), 
     51    $settings = get_option( 'reclinks_plugin_options' ); 
     52 
     53    switch ( $page ) : 
     54        case 'general': 
     55            $settings['page_for_reclinks'] = intval( $_POST['page_id'] ); 
     56            $settings['sort_order'] = $_POST['sort_order']; 
     57            $settings['tax'] = ( isset( $_POST['tax'] ) ) ? $_POST['tax'] : array(); 
     58            $settings['allow-unregistered-vote'] = (isset($_POST['allow-unregistered-vote']) && true == $_POST['allow-unregistered-vote']); 
     59            $settings['allow-unregistered-post'] = (isset($_POST['allow-unregistered-post']) && true == $_POST['allow-unregistered-post']); 
     60            $settings['vote-on-comments'] = (isset($_POST['vote-on-comments']) && true == $_POST['vote-on-comments']); 
    12161 
    12262            // no UI for this yet, but its gotta be in there 
    123             'vote-values' => array( 
     63            $settings['vote-values'] = array( 
    12464                'minus' => array( 'value' => -1, 'text' => '-' ), 
    12565                'plus' => array( 'value' => 1, 'text' => '+' ) 
    126             ), 
    127         ) 
    128     ); 
     66            ); 
     67            break; 
     68        case 'bookmarklet': 
     69            $settings['bookmarklet_text'] = sanitize_text_field( $_POST['bookmarklet_text'] ); 
     70            $settings['bookmarklet_class'] = sanitize_text_field( $_POST['bookmarklet_class'] ); 
     71            $settings['bookmarklet_header'] = wp_kses_post( $_POST['bookmarklet_header'] ); 
     72            break; 
     73        default: 
     74            break; 
     75    endswitch; 
     76 
     77    update_option( 'reclinks_plugin_options', $settings ); 
     78 
    12979    echo '<div id="message" class="messages updated"><p>Plugin settings updated!</p></div>'; 
    13080} 
     
    178128    return $vars; 
    179129} 
     130 
     131/** 
     132 * Added meta boxes for edit-post?post_type=reclink screen 
     133 * 
     134 */ 
     135function reclinks_edit_screen_metaboxes() { 
     136    add_meta_box( 'reclinkurl', __( 'Link URL', 'reclinks'), 'reclinks_URL_metabox', 'reclink', 'normal', 'core' ); 
     137} 
     138 
     139function reclinks_URL_metabox() { 
     140    global $post; 
     141    $href = get_post_meta( $post->ID, '_href', true ); 
     142    wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' ); 
     143    echo '<input name="_href" type="url" class="regular-text" style="width: 98%" value="'.$href.'">'; 
     144} 
     145 
     146add_action( 'save_post', 'save_edited_reclink_href' ); 
     147 
     148function save_edited_reclink_href( $post_ID ) { 
     149    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 
     150        return; 
     151 
     152    if ( 'reclink' === $_POST['post_type'] ) 
     153        update_post_meta( $post_ID, '_href', $_POST['_href'] ); 
     154 
     155} 
  • recommended-links/tags/0.4/ajax-functions.php

    r492236 r509618  
    3838 
    3939        $votesuccess = gad_add_reclink_vote( $_POST['reclink'], $comment, $vote, $current_user->ID, $_SERVER['REMOTE_ADDR'] ); 
     40    } 
     41 
     42    if ( 'submitlink' === $_GET['action'] ) { 
     43        add_filter( 'show_admin_bar', '__return_false' ); 
     44        reclinks_bookmarklet_request(); 
     45        exit; 
    4046    } 
    4147 
     
    8591} 
    8692 
    87 // Not currently used; but here in case the YQL solution proves too clow, or unreliable 
     93// Not currently used; but here in case the YQL solution proves too slow, or unreliable 
    8894add_action( 'wp_ajax_check_reclink_title', 'gad_reclinks_check_link_title' ); 
    8995add_action( 'wp_ajax_nopriv_check_reclink_title', 'gad_reclinks_check_link_title' ); 
     
    105111    die( json_encode( $return ) ); 
    106112 
     113} 
    107114 
     115 
     116/** 
     117 * On template redirect, checks for the presence of the "action=submitlink" query 
     118 * arg (IE, a request originating from the bookmarklet), and, if present, skips the 
     119 * usual template hierarchy and only displays the "Add Link" form. 
     120 *  
     121 */ 
     122 
     123 
     124function reclinks_bookmarklet_request() { 
     125 
     126    define( 'IFRAME_REQUEST', true ); 
     127 
     128    if ( !is_user_logged_in() ) { 
     129        $current_request = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']; 
     130        wp_redirect( add_query_arg(  
     131            array( 'msg' => 'bookmarklets-login' ), 
     132            wp_login_url( $current_request ) ) 
     133        ); 
     134        exit; 
     135    } 
     136     
     137    header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 
     138?> 
     139<html> 
     140    <head> 
     141        <title><?php wp_title('Submit Recommended Link'); ?></title> 
     142        <?php wp_head(); ?> 
     143        <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> 
     144        <script type="text/javascript"> 
     145            jQuery(document).ready(function($){ 
     146                reclink = { 
     147                    url: '<?php echo $_GET['u']; ?>', 
     148                    title: '<?php echo $_GET['t']; ?>', 
     149                    description: '<?php echo $_GET['s']; ?>' 
     150                } 
     151                $('#reclink_URL').val(reclink.url); 
     152                $('#reclink_title').val(reclink.title); 
     153                $('#reclink_description').val(reclink.description); 
     154            }); 
     155        </script> 
     156    </head> 
     157    <body> 
     158        <div class="widget widget_addLink_form"> 
     159            <?php output_addlink_form( true ); ?> 
     160        </div> 
     161    </body> 
     162</html> 
     163<?php 
     164    die(0); 
    108165} 
  • recommended-links/tags/0.4/display-filters.php

    r492388 r509618  
    5555    $sort_order = ( isset( $plugin_settings['sort_order'] ) ) ? $plugin_settings['sort_order'] : 'current'; 
    5656 
     57    if ( isset( $query->query_vars['reclinks_sort'] ) && in_array( 
     58            $query->query_vars['reclinks_sort'],  
     59            array( 'newest', 'hot', 'current', 'score', 'controversial' ) ) ) 
     60        $sort_order = $query->query_vars['reclinks_sort']; 
     61 
    5762    if ( isset( $_GET['sort'] ) && in_array( 
    5863            $_GET['sort'],  
    59             array( 'newest', 'hot', 'current', 'score' ) ) ) 
     64            array( 'newest', 'hot', 'current', 'score', 'controversial' ) ) ) 
    6065        $sort_order = $_GET['sort']; 
    61  
    62     if ( isset( $query->query_vars['reclinks_sort'] ) && in_array( 
    63             $query->query_vars['reclinks_sort'],  
    64             array( 'newest', 'hot', 'current', 'score' ) ) ) 
    65         $sort_order = $query->query_vars['reclinks_sort']; 
    6666 
    6767    switch ( $sort_order ) : 
     
    8282            add_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
    8383            add_filter( 'posts_join', 'gad_reclinks_votes_join_hot' ); 
     84            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     85            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     86            add_action( 'the_posts', 'gad_remove_custom_filters' ); 
     87            break; 
     88        case 'controversial': 
     89            add_filter( 'posts_fields', 'gad_reclinks_posts_fields_absval' ); 
     90            add_filter( 'posts_join', 'gad_reclinks_votes_join_current' ); 
    8491            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
    8592            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     
    110117} 
    111118 
     119function gad_reclinks_posts_fields_absval( $fields ) { 
     120    global $wpdb; 
     121    $fields = str_replace( "{$wpdb->posts}.*", "{$wpdb->posts}.*, SUM( ABS( {$wpdb->reclinkvotes}.vote ) ) AS post_vote ", $fields ); 
     122    return $fields; 
     123} 
     124 
    112125function gad_reclinks_votes_join_hot( $join ) { 
    113126    return $join . gad_reclinks_votes_join( '1 DAY' ); 
     
    218231} 
    219232 
     233function reclinks_favicon( $echo = true ) { 
     234    $domain = reclinks_domain( false, '', '' ); 
     235    if ( empty( $domain ) ) return false; 
     236    $favicon = '<img class="reclink-favicon" src="http://www.google.com/s2/favicons?domain='.$domain.'" alt="'.$domain.'">'; 
     237    if ( $echo ) 
     238        echo $favicon; 
     239    else 
     240        return $favicon; 
     241} 
    220242 
    221243/** 
     
    279301 
    280302} 
     303 
  • recommended-links/tags/0.4/display-shortcodes.php

    r489412 r509618  
    11<?php 
    22 
     3/** 
     4 * @function    output_addlink_form 
     5 * 
     6 * Outputs or returns html markup for the "Add Link" form. 
     7 * Called by the shortcode `reclink_addform` as well as by the Add Link widget, 
     8 * and can be called directly by theme or bookmarklet. 
     9 * 
     10 * @param   bool    Whether to echo (true) or return (false). 
     11 * 
     12 */ 
    313add_shortcode( 'reclink_addform', 'output_addlink_form' ); 
    414 
     
    818?> 
    919    <form class="reclinks_addlink" action="<?php echo add_query_arg( 'action', 'reclink-add' ); ?>" method="POST"> 
    10         <label for="reclink_URL"><?php _e('Link URL', 'gad_reclinks'); ?></label> 
    11         <input type="text" name="reclink_URL" id="reclink_URL" /> 
    12         <label for="reclink_title"><?php _e('Link Title', 'gad_reclinks'); ?></label> 
    13         <input type="text" name="reclink_title" id="reclink_title" /> 
    14         <label for="reclink_description"><?php _e('Link Description', 'gad_reclinks'); ?></label> 
    15         <textarea id="reclink_description" name="reclink_description" rows="10" cols="30" ></textarea> 
     20        <div class="reclink_form_field"> 
     21            <label for="reclink_URL"><?php _e('Link URL', 'gad_reclinks'); ?></label> 
     22            <input type="text" name="reclink_URL" id="reclink_URL" /> 
     23        </div> 
     24        <div class="reclink_form_field"> 
     25            <label for="reclink_title"><?php _e('Link Title', 'gad_reclinks'); ?></label> 
     26            <input type="text" name="reclink_title" id="reclink_title" /> 
     27        </div> 
     28        <div class="reclink_form_field"> 
     29            <label for="reclink_description"><?php _e('Link Description', 'gad_reclinks'); ?></label> 
     30            <textarea id="reclink_description" name="reclink_description" rows="10" cols="30" ></textarea> 
     31        </div> 
    1632<?php if ( isset( $plugin_settings['tax'] ) && is_array( $plugin_settings['tax'] ) ) { 
    1733    foreach ( $plugin_settings['tax'] as $tax => $on ) { 
    1834        $t = get_taxonomy( $tax ); 
    19         echo '<p><label for="reclink_taxes['.$tax.']">'.$t->labels->name.'</label>'; 
     35        echo '<div class="reclink_form_field">'; 
     36        echo '<label for="reclink_taxes['.$tax.']">'.$t->labels->name.'</label>'; 
    2037        wp_dropdown_categories(  
    2138            array(  
     
    2744            ) 
    2845        );   
    29         echo '</p>'; 
     46        echo '</div>'; 
    3047    } 
    3148} ?> 
     
    3653    ob_end_clean(); 
    3754    if ( $echo === true ) echo $output; else return $output; 
     55} 
     56 
     57 
     58/** 
     59 * @function    reclinks_bookmarklet 
     60 * 
     61 * Displays a button for the Add Link bookmarklet and outputs the javascript  
     62 * necessary for the bookmarklet. 
     63 * 
     64 * Based loosely on the internals of the Press This bookmarklet, but all of the work 
     65 * is done front-end so there's no need to load admin scripts, etc. 
     66 * 
     67 * @param   bool    true: echoes bookmarklet, false: returns it. 
     68 */ 
     69 
     70add_shortcode( 'reclink_bookmarklet', 'reclinks_bookmarklet' ); 
     71 
     72function reclinks_bookmarklet( $echo = false ) { 
     73    $plugin_settings = get_option( 'reclinks_plugin_options' ); 
     74    $submit_link_url = add_query_arg( array( 'action' => 'submitlink' ), home_url() ); 
     75    $button_text = isset( $plugin_settings['bookmarklet_text'] ) ? $plugin_settings['bookmarklet_text'] : get_bloginfo('title') .' bookmarklet'; 
     76    $button_class = isset( $plugin_settings['bookmarklet_class'] ) ? $plugin_settings['bookmarklet_class'] : 'reclinks-bookmarklet'; 
     77    if ( !empty( $plugin_settings['button-class'] ) ) $button_class .= " " . trim( $plugin_settings['button-class'] ); 
     78    $button = <<<HTML 
     79<p class="{$button_class}"> 
     80<a onclick="return false;" oncontextmenu="if(window.navigator.userAgent.indexOf('WebKit')!=-1||window.navigator.userAgent.indexOf('MSIE')!=-1)jQuery('.reclinks-bookmarklet-code').show().find('textarea').focus().select();return false;" href="javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='{$submit_link_url}',l=d.location,e=encodeURIComponent,u=f+'&u='+e(l.href)+'&amp;t='+e(d.title)+'&amp;s='+e(s)+'&amp;v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)"><span>$button_text</span></a> 
     81</p> 
     82HTML; 
     83    if ( $echo ) echo $button; 
     84    else return $button; 
    3885} 
    3986 
     
    150197    } 
    151198} 
     199 
     200/** 
     201 * Shortcode to display buttons for different sort options 
     202 * 
     203 * Usage:   [reclink_sort_options]  
     204 *              to show buttons for all four sorting options, with default text 
     205 *          [reclink_sort_options show="newest,current,score" score="All time best"] 
     206 *              will show only buttons for newest, current, and score, and will use 
     207 *              "All time best" as the text for the "score" button rather than "Top Score" 
     208 */ 
     209add_shortcode( 'reclink_sort_options', 'reclink_sort_options' ); 
     210 
     211function reclink_sort_options( $args = null ) { 
     212    $defaults = array( 
     213        'base_url'      => false, 
     214        'show'          => 'hot,current,newest,controversial,score', 
     215        'hot'           => __( 'Hot', 'reclinks' ), 
     216        'current'       => __( 'Current', 'reclinks' ), 
     217        'newest'        => __( 'Newest', 'reclinks' ), 
     218        'controversial' => __( 'Controversial', 'reclinks' ), 
     219        'score'         => __( 'Top Score', 'reclinks' ) 
     220    ); 
     221    $args = wp_parse_args( $args, $defaults ); 
     222    $links = explode( ',' , $args['show'] ); 
     223     
     224    $plugin_settings = get_option( 'reclinks_plugin_options' ); 
     225    $archive_page = ( isset( $plugin_settings['page_for_reclinks'] ) ) ? 
     226        get_permalink( $plugin_settings['page_for_reclinks'] ) : get_post_type_archive_link( 'reclink' ); 
     227    if ( $args['base_url'] )  
     228        $archive_page= $args['base_url']; 
     229 
     230    $return = '<form class="reclinks-sort-options" action="'.$archive_page.'" method="get" >'; 
     231    foreach ( $links as $link ) 
     232        $return .= '<button class="reclinks-sort reclinks-sort-'.$link.'" name="sort" value="'.$link.'">'.$args[$link].'</button>'; 
     233    $return .= '</form>'; 
     234 
     235    return $return; 
     236} 
  • recommended-links/tags/0.4/js/reclinks-scripts.coffee

    r489412 r509618  
    3030    $('#reclink_URL').bind 'change', (event) -> 
    3131        linkUrl = $(this).val() 
     32        if linkUrl is '' return false 
    3233        $.ajax 'http://query.yahooapis.com/v1/public/yql', 
    3334            type: 'get', 
    3435            data: { 
    35                 q: "use 'http://www.datatables.org/data/htmlstring.xml' as htmlstring; select * from htmlstring where url='#{ linkUrl }'", 
     36                q: "select * from html where url='#{ linkUrl }' and xpath='/html/head/title'", 
    3637                format: 'json' 
    3738                }, 
     
    4243                    alert reclinks.messages_error404 
    4344                    return false 
    44                 title = response.result.match( /<\s*title\s*>([^<]*)<\/title>/ )[1] 
     45                title = response.title 
    4546                unless title 
    4647                    alert reclinks.messages_errorNoTitle 
  • recommended-links/tags/0.4/js/reclinks-scripts.js

    r489412 r509618  
    4545        type: 'get', 
    4646        data: { 
    47           q: "use 'http://www.datatables.org/data/htmlstring.xml' as htmlstring; select * from htmlstring where url='" + linkUrl + "'", 
     47          q: "select * from html where url='" + linkUrl + "' and xpath='/html/head/title|/html/head/link[@rel=\"icon\"]|/html/head/link[@rel=\"shortcut icon\"]'", 
    4848          format: 'json' 
    4949        }, 
     
    5656            return false; 
    5757          } 
    58           title = response.result.match(/<\s*title\s*>([^<]*)<\/title>/)[1]; 
     58          title = response.title; 
    5959          if (!title) { 
    6060            alert(reclinks.messages_errorNoTitle); 
  • recommended-links/tags/0.4/loop-reclinks.php

    r489412 r509618  
    2525    <?php while ( have_posts() ) : the_post(); ?> 
    2626        <li> 
     27            <?php reclinks_favicon(); ?> 
    2728            <?php reclink_terms(); ?> 
    2829            <strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong>  
    29             <small><?php reclinks_domain(); ?><small> 
     30<!--        <small><?php reclinks_domain(); ?><small>  --> 
    3031            <br /><?php reclinks_votebox(); ?> 
    3132        </li> 
  • recommended-links/tags/0.4/plugin-activation.php

    r489412 r509618  
    5858function reclinks_db_option_upgrade( $from ) { 
    5959 
    60     if ( $from === 4 ) return; 
     60    if ( $from === 5 ) return; 
    6161 
    6262    $old_settings = ( $from ) ? get_option( 'reclinks_plugin_options' ) : array(); 
    6363 
    64     /* DB version 4, reflects plugin version 0.4. Includes 'vote-on-comments' settings. */ 
     64    /* DB version 5, reflects plugin version 0.4early. Introduces bookmarklet settings options. 
     65    /* DB version 4, reflects plugin version 0.4early. Includes 'vote-on-comments' settings. */ 
    6566    /* DB version 3, reflects plugin version 0.3. Includes 'tax' string. */ 
    6667    $reclinks_plugin_defaults = array( 
     
    7475        'allow-unregistered-post' => false, 
    7576        'vote-on-comments' => true, 
    76         'tax' => array() 
     77        'tax' => array(), 
     78        'bookmarklet_text' => sprintf( __( 'Post to %s', 'reclinks' ), get_option( 'blogname' ) ), 
     79        'bookmarklet_class' => 'reclinks-bookmarklet', 
     80        'bookmarklet_header' => '' 
    7781    ); 
    7882 
     
    8084 
    8185    update_option( 'reclinks_plugin_options', $options_to_set ); 
    82     update_option( 'reclinks_db_version', 4 ); 
     86    update_option( 'reclinks_db_version', 5 ); 
    8387 
    8488} 
  • recommended-links/tags/0.4/readme.txt

    r492388 r509618  
    55Requires at least: 3.2.1 
    66Tested up to: 3.3.1 
    7 Stable tag: 0.3.5 
     7Stable tag: 0.4 
    88 
    99A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them. 
     
    1111== Description == 
    1212 
    13 This is the beginning of what I hope will be a much more ambitious project. If you want to try this out, please give me feedback. 
     13This plugin aims to support community link-sharing, social bookmarking, and discussion of links in the WordPress environment.  
     14 
     15This is still at an early stage of what I hope will be a much more ambitious project. If you want to try this out, please give me feedback. 
    1416 
    1517I will guarantee backwards compatibility with all data saved by the plugin, so it should be safe to install and activate, and as I add features, your existing posts and links will work with them just fine. 
    1618 
    17 == Installation == 
    18  
    19 1. Upload the entire `recommended-links/` folder to the `/wp-content/plugins/` directory. 
    20 1. Activate the plugin through the 'Plugins' menu in WordPress. 
    21 1. A plugin options page is included under the "Recommended Links" admin menu, where you can select some basic settings. 
    22 1. Include the 'Reclinks Add Link Form' widget in a sidebar (or anywhere). Alternately, you can use the shortcode `[reclinks_addlinkform]` in any page or post. 
    23 1. Any links added through this widget show up in the archive for the custom post type "Recommended Links". You can also create a new page and set that page to show your links on the plugin options page. 
    24 1. If you have permalinks enabled, the archive will be displayed at `http://yoursite.tld/reclinks`; otherwise it will be at `http://yoursite.tld?post_type=reclink`.  
    25 1. The plugin tries to intelligently filter markup so that it can work with most themes out of the box. If the archive or single link display doesn't work in your theme, you may have to create an `archive-reclink.php` or `single-reclink.php` template file. _(See the FAQ for examples of markup for these template files)_. 
    26 1. See the [plugin wiki](https://github.com/goldenapples/recommended-links/wiki) for troubleshooting and customization instructions. 
    27  
    28 == Frequently Asked Questions == 
    29  
    30 = How can I customize the markup of the list of "Recommended Links"? = 
    31  
    32 __If you are using the default post type archive__, WordPress will search in your theme directory for a file called `archive-reclinks.php`. If thats not found, it will fall back along the usual WordPress [template hierarchy](http://codex.wordpress.org/Template_Hierarchy). The easiest way to begin customizing your output is to copy your existing `archive.php` or `index.php` to a file called `archive-reclinks.php` and begin making changes to it. 
    33  
    34 __If you have selected an existing page to hold your archive__, WordPress will use the template assigned to that page for the page layout, and the loop defined in the `loop_reclinks.php` file in the plugin directory to mark up the list of recommended links. To make changes to the `loop-reclinks.php` (which also affects the output of the recommended links list widget), copy it to your theme directory and edit it there. 
    35  
    36 __Individual recommended link posts__ are handled by WordPress's normal template hierarchy in your theme. If you want to change their markup and layout, create a file in your theme directory called `single-reclink.php` (or copy your `single.php` file and rename it to `single-reclink.php`) and begin editing. 
    37  
    38 = What sorting options are there? = 
    39  
    40 Currently this plugin supports sorting of archive pages by a "sort" parameter passed via query string. The options allowed are: 
    41  
    42 * **newest** Sort links by posted time, most recently first 
    43 * **hot** Sort links by votes over the past day 
    44 * **current** Sort by votes over the past week 
    45 * **score** Sort by total vote score over time 
    46  
    47 So for example, with permalinks enabled, the URL `yoursite.tld/reclinks/?sort=hot` would display a page of the 25 links with the highest vote score over the past day. 
    48  
    49 You can also set a default sort order from the plugin settings page. The query string argument, if present, overrides the default value. So if your default sorting is **current**, you can still give your users a chance to view top voted links of all time by giving them a link to `yoursite.tld/reclinks/?sort=score`. 
    50  
    51 = What markup does the plugin offer? = 
    52  
    53 This plugin filters `the_permalink` to display the link submitted. A typical archive page, where the post title is wrapped in markup like 
    54 `<a href=<?php the_permalink(); ?>"><?php the_title(); ?></a>` 
    55 will display the title of the submitted link, linking to that link itself. 
    56  
    57 If you want to access the permalink of the comments page on your site, use `get_permalink()` instead. 
    58  
    59 By default, this plugin filters both `the_content` and `comment_text` to add vote buttons and current score box above the post/comment content. If you want to display these in a different position, you can unhook those filters and use the template tag `reclinks_votebox()` in your template files wherever you want the vote box to display. 
    60  
    61 There are not many special display features yet. A partial listing: 
    62  
    63 * `reclink_domain()` echoes the host of the link submitted - give people a chance to know what they're getting themselves into before they follow a link.  
    64 * `reclink_votebox()` echoes a div with +/- vote buttons, the current score, author, and human time diff'd post date 
    65 * `author_karma( $user )` returns a user's total karma score 
    66  
    67  
     19See the plugin's [wiki page on github](https://github.com/goldenapples/recommended-links/wiki) for more up-to-date documentation (its hard to keep documentation updated in multiple places). 
    6820 
    6921== Changelog == 
     22 
     23= 0.4 = 
     24 
     25This update fleshes out a number of functions that were introduced in earlier versions, and introduces a bookmarklet that can be used for easier submission of links. 
    7026 
    7127= 0.3.5 = 
     
    11773== Upgrade Notice == 
    11874 
    119 = 0.3.5 = 
    120  
    121 Fixed term archive pages; also fixed the loop on archive pages so it doesn't mess up any secondary loops on the page. 
    122  
    123 = 0.3.4 = 
    124  
    125 I broke posting of new links in the last update (0.3.3)... this is just a quick fix to correct that. More changes to come soon. 
    126  
    127 = 0.3.3 =  
    128 This update fixes several bugs that were pointed out (time zone setting, posts showing up as from "anonymous", update messages not defined), and adds an option to disable voting on comments. It also styles the +1/-1 buttons a bit - skins for the style will be selectable and overridable by version 0.4, but just for now I was tired of seeing the unstyled buttons. 
    129  
    130 = 0.3 = 
    131 This version includes a plugin settings page, as well as multiple new features: 
    132  
    133 = 0.2.2 = 
    134 Added a widget to display the most recently posted links in the sidebar. Also, fixed some minor javascript and css errors. 
    135  
    136 = 0.2.1 = 
    137 Implemented four new sorting options to the recommended links archive page: "newest", "hot", "current", and "score". 
     75= 0.4 = 
     76This update introduces a bookmarklet that can be used for easier submission of links, and some other features. 
  • recommended-links/tags/0.4/reclinks-styles.css

    r489412 r509618  
    2828.votelink.votelink-minus:hover { background-position: -28px -14px; } 
    2929.votelink.votelink-plus:hover { background-position: -42px -14px; } 
     30 
     31/* Bookmarklet default styles */ 
     32 
     33.reclinks-bookmarklet { 
     34    margin: 20px 0; 
     35    position: relative; 
     36} 
     37 
     38.reclinks-bookmarklet a { 
     39    display: inline-block; 
     40    padding-right: 12px; 
     41    position: relative; 
     42    cursor: move; 
     43    color: #333; 
     44    background: #dfdfdf; 
     45    background-image: -webkit-gradient( 
     46        linear, 
     47        left bottom, 
     48        left top, 
     49        color-stop(0.07, rgb(230,230,230)), 
     50        color-stop(0.77, rgb(216,216,216)) 
     51    ); 
     52    background-image: -moz-linear-gradient( 
     53        center bottom, 
     54        rgb(230,230,230) 7%, 
     55        rgb(216,216,216) 77% 
     56    ); 
     57    background-repeat: no-repeat; 
     58    background-image-position: 10px 8px; 
     59    -webkit-border-radius: 5px; 
     60    border-radius: 5px; 
     61    border: 1px #b4b4b4 solid; 
     62    font-style: normal; 
     63    line-height: 16px; 
     64    font-size: 14px; 
     65    text-decoration: none; 
     66    text-shadow: #fff 0 1px 0px; 
     67} 
     68 
     69.reclinks-bookmarklet a:hover, 
     70.reclinks-bookmarklet a:active { 
     71    color: #333 
     72} 
     73 
     74.reclinks-bookmarklet a:hover:after { 
     75    transform: skew(20deg) rotate(9deg); 
     76    -webkit-transform: skew(20deg) rotate(9deg); 
     77    -moz-transform: skew(20deg) rotate(9deg); 
     78    box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); 
     79    -webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); 
     80    -moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); 
     81} 
     82 
     83.reclinks-bookmarklet a span { 
     84    background: url(../../../wp-admin/images/press-this.png) no-repeat -45px 5px ; 
     85    padding: 8px 8px 8px 32px; 
     86    display: inline-block; 
     87} 
     88 
     89.reclinks-bookmarklet a:after { 
     90    content: ''; 
     91    width: 70%; 
     92    height: 55%; 
     93    z-index: -1; 
     94    position: absolute; 
     95    right: 10px; 
     96    bottom: 9px; 
     97    background: transparent; 
     98    transform: skew(20deg) rotate(6deg); 
     99    -webkit-transform: skew(20deg) rotate(6deg); 
     100    -moz-transform: skew(20deg) rotate(6deg); 
     101    box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); 
     102    -webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); 
     103    -moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); 
     104} 
     105 
     106.reclink-favicon { vertical-align: middle; } 
  • recommended-links/tags/0.4/recommended-links.php

    r492388 r509618  
    55Description: A "reddit clone" that runs in Wordpress. 
    66Author: Nathaniel Taintor 
    7 Version: 0.3.5 
     7Version: 0.4 
    88Author URI: http://goldenapplesdesign.com 
    99*/ 
     
    7373        'rewrite' => array(  
    7474            'slug' => 'link' 
    75         ) 
     75        ), 
     76        'register_meta_box_cb' => 'reclinks_edit_screen_metaboxes' 
    7677    ); 
    7778 
     
    9091function gad_check_db_tables() { 
    9192    $v = get_option( 'reclinks_db_version' ); 
    92     if ( !$v || $v < 4 ) 
     93    if ( !$v || $v < 5 ) 
    9394        reclinks_db_option_upgrade( $v ); 
    9495} 
     
    170171            $terms_array = array_map( 'intval', (array)$terms ); 
    171172            $test = wp_set_object_terms( $link_ID, $terms_array, $tax ); 
    172             error_log( 'Setting terms on '.$link_ID.': '.print_r( $test ) ); 
     173//          error_log( 'Setting terms on '.$link_ID.': '.print_r( $test ) ); 
    173174        } 
    174175 
  • recommended-links/tags/0.4/user-functions.php

    r482847 r509618  
    3737    if ( 'reclinks-login' === $_GET['msg'] ) { 
    3838        $message = '<p class="message">'.__( 'You must be logged in to vote.', 'gad_reclinks' ) .'</p>'; 
     39        return $message; 
     40    } 
     41    if ( 'bookmarklets-login' === $_GET['msg'] ) { 
     42        $message = '<p class="message">'.__( 'Please <b>log in</b> to submit this link.', 'gad_reclinks' ) . '</p>'; 
    3943        return $message; 
    4044    } 
  • recommended-links/tags/0.4/widgets.php

    r486514 r509618  
    170170 
    171171    register_widget('RecLinks_Display_Links'); 
     172 
     173 
     174    /* 
     175     * Widget for displaying bookmarklet button. 
     176     * 
     177     * ALso includes textarea where site owners can include description 
     178     * and instructions, etc. 
     179     * 
     180     */ 
     181    class RecLinks_Bookmarklet extends WP_Widget { 
     182 
     183        function RecLinks_Bookmarklet() { 
     184        //Constructor 
     185            $widget_ops = array( 
     186                'classname' => 'widget_reclinks_bookmarklet', 
     187                'description' => 'Display a bookmarklet that your users can drag to their address bar' 
     188            ); 
     189            $this->WP_Widget('reclinks_bookmarklet', 'RecLinks Bookmarklet Form', $widget_ops); 
     190        } 
     191 
     192        function widget($args, $instance) { 
     193        // prints the widget 
     194            if ( !current_user_can('add_reclink') ) 
     195                return; 
     196            extract($args, EXTR_SKIP); 
     197            echo $before_widget; 
     198            $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); 
     199            $entry_title = empty($instance['entry_title']) ? ' ' : apply_filters('widget_entry_title', $instance['entry_title']); 
     200            if ( !empty( $title ) )  
     201                echo $before_title . $title . $after_title; 
     202 
     203            echo reclinks_bookmarklet(); 
     204 
     205            if ( !empty( $description ) ) 
     206                echo '<p>' . $description . '</p>'; 
     207 
     208            echo $after_widget; 
     209        } 
     210 
     211        function update($new_instance, $old_instance) { 
     212            //save the widget 
     213            $instance = $old_instance; 
     214            $instance['title'] = sanitize_text_field($new_instance['title']); 
     215            $instance['description'] = wp_filter_post_kses($new_instance['description']); 
     216            return $instance; 
     217        } 
     218 
     219        function form($instance) { 
     220            //widgetform in backend 
     221            $instance = wp_parse_args(  
     222                (array) $instance,  
     223                array( 'title' => '' ) ); 
     224                $title = strip_tags($instance['title']); 
     225                ?> 
     226                <p> 
     227                    <label for="<?php echo $this->get_field_id('title'); ?>">Title: </label> 
     228                    <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> 
     229                </p> 
     230                <p>                  
     231                    <label for="<?php echo $this->get_field_id('description'); ?>">Description: </label> 
     232                    <textarea id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" rows="10" cols="30"><?php echo esc_textarea( $description ); ?></textarea> 
     233                    <span class="description">(Give your users an idea of how to use the bookmarklet, or instructions, etc.)</span> 
     234                </p> 
     235                <?php 
     236                } 
     237        } 
     238 
     239    register_widget( 'RecLinks_Bookmarklet' ); 
    172240} 
    173241 
  • recommended-links/trunk/admin-functions.php

    r492236 r509618  
    44 
    55function reclinks_admin_pages() { 
    6 //  add_menu_page('Recommended Links Plugin Settings','RecLinks','activate_plugins','reclinks_plugin_settings','reclinks_plugin_settings',RECLINKS_DIRECTORY.'/images/icon16.png'); 
    76    add_submenu_page('edit.php?post_type=reclink',__( 'Recommended Links Plugin Settings', 'gad_reclinks' ),'Plugin Settings','activate_plugins','reclinks_plugin_settings','reclinks_plugin_settings'); 
    87} 
    98 
    109function reclinks_plugin_settings() { 
     10    $tabs = array( 
     11        'general' => __( 'General Settings', 'reclinks' ), 
     12        'archives' => __( 'Archive Pages', 'reclinks' ), 
     13        'bookmarklet' => __( 'Bookmarklet', 'reclinks' ), 
     14        'about' => __( 'About this plugin', 'reclinks' ) 
     15    ); 
     16    $page = ( isset($_GET['tab']) && in_array( $_GET['tab'], array_keys( $tabs ) ) ) ? $_GET['tab'] : 'general'; 
     17 
     18    $current_settings = get_option( 'reclinks_options' ); 
    1119    if ( !empty( $_POST ) && check_admin_referer( 'gad-reclinks-settings', '_wpnonce') ) 
    12         update_reclinks_settings(); 
     20        update_reclinks_settings( $page ); 
    1321    $current_settings = get_option( 'reclinks_plugin_options' ); 
    1422?> 
    1523    <div class="wrap"> 
    16         <h2><?php _e( 'Recommended Links Plugin Settings', 'gad_reclinks' ); ?></h2> 
     24<h2><?php _e( 'Recommended Links Plugin Settings', 'reclinks' ); ?></h2> 
     25 
     26<div id="icon-themes" class="icon32"><br /></div> 
     27<h3 class="nav-tab-wrapper"> 
     28<?php foreach ( $tabs as $tab => $title ) { 
     29    $tab_active_class = ( $tab == $page ) ? ' nav-tab-active' : ''; 
     30    echo '<a class="nav-tab'.$tab_active_class.'" href="?post_type=reclink&page=reclinks_plugin_settings&tab='.$tab.'">'; 
     31    echo $title; 
     32    echo '</a>'; 
     33} ?> 
     34</h3> 
     35        <?php if ( 'about' == $page ) { 
     36                require( 'admin/options-about.php' );  
     37            } else { ?> 
    1738        <form method="post"> 
    1839            <table class="form-table"> 
    19                 <tr> 
    20                     <th scope="row"> 
    21                         <label for="page_for_reclinks"><?php _e( 'Page for Recommended Links Archive:', 'gad_reclinks' ); ?></label> 
    22                     </th> 
    23                     <td> 
    24                         <?php wp_dropdown_pages( 
    25                             array( 
    26                                 'show_option_none' => __('None (use default archive)', 'gad_reclinks'), 
    27                                 'exclude' => array( get_option('page_for_posts') ), 
    28                                 'selected' => $current_settings['page_for_reclinks'] 
    29                             ) 
    30                         ); ?> 
    31     <p class="description"><?php _e( 'Note: if you choose a custom page to hold your archive, you can add content above the archive.<br>The page template you select will be used for styling purposes.', 'gad_reclinks' ); ?></p> 
    32                     </td> 
    33                 </tr> 
    34                 <tr> 
    35                     <th scope="row"> 
    36                         <label for="page_for_reclinks"><?php _e( 'Default Sort Order:', 'gad_reclinks' ); ?></label> 
    37                     </th> 
    38                     <td> 
    39                         <select id="sort_order" name="sort_order"> 
    40                             <?php $options = array(  
    41                                 'current' => __( 'Current: Top score this week', 'gad_reclinks' ), 
    42                                 'hot' => __( 'Hot: Top score in the past 24 hours', 'gad_reclinks' ), 
    43                                 'score' => __( 'Highest overall score', 'gad_reclinks' ), 
    44                                 'newest' => __( 'Most recently submitted', 'gad_reclinks' ) 
    45                             ); 
    46                             foreach ( $options as $opt => $descrip ) { 
    47                                 echo '<option value="'.$opt.'" '.selected( $opt, $current_settings['sort_order'], 0 ).'>'.$descrip.'</option>'; 
    48                             } ?> 
    49                         </select> 
    50                     </td> 
    51                 </tr> 
    52         <tr> 
    53             <th scope="row"> 
    54                 <label for="taxonomies"><?php _e( 'Taxonomies to enable for recommended links:', 'gad_reclinks' ); ?></label> 
    55             </th> 
    56             <td> 
    57             <?php $taxes = get_taxonomies( null, 'objects' ); 
    58                     foreach ($taxes as $name => $tax)  
    59                         if (!in_array( $name, array( 'nav_menu', 'link_category', 'post_format' ) ) ) 
    60                             echo '<p><input type="checkbox" name="tax['.$name.']" '.checked( ( isset( $current_settings['tax'][$name] ) && $current_settings['tax'][$name] ), true, false ).'> '.$tax->labels->name .'</p>'; 
    61             ?> 
    62             </td> 
    63         </tr> 
    64             <tr> 
    65                 <th scope="row"> 
    66                     <label><?php _e( 'User registration options:', 'gad_reclinks' ); ?></label> 
    67                 </th> 
    68                 <td> 
    69                     <p> 
    70                         <input type="checkbox" name="allow-unregistered-vote" <?php checked( $current_settings['allow-unregistered-vote'] ); ?>/> 
    71                         <label for="allow-unregistered-vote"><?php _e( 'Allow unregistered users to vote?', 'gad_reclinks' ); ?></label> 
    72                         <br><span class="description"><?php _e('(Votes will be logged by IP address.)', 'gad_reclinks' ); ?></span> 
    73                     </p> 
    74 <!--- 
    75                     <p> 
    76                         <input type="checkbox" name="allow-unregistered-post" <?php checked( $current_settings['allow-unregistered-post'] ); ?>/> 
    77                         <label for="allow-unregistered-post"><?php _e( 'Allow unregistered users to post new links?', 'gad_reclinks' ); ?></label> 
    78                     </p> 
    79 --> 
    80                 </td> 
    81             </tr> 
    82         <tr> 
    83             <th scope="row"> 
    84                 <label><?php _e( 'Comments:', 'gad_reclinks' ); ?></label> 
    85             </th> 
    86             <td> 
    87                 <p> 
    88                     <input type="checkbox" name="vote-on-comments" <?php checked( $current_settings['vote-on-comments'] ); ?> /> 
    89                     <label for="vote-on-comments"><?php _e( 'Enable voting / points tally on comments?', 'gad_reclinks' ); ?></label> 
    90                 </p> 
    91             </td> 
    92         </tr> 
    93         <tr> 
    94             <th></th> 
    95             <td> 
    96                 <?php wp_nonce_field( 'gad-reclinks-settings' ); ?> 
    97                 <p> 
    98                     <input type="submit" class="button-primary" value="Save changes"/> 
    99                 </p> 
    100             </td> 
    101         </tr> 
     40            <?php require( "admin/options-$page.php" ); ?> 
    10241            </table> 
    10342        </form> 
     43    <?php } ?> 
    10444    </div> 
    10545 
     
    10747} 
    10848 
    109 function update_reclinks_settings() { 
     49function update_reclinks_settings( $page ) { 
    11050 
    111     // needs sanitization and whitelisting, of course 
    112     // this is just bare minimum 
    113     update_option( 'reclinks_plugin_options',  
    114         array( 
    115             'page_for_reclinks' => intval( $_POST['page_id'] ), 
    116             'sort_order' => $_POST['sort_order'], 
    117             'tax' => ( isset( $_POST['tax'] ) ) ? $_POST['tax'] : array(), 
    118             'allow-unregistered-vote' => (isset($_POST['allow-unregistered-vote']) && true == $_POST['allow-unregistered-vote']), 
    119             'allow-unregistered-post' => (isset($_POST['allow-unregistered-post']) && true == $_POST['allow-unregistered-post']), 
    120             'vote-on-comments' => (isset($_POST['vote-on-comments']) && true == $_POST['vote-on-comments']), 
     51    $settings = get_option( 'reclinks_plugin_options' ); 
     52 
     53    switch ( $page ) : 
     54        case 'general': 
     55            $settings['page_for_reclinks'] = intval( $_POST['page_id'] ); 
     56            $settings['sort_order'] = $_POST['sort_order']; 
     57            $settings['tax'] = ( isset( $_POST['tax'] ) ) ? $_POST['tax'] : array(); 
     58            $settings['allow-unregistered-vote'] = (isset($_POST['allow-unregistered-vote']) && true == $_POST['allow-unregistered-vote']); 
     59            $settings['allow-unregistered-post'] = (isset($_POST['allow-unregistered-post']) && true == $_POST['allow-unregistered-post']); 
     60            $settings['vote-on-comments'] = (isset($_POST['vote-on-comments']) && true == $_POST['vote-on-comments']); 
    12161 
    12262            // no UI for this yet, but its gotta be in there 
    123             'vote-values' => array( 
     63            $settings['vote-values'] = array( 
    12464                'minus' => array( 'value' => -1, 'text' => '-' ), 
    12565                'plus' => array( 'value' => 1, 'text' => '+' ) 
    126             ), 
    127         ) 
    128     ); 
     66            ); 
     67            break; 
     68        case 'bookmarklet': 
     69            $settings['bookmarklet_text'] = sanitize_text_field( $_POST['bookmarklet_text'] ); 
     70            $settings['bookmarklet_class'] = sanitize_text_field( $_POST['bookmarklet_class'] ); 
     71            $settings['bookmarklet_header'] = wp_kses_post( $_POST['bookmarklet_header'] ); 
     72            break; 
     73        default: 
     74            break; 
     75    endswitch; 
     76 
     77    update_option( 'reclinks_plugin_options', $settings ); 
     78 
    12979    echo '<div id="message" class="messages updated"><p>Plugin settings updated!</p></div>'; 
    13080} 
     
    178128    return $vars; 
    179129} 
     130 
     131/** 
     132 * Added meta boxes for edit-post?post_type=reclink screen 
     133 * 
     134 */ 
     135function reclinks_edit_screen_metaboxes() { 
     136    add_meta_box( 'reclinkurl', __( 'Link URL', 'reclinks'), 'reclinks_URL_metabox', 'reclink', 'normal', 'core' ); 
     137} 
     138 
     139function reclinks_URL_metabox() { 
     140    global $post; 
     141    $href = get_post_meta( $post->ID, '_href', true ); 
     142    wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' ); 
     143    echo '<input name="_href" type="url" class="regular-text" style="width: 98%" value="'.$href.'">'; 
     144} 
     145 
     146add_action( 'save_post', 'save_edited_reclink_href' ); 
     147 
     148function save_edited_reclink_href( $post_ID ) { 
     149    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 
     150        return; 
     151 
     152    if ( 'reclink' === $_POST['post_type'] ) 
     153        update_post_meta( $post_ID, '_href', $_POST['_href'] ); 
     154 
     155} 
  • recommended-links/trunk/ajax-functions.php

    r492236 r509618  
    3838 
    3939        $votesuccess = gad_add_reclink_vote( $_POST['reclink'], $comment, $vote, $current_user->ID, $_SERVER['REMOTE_ADDR'] ); 
     40    } 
     41 
     42    if ( 'submitlink' === $_GET['action'] ) { 
     43        add_filter( 'show_admin_bar', '__return_false' ); 
     44        reclinks_bookmarklet_request(); 
     45        exit; 
    4046    } 
    4147 
     
    8591} 
    8692 
    87 // Not currently used; but here in case the YQL solution proves too clow, or unreliable 
     93// Not currently used; but here in case the YQL solution proves too slow, or unreliable 
    8894add_action( 'wp_ajax_check_reclink_title', 'gad_reclinks_check_link_title' ); 
    8995add_action( 'wp_ajax_nopriv_check_reclink_title', 'gad_reclinks_check_link_title' ); 
     
    105111    die( json_encode( $return ) ); 
    106112 
     113} 
    107114 
     115 
     116/** 
     117 * On template redirect, checks for the presence of the "action=submitlink" query 
     118 * arg (IE, a request originating from the bookmarklet), and, if present, skips the 
     119 * usual template hierarchy and only displays the "Add Link" form. 
     120 *  
     121 */ 
     122 
     123 
     124function reclinks_bookmarklet_request() { 
     125 
     126    define( 'IFRAME_REQUEST', true ); 
     127 
     128    if ( !is_user_logged_in() ) { 
     129        $current_request = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']; 
     130        wp_redirect( add_query_arg(  
     131            array( 'msg' => 'bookmarklets-login' ), 
     132            wp_login_url( $current_request ) ) 
     133        ); 
     134        exit; 
     135    } 
     136     
     137    header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 
     138?> 
     139<html> 
     140    <head> 
     141        <title><?php wp_title('Submit Recommended Link'); ?></title> 
     142        <?php wp_head(); ?> 
     143        <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> 
     144        <script type="text/javascript"> 
     145            jQuery(document).ready(function($){ 
     146                reclink = { 
     147                    url: '<?php echo $_GET['u']; ?>', 
     148                    title: '<?php echo $_GET['t']; ?>', 
     149                    description: '<?php echo $_GET['s']; ?>' 
     150                } 
     151                $('#reclink_URL').val(reclink.url); 
     152                $('#reclink_title').val(reclink.title); 
     153                $('#reclink_description').val(reclink.description); 
     154            }); 
     155        </script> 
     156    </head> 
     157    <body> 
     158        <div class="widget widget_addLink_form"> 
     159            <?php output_addlink_form( true ); ?> 
     160        </div> 
     161    </body> 
     162</html> 
     163<?php 
     164    die(0); 
    108165} 
  • recommended-links/trunk/display-filters.php

    r492388 r509618  
    5555    $sort_order = ( isset( $plugin_settings['sort_order'] ) ) ? $plugin_settings['sort_order'] : 'current'; 
    5656 
     57    if ( isset( $query->query_vars['reclinks_sort'] ) && in_array( 
     58            $query->query_vars['reclinks_sort'],  
     59            array( 'newest', 'hot', 'current', 'score', 'controversial' ) ) ) 
     60        $sort_order = $query->query_vars['reclinks_sort']; 
     61 
    5762    if ( isset( $_GET['sort'] ) && in_array( 
    5863            $_GET['sort'],  
    59             array( 'newest', 'hot', 'current', 'score' ) ) ) 
     64            array( 'newest', 'hot', 'current', 'score', 'controversial' ) ) ) 
    6065        $sort_order = $_GET['sort']; 
    61  
    62     if ( isset( $query->query_vars['reclinks_sort'] ) && in_array( 
    63             $query->query_vars['reclinks_sort'],  
    64             array( 'newest', 'hot', 'current', 'score' ) ) ) 
    65         $sort_order = $query->query_vars['reclinks_sort']; 
    6666 
    6767    switch ( $sort_order ) : 
     
    8282            add_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
    8383            add_filter( 'posts_join', 'gad_reclinks_votes_join_hot' ); 
     84            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     85            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     86            add_action( 'the_posts', 'gad_remove_custom_filters' ); 
     87            break; 
     88        case 'controversial': 
     89            add_filter( 'posts_fields', 'gad_reclinks_posts_fields_absval' ); 
     90            add_filter( 'posts_join', 'gad_reclinks_votes_join_current' ); 
    8491            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
    8592            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     
    110117} 
    111118 
     119function gad_reclinks_posts_fields_absval( $fields ) { 
     120    global $wpdb; 
     121    $fields = str_replace( "{$wpdb->posts}.*", "{$wpdb->posts}.*, SUM( ABS( {$wpdb->reclinkvotes}.vote ) ) AS post_vote ", $fields ); 
     122    return $fields; 
     123} 
     124 
    112125function gad_reclinks_votes_join_hot( $join ) { 
    113126    return $join . gad_reclinks_votes_join( '1 DAY' ); 
     
    218231} 
    219232 
     233function reclinks_favicon( $echo = true ) { 
     234    $domain = reclinks_domain( false, '', '' ); 
     235    if ( empty( $domain ) ) return false; 
     236    $favicon = '<img class="reclink-favicon" src="http://www.google.com/s2/favicons?domain='.$domain.'" alt="'.$domain.'">'; 
     237    if ( $echo ) 
     238        echo $favicon; 
     239    else 
     240        return $favicon; 
     241} 
    220242 
    221243/** 
     
    279301 
    280302} 
     303 
  • recommended-links/trunk/display-shortcodes.php

    r489412 r509618  
    11<?php 
    22 
     3/** 
     4 * @function    output_addlink_form 
     5 * 
     6 * Outputs or returns html markup for the "Add Link" form. 
     7 * Called by the shortcode `reclink_addform` as well as by the Add Link widget, 
     8 * and can be called directly by theme or bookmarklet. 
     9 * 
     10 * @param   bool    Whether to echo (true) or return (false). 
     11 * 
     12 */ 
    313add_shortcode( 'reclink_addform', 'output_addlink_form' ); 
    414 
     
    818?> 
    919    <form class="reclinks_addlink" action="<?php echo add_query_arg( 'action', 'reclink-add' ); ?>" method="POST"> 
    10         <label for="reclink_URL"><?php _e('Link URL', 'gad_reclinks'); ?></label> 
    11         <input type="text" name="reclink_URL" id="reclink_URL" /> 
    12         <label for="reclink_title"><?php _e('Link Title', 'gad_reclinks'); ?></label> 
    13         <input type="text" name="reclink_title" id="reclink_title" /> 
    14         <label for="reclink_description"><?php _e('Link Description', 'gad_reclinks'); ?></label> 
    15         <textarea id="reclink_description" name="reclink_description" rows="10" cols="30" ></textarea> 
     20        <div class="reclink_form_field"> 
     21            <label for="reclink_URL"><?php _e('Link URL', 'gad_reclinks'); ?></label> 
     22            <input type="text" name="reclink_URL" id="reclink_URL" /> 
     23        </div> 
     24        <div class="reclink_form_field"> 
     25            <label for="reclink_title"><?php _e('Link Title', 'gad_reclinks'); ?></label> 
     26            <input type="text" name="reclink_title" id="reclink_title" /> 
     27        </div> 
     28        <div class="reclink_form_field"> 
     29            <label for="reclink_description"><?php _e('Link Description', 'gad_reclinks'); ?></label> 
     30            <textarea id="reclink_description" name="reclink_description" rows="10" cols="30" ></textarea> 
     31        </div> 
    1632<?php if ( isset( $plugin_settings['tax'] ) && is_array( $plugin_settings['tax'] ) ) { 
    1733    foreach ( $plugin_settings['tax'] as $tax => $on ) { 
    1834        $t = get_taxonomy( $tax ); 
    19         echo '<p><label for="reclink_taxes['.$tax.']">'.$t->labels->name.'</label>'; 
     35        echo '<div class="reclink_form_field">'; 
     36        echo '<label for="reclink_taxes['.$tax.']">'.$t->labels->name.'</label>'; 
    2037        wp_dropdown_categories(  
    2138            array(  
     
    2744            ) 
    2845        );   
    29         echo '</p>'; 
     46        echo '</div>'; 
    3047    } 
    3148} ?> 
     
    3653    ob_end_clean(); 
    3754    if ( $echo === true ) echo $output; else return $output; 
     55} 
     56 
     57 
     58/** 
     59 * @function    reclinks_bookmarklet 
     60 * 
     61 * Displays a button for the Add Link bookmarklet and outputs the javascript  
     62 * necessary for the bookmarklet. 
     63 * 
     64 * Based loosely on the internals of the Press This bookmarklet, but all of the work 
     65 * is done front-end so there's no need to load admin scripts, etc. 
     66 * 
     67 * @param   bool    true: echoes bookmarklet, false: returns it. 
     68 */ 
     69 
     70add_shortcode( 'reclink_bookmarklet', 'reclinks_bookmarklet' ); 
     71 
     72function reclinks_bookmarklet( $echo = false ) { 
     73    $plugin_settings = get_option( 'reclinks_plugin_options' ); 
     74    $submit_link_url = add_query_arg( array( 'action' => 'submitlink' ), home_url() ); 
     75    $button_text = isset( $plugin_settings['bookmarklet_text'] ) ? $plugin_settings['bookmarklet_text'] : get_bloginfo('title') .' bookmarklet'; 
     76    $button_class = isset( $plugin_settings['bookmarklet_class'] ) ? $plugin_settings['bookmarklet_class'] : 'reclinks-bookmarklet'; 
     77    if ( !empty( $plugin_settings['button-class'] ) ) $button_class .= " " . trim( $plugin_settings['button-class'] ); 
     78    $button = <<<HTML 
     79<p class="{$button_class}"> 
     80<a onclick="return false;" oncontextmenu="if(window.navigator.userAgent.indexOf('WebKit')!=-1||window.navigator.userAgent.indexOf('MSIE')!=-1)jQuery('.reclinks-bookmarklet-code').show().find('textarea').focus().select();return false;" href="javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='{$submit_link_url}',l=d.location,e=encodeURIComponent,u=f+'&u='+e(l.href)+'&amp;t='+e(d.title)+'&amp;s='+e(s)+'&amp;v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)"><span>$button_text</span></a> 
     81</p> 
     82HTML; 
     83    if ( $echo ) echo $button; 
     84    else return $button; 
    3885} 
    3986 
     
    150197    } 
    151198} 
     199 
     200/** 
     201 * Shortcode to display buttons for different sort options 
     202 * 
     203 * Usage:   [reclink_sort_options]  
     204 *              to show buttons for all four sorting options, with default text 
     205 *          [reclink_sort_options show="newest,current,score" score="All time best"] 
     206 *              will show only buttons for newest, current, and score, and will use 
     207 *              "All time best" as the text for the "score" button rather than "Top Score" 
     208 */ 
     209add_shortcode( 'reclink_sort_options', 'reclink_sort_options' ); 
     210 
     211function reclink_sort_options( $args = null ) { 
     212    $defaults = array( 
     213        'base_url'      => false, 
     214        'show'          => 'hot,current,newest,controversial,score', 
     215        'hot'           => __( 'Hot', 'reclinks' ), 
     216        'current'       => __( 'Current', 'reclinks' ), 
     217        'newest'        => __( 'Newest', 'reclinks' ), 
     218        'controversial' => __( 'Controversial', 'reclinks' ), 
     219        'score'         => __( 'Top Score', 'reclinks' ) 
     220    ); 
     221    $args = wp_parse_args( $args, $defaults ); 
     222    $links = explode( ',' , $args['show'] ); 
     223     
     224    $plugin_settings = get_option( 'reclinks_plugin_options' ); 
     225    $archive_page = ( isset( $plugin_settings['page_for_reclinks'] ) ) ? 
     226        get_permalink( $plugin_settings['page_for_reclinks'] ) : get_post_type_archive_link( 'reclink' ); 
     227    if ( $args['base_url'] )  
     228        $archive_page= $args['base_url']; 
     229 
     230    $return = '<form class="reclinks-sort-options" action="'.$archive_page.'" method="get" >'; 
     231    foreach ( $links as $link ) 
     232        $return .= '<button class="reclinks-sort reclinks-sort-'.$link.'" name="sort" value="'.$link.'">'.$args[$link].'</button>'; 
     233    $return .= '</form>'; 
     234 
     235    return $return; 
     236} 
  • recommended-links/trunk/js/reclinks-scripts.coffee

    r489412 r509618  
    3030    $('#reclink_URL').bind 'change', (event) -> 
    3131        linkUrl = $(this).val() 
     32        if linkUrl is '' return false 
    3233        $.ajax 'http://query.yahooapis.com/v1/public/yql', 
    3334            type: 'get', 
    3435            data: { 
    35                 q: "use 'http://www.datatables.org/data/htmlstring.xml' as htmlstring; select * from htmlstring where url='#{ linkUrl }'", 
     36                q: "select * from html where url='#{ linkUrl }' and xpath='/html/head/title'", 
    3637                format: 'json' 
    3738                }, 
     
    4243                    alert reclinks.messages_error404 
    4344                    return false 
    44                 title = response.result.match( /<\s*title\s*>([^<]*)<\/title>/ )[1] 
     45                title = response.title 
    4546                unless title 
    4647                    alert reclinks.messages_errorNoTitle 
  • recommended-links/trunk/js/reclinks-scripts.js

    r489412 r509618  
    4545        type: 'get', 
    4646        data: { 
    47           q: "use 'http://www.datatables.org/data/htmlstring.xml' as htmlstring; select * from htmlstring where url='" + linkUrl + "'", 
     47          q: "select * from html where url='" + linkUrl + "' and xpath='/html/head/title|/html/head/link[@rel=\"icon\"]|/html/head/link[@rel=\"shortcut icon\"]'", 
    4848          format: 'json' 
    4949        }, 
     
    5656            return false; 
    5757          } 
    58           title = response.result.match(/<\s*title\s*>([^<]*)<\/title>/)[1]; 
     58          title = response.title; 
    5959          if (!title) { 
    6060            alert(reclinks.messages_errorNoTitle); 
  • recommended-links/trunk/loop-reclinks.php

    r489412 r509618  
    2525    <?php while ( have_posts() ) : the_post(); ?> 
    2626        <li> 
     27            <?php reclinks_favicon(); ?> 
    2728            <?php reclink_terms(); ?> 
    2829            <strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong>  
    29             <small><?php reclinks_domain(); ?><small> 
     30<!--        <small><?php reclinks_domain(); ?><small>  --> 
    3031            <br /><?php reclinks_votebox(); ?> 
    3132        </li> 
  • recommended-links/trunk/plugin-activation.php

    r489412 r509618  
    5858function reclinks_db_option_upgrade( $from ) { 
    5959 
    60     if ( $from === 4 ) return; 
     60    if ( $from === 5 ) return; 
    6161 
    6262    $old_settings = ( $from ) ? get_option( 'reclinks_plugin_options' ) : array(); 
    6363 
    64     /* DB version 4, reflects plugin version 0.4. Includes 'vote-on-comments' settings. */ 
     64    /* DB version 5, reflects plugin version 0.4early. Introduces bookmarklet settings options. 
     65    /* DB version 4, reflects plugin version 0.4early. Includes 'vote-on-comments' settings. */ 
    6566    /* DB version 3, reflects plugin version 0.3. Includes 'tax' string. */ 
    6667    $reclinks_plugin_defaults = array( 
     
    7475        'allow-unregistered-post' => false, 
    7576        'vote-on-comments' => true, 
    76         'tax' => array() 
     77        'tax' => array(), 
     78        'bookmarklet_text' => sprintf( __( 'Post to %s', 'reclinks' ), get_option( 'blogname' ) ), 
     79        'bookmarklet_class' => 'reclinks-bookmarklet', 
     80        'bookmarklet_header' => '' 
    7781    ); 
    7882 
     
    8084 
    8185    update_option( 'reclinks_plugin_options', $options_to_set ); 
    82     update_option( 'reclinks_db_version', 4 ); 
     86    update_option( 'reclinks_db_version', 5 ); 
    8387 
    8488} 
  • recommended-links/trunk/readme.txt

    r492388 r509618  
    55Requires at least: 3.2.1 
    66Tested up to: 3.3.1 
    7 Stable tag: 0.3.5 
     7Stable tag: 0.4 
    88 
    99A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them. 
     
    1111== Description == 
    1212 
    13 This is the beginning of what I hope will be a much more ambitious project. If you want to try this out, please give me feedback. 
     13This plugin aims to support community link-sharing, social bookmarking, and discussion of links in the WordPress environment.  
     14 
     15This is still at an early stage of what I hope will be a much more ambitious project. If you want to try this out, please give me feedback. 
    1416 
    1517I will guarantee backwards compatibility with all data saved by the plugin, so it should be safe to install and activate, and as I add features, your existing posts and links will work with them just fine. 
    1618 
    17 == Installation == 
    18  
    19 1. Upload the entire `recommended-links/` folder to the `/wp-content/plugins/` directory. 
    20 1. Activate the plugin through the 'Plugins' menu in WordPress. 
    21 1. A plugin options page is included under the "Recommended Links" admin menu, where you can select some basic settings. 
    22 1. Include the 'Reclinks Add Link Form' widget in a sidebar (or anywhere). Alternately, you can use the shortcode `[reclinks_addlinkform]` in any page or post. 
    23 1. Any links added through this widget show up in the archive for the custom post type "Recommended Links". You can also create a new page and set that page to show your links on the plugin options page. 
    24 1. If you have permalinks enabled, the archive will be displayed at `http://yoursite.tld/reclinks`; otherwise it will be at `http://yoursite.tld?post_type=reclink`.  
    25 1. The plugin tries to intelligently filter markup so that it can work with most themes out of the box. If the archive or single link display doesn't work in your theme, you may have to create an `archive-reclink.php` or `single-reclink.php` template file. _(See the FAQ for examples of markup for these template files)_. 
    26 1. See the [plugin wiki](https://github.com/goldenapples/recommended-links/wiki) for troubleshooting and customization instructions. 
    27  
    28 == Frequently Asked Questions == 
    29  
    30 = How can I customize the markup of the list of "Recommended Links"? = 
    31  
    32 __If you are using the default post type archive__, WordPress will search in your theme directory for a file called `archive-reclinks.php`. If thats not found, it will fall back along the usual WordPress [template hierarchy](http://codex.wordpress.org/Template_Hierarchy). The easiest way to begin customizing your output is to copy your existing `archive.php` or `index.php` to a file called `archive-reclinks.php` and begin making changes to it. 
    33  
    34 __If you have selected an existing page to hold your archive__, WordPress will use the template assigned to that page for the page layout, and the loop defined in the `loop_reclinks.php` file in the plugin directory to mark up the list of recommended links. To make changes to the `loop-reclinks.php` (which also affects the output of the recommended links list widget), copy it to your theme directory and edit it there. 
    35  
    36 __Individual recommended link posts__ are handled by WordPress's normal template hierarchy in your theme. If you want to change their markup and layout, create a file in your theme directory called `single-reclink.php` (or copy your `single.php` file and rename it to `single-reclink.php`) and begin editing. 
    37  
    38 = What sorting options are there? = 
    39  
    40 Currently this plugin supports sorting of archive pages by a "sort" parameter passed via query string. The options allowed are: 
    41  
    42 * **newest** Sort links by posted time, most recently first 
    43 * **hot** Sort links by votes over the past day 
    44 * **current** Sort by votes over the past week 
    45 * **score** Sort by total vote score over time 
    46  
    47 So for example, with permalinks enabled, the URL `yoursite.tld/reclinks/?sort=hot` would display a page of the 25 links with the highest vote score over the past day. 
    48  
    49 You can also set a default sort order from the plugin settings page. The query string argument, if present, overrides the default value. So if your default sorting is **current**, you can still give your users a chance to view top voted links of all time by giving them a link to `yoursite.tld/reclinks/?sort=score`. 
    50  
    51 = What markup does the plugin offer? = 
    52  
    53 This plugin filters `the_permalink` to display the link submitted. A typical archive page, where the post title is wrapped in markup like 
    54 `<a href=<?php the_permalink(); ?>"><?php the_title(); ?></a>` 
    55 will display the title of the submitted link, linking to that link itself. 
    56  
    57 If you want to access the permalink of the comments page on your site, use `get_permalink()` instead. 
    58  
    59 By default, this plugin filters both `the_content` and `comment_text` to add vote buttons and current score box above the post/comment content. If you want to display these in a different position, you can unhook those filters and use the template tag `reclinks_votebox()` in your template files wherever you want the vote box to display. 
    60  
    61 There are not many special display features yet. A partial listing: 
    62  
    63 * `reclink_domain()` echoes the host of the link submitted - give people a chance to know what they're getting themselves into before they follow a link.  
    64 * `reclink_votebox()` echoes a div with +/- vote buttons, the current score, author, and human time diff'd post date 
    65 * `author_karma( $user )` returns a user's total karma score 
    66  
    67  
     19See the plugin's [wiki page on github](https://github.com/goldenapples/recommended-links/wiki) for more up-to-date documentation (its hard to keep documentation updated in multiple places). 
    6820 
    6921== Changelog == 
     22 
     23= 0.4 = 
     24 
     25This update fleshes out a number of functions that were introduced in earlier versions, and introduces a bookmarklet that can be used for easier submission of links. 
    7026 
    7127= 0.3.5 = 
     
    11773== Upgrade Notice == 
    11874 
    119 = 0.3.5 = 
    120  
    121 Fixed term archive pages; also fixed the loop on archive pages so it doesn't mess up any secondary loops on the page. 
    122  
    123 = 0.3.4 = 
    124  
    125 I broke posting of new links in the last update (0.3.3)... this is just a quick fix to correct that. More changes to come soon. 
    126  
    127 = 0.3.3 =  
    128 This update fixes several bugs that were pointed out (time zone setting, posts showing up as from "anonymous", update messages not defined), and adds an option to disable voting on comments. It also styles the +1/-1 buttons a bit - skins for the style will be selectable and overridable by version 0.4, but just for now I was tired of seeing the unstyled buttons. 
    129  
    130 = 0.3 = 
    131 This version includes a plugin settings page, as well as multiple new features: 
    132  
    133 = 0.2.2 = 
    134 Added a widget to display the most recently posted links in the sidebar. Also, fixed some minor javascript and css errors. 
    135  
    136 = 0.2.1 = 
    137 Implemented four new sorting options to the recommended links archive page: "newest", "hot", "current", and "score". 
     75= 0.4 = 
     76This update introduces a bookmarklet that can be used for easier submission of links, and some other features. 
  • recommended-links/trunk/reclinks-styles.css

    r489412 r509618  
    2828.votelink.votelink-minus:hover { background-position: -28px -14px; } 
    2929.votelink.votelink-plus:hover { background-position: -42px -14px; } 
     30 
     31/* Bookmarklet default styles */ 
     32 
     33.reclinks-bookmarklet { 
     34    margin: 20px 0; 
     35    position: relative; 
     36} 
     37 
     38.reclinks-bookmarklet a { 
     39    display: inline-block; 
     40    padding-right: 12px; 
     41    position: relative; 
     42    cursor: move; 
     43    color: #333; 
     44    background: #dfdfdf; 
     45    background-image: -webkit-gradient( 
     46        linear, 
     47        left bottom, 
     48        left top, 
     49        color-stop(0.07, rgb(230,230,230)), 
     50        color-stop(0.77, rgb(216,216,216)) 
     51    ); 
     52    background-image: -moz-linear-gradient( 
     53        center bottom, 
     54        rgb(230,230,230) 7%, 
     55        rgb(216,216,216) 77% 
     56    ); 
     57    background-repeat: no-repeat; 
     58    background-image-position: 10px 8px; 
     59    -webkit-border-radius: 5px; 
     60    border-radius: 5px; 
     61    border: 1px #b4b4b4 solid; 
     62    font-style: normal; 
     63    line-height: 16px; 
     64    font-size: 14px; 
     65    text-decoration: none; 
     66    text-shadow: #fff 0 1px 0px; 
     67} 
     68 
     69.reclinks-bookmarklet a:hover, 
     70.reclinks-bookmarklet a:active { 
     71    color: #333 
     72} 
     73 
     74.reclinks-bookmarklet a:hover:after { 
     75    transform: skew(20deg) rotate(9deg); 
     76    -webkit-transform: skew(20deg) rotate(9deg); 
     77    -moz-transform: skew(20deg) rotate(9deg); 
     78    box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); 
     79    -webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); 
     80    -moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); 
     81} 
     82 
     83.reclinks-bookmarklet a span { 
     84    background: url(../../../wp-admin/images/press-this.png) no-repeat -45px 5px ; 
     85    padding: 8px 8px 8px 32px; 
     86    display: inline-block; 
     87} 
     88 
     89.reclinks-bookmarklet a:after { 
     90    content: ''; 
     91    width: 70%; 
     92    height: 55%; 
     93    z-index: -1; 
     94    position: absolute; 
     95    right: 10px; 
     96    bottom: 9px; 
     97    background: transparent; 
     98    transform: skew(20deg) rotate(6deg); 
     99    -webkit-transform: skew(20deg) rotate(6deg); 
     100    -moz-transform: skew(20deg) rotate(6deg); 
     101    box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); 
     102    -webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); 
     103    -moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); 
     104} 
     105 
     106.reclink-favicon { vertical-align: middle; } 
  • recommended-links/trunk/recommended-links.php

    r492388 r509618  
    55Description: A "reddit clone" that runs in Wordpress. 
    66Author: Nathaniel Taintor 
    7 Version: 0.3.5 
     7Version: 0.4 
    88Author URI: http://goldenapplesdesign.com 
    99*/ 
     
    7373        'rewrite' => array(  
    7474            'slug' => 'link' 
    75         ) 
     75        ), 
     76        'register_meta_box_cb' => 'reclinks_edit_screen_metaboxes' 
    7677    ); 
    7778 
     
    9091function gad_check_db_tables() { 
    9192    $v = get_option( 'reclinks_db_version' ); 
    92     if ( !$v || $v < 4 ) 
     93    if ( !$v || $v < 5 ) 
    9394        reclinks_db_option_upgrade( $v ); 
    9495} 
     
    170171            $terms_array = array_map( 'intval', (array)$terms ); 
    171172            $test = wp_set_object_terms( $link_ID, $terms_array, $tax ); 
    172             error_log( 'Setting terms on '.$link_ID.': '.print_r( $test ) ); 
     173//          error_log( 'Setting terms on '.$link_ID.': '.print_r( $test ) ); 
    173174        } 
    174175 
  • recommended-links/trunk/user-functions.php

    r482847 r509618  
    3737    if ( 'reclinks-login' === $_GET['msg'] ) { 
    3838        $message = '<p class="message">'.__( 'You must be logged in to vote.', 'gad_reclinks' ) .'</p>'; 
     39        return $message; 
     40    } 
     41    if ( 'bookmarklets-login' === $_GET['msg'] ) { 
     42        $message = '<p class="message">'.__( 'Please <b>log in</b> to submit this link.', 'gad_reclinks' ) . '</p>'; 
    3943        return $message; 
    4044    } 
  • recommended-links/trunk/widgets.php

    r486514 r509618  
    170170 
    171171    register_widget('RecLinks_Display_Links'); 
     172 
     173 
     174    /* 
     175     * Widget for displaying bookmarklet button. 
     176     * 
     177     * ALso includes textarea where site owners can include description 
     178     * and instructions, etc. 
     179     * 
     180     */ 
     181    class RecLinks_Bookmarklet extends WP_Widget { 
     182 
     183        function RecLinks_Bookmarklet() { 
     184        //Constructor 
     185            $widget_ops = array( 
     186                'classname' => 'widget_reclinks_bookmarklet', 
     187                'description' => 'Display a bookmarklet that your users can drag to their address bar' 
     188            ); 
     189            $this->WP_Widget('reclinks_bookmarklet', 'RecLinks Bookmarklet Form', $widget_ops); 
     190        } 
     191 
     192        function widget($args, $instance) { 
     193        // prints the widget 
     194            if ( !current_user_can('add_reclink') ) 
     195                return; 
     196            extract($args, EXTR_SKIP); 
     197            echo $before_widget; 
     198            $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); 
     199            $entry_title = empty($instance['entry_title']) ? ' ' : apply_filters('widget_entry_title', $instance['entry_title']); 
     200            if ( !empty( $title ) )  
     201                echo $before_title . $title . $after_title; 
     202 
     203            echo reclinks_bookmarklet(); 
     204 
     205            if ( !empty( $description ) ) 
     206                echo '<p>' . $description . '</p>'; 
     207 
     208            echo $after_widget; 
     209        } 
     210 
     211        function update($new_instance, $old_instance) { 
     212            //save the widget 
     213            $instance = $old_instance; 
     214            $instance['title'] = sanitize_text_field($new_instance['title']); 
     215            $instance['description'] = wp_filter_post_kses($new_instance['description']); 
     216            return $instance; 
     217        } 
     218 
     219        function form($instance) { 
     220            //widgetform in backend 
     221            $instance = wp_parse_args(  
     222                (array) $instance,  
     223                array( 'title' => '' ) ); 
     224                $title = strip_tags($instance['title']); 
     225                ?> 
     226                <p> 
     227                    <label for="<?php echo $this->get_field_id('title'); ?>">Title: </label> 
     228                    <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> 
     229                </p> 
     230                <p>                  
     231                    <label for="<?php echo $this->get_field_id('description'); ?>">Description: </label> 
     232                    <textarea id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" rows="10" cols="30"><?php echo esc_textarea( $description ); ?></textarea> 
     233                    <span class="description">(Give your users an idea of how to use the bookmarklet, or instructions, etc.)</span> 
     234                </p> 
     235                <?php 
     236                } 
     237        } 
     238 
     239    register_widget( 'RecLinks_Bookmarklet' ); 
    172240} 
    173241 
Note: See TracChangeset for help on using the changeset viewer.