Plugin Directory

Changeset 416668


Ignore:
Timestamp:
07/28/2011 10:30:34 PM (15 years ago)
Author:
elubow
Message:

Allow for style changes.

Location:
simplereach-slide/trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • simplereach-slide/trunk/readme.txt

    r413935 r416668  
    11=== SimpleReach Slide ===
    2 Tags: slide, simplereach, content, recommendation, relevant, related, pageviews, traffic, plugin, widget, thumbnails, headlines, articles, links
     2Tags: articles, content, headlines, links, pageviews, plugin, recommendation, related, relevant, simplereach, slide, thumbnails, traffic, widget, posts, slider, flyout, fly-out, best, readers, engagement
    33Contributors: elubow
    4 Plugin Name: SimpleReach Slide
     4Plugin Name: The Slide by SimpleReach
    55Plugin URI: https://github.com/simplereach/srslide_wordpress
    66Requires at least: 2.7
    77Tested up to: 3.2.1
    8 Stable tag: trunk
     8Stable tag: 0.4.7
    99
    10 The SimpleReach Slide recommends related posts on a widget that "slides" in at the bottom of the page -- increasing pageviews and time spent on site.
     10The Slide recommends related posts from within your site on a widget that "slides" in at the bottom of the page.
    1111
    1212== Description ==
    13 The SimpleReach Slide is the best way to help readers discover more of your content.
     13The Slide by SimpleReach is the best way to help readers discover more of your content.
    1414
    15 The Slide recommends related posts on a widget that "slides" in at the bottom of the page -- increasing pageviews and time spent on your site.  You've seen a similar content recommendation widget on sites like NYTimes.com, and now SimpleReach is allowing anybody to take advantage of this awesome plugin for free.
     15The Slide recommends related posts from within your site on a widget that "slides" in at the bottom of the page.  You've seen a similar content recommendation widget on sites like NYTimes.com, and now SimpleReach is allowing anybody to take advantage of this awesome plugin for free.
     16
     17NOTE: After installation, you must go to _Settings -> SimpleReach Slide_ in your plugins list to turn on The Slide
    1618
    1719If you have any questions, please contact us at info@simplereach.com or visit our [website](https://www.simplereach.com/).
    1820
    19 = Highlights =
    20 * Boost sharing on Twitter, Facebook, and Google +1 with embedded social buttons
    21 * Access full Reporting/Analytics Dashboard at SimpleReach.com
    22 * Customize The Slide's look and feel
     21= Benefits =
     22* Increased pageviews and time on site
     23* Increased sharing on Twitter, Facebook and Google +1 via embedded social buttons
     24* Access to full analytics in 'Reports' at SimpleReach.com
     25* Customize The Slide's style and functionality
    2326* Allow readers to opt-out
    2427
    2528= Technology =
    26 Content recommendations are based on SimpleReach's proprietary targeting algorithm.  Variables include:
    27 * Contextual, behavioral, and sentiment analysis
     29* Contextual, behavioral and sentiment analysis
    2830* Posts most likely to be shared on social networks
    2931* Posts related to socially trending topics
    3032
    31 SimpleReach uses _asynchronous loading_ and will not affect the load time of your pages.
    32 
     33Content recommendations are determined by SimpleReach's proprietary targeting algorithm, which factors in the above variables.  The Slide uses ‘asynchronous loading’ and will not affect the load time of your pages.
    3334
    3435== Installation ==
     
    36372. Log in to yourdomain.com/wp-admin
    37383. Click Plugins -> Add New -> Upload
    38 4. After installation, go to Settings -> SimpleReach Slide and register for a SimpleReach account
     394. After installation, you must go to _Settings -> SimpleReach Slide_ in your plugins list to turn on The Slide
    39405. You're finished!
    4041
     
    5354
    5455== Changelog ==
     56
     57= 0.4.7 =
     58* Ability to change Slide styling
     59* Verbage fixes
    5560
    5661= 0.4.6 =
  • simplereach-slide/trunk/srslide.php

    r413935 r416668  
    11<?php
    22    /*
    3     Plugin Name: SimpleReach Slide
     3    Plugin Name: The Slide by SimpleReach
    44    Plugin URI: https://www.simplereach.com
    55    Description: After installation, you must click '<a href='options-general.php?page=SimpleReach-Slide'>Settings &rarr; SimpleReach Slide</a>' to turn on The Slide.
    6     Version: 0.4.6
     6    Version: 0.4.7
    77    Author: SimpleReach
    88    Author URI: https://www.simplereach.com
  • simplereach-slide/trunk/srslide_admin.php

    r413935 r416668  
    1414            array_push($errors, "Header text cannot be more than 30 characters.");
    1515        } else {
    16             update_option('srslide_header_text',$_POST['srslide_header_text']);
     16            update_option('srslide_header_text', strtoupper($_POST['srslide_header_text']) );
     17        }
     18
     19        // Convert the style settings into a hash and save it
     20        $style_hash = create_style_hash($_POST);
     21        update_option('srslide_styles',$style_hash);
     22        $style_error = update_slide_styles();
     23        if ($style_error != "OK") {
     24            array_push($errors, $style_error);
    1725        }
    1826
     
    2028        if (count($errors) == 0) {
    2129          ?>
    22           <div class="updated"><p><strong><?php _e('Options saved.'); ?></strong></p></div>
     30          <div class="updated"><p><strong><?php _e('Options saved. If you shifted The Slide position or adjusted the link color, it could take up to 15 minutes for your changes to take effect.'); ?></strong></p></div>
    2331          <?php
    2432        } else {
     
    4351        foreach($_POST as $name => $value) {
    4452            // Only pass vars that start with srslide_sr
    45             if (!preg_match('/^srslide_sr_.+/',$name)) { next; }
     53            if (!preg_match('/^srslide_sr_.+/',$name)) { continue; }
    4654            $encoded_params .= urlencode($name).'='.urlencode($value).'&';
    4755        }
     
    106114
    107115<div class="wrap">
    108     <?php echo "<h2>" . __( 'SimpleReach Slide', 'srslide_adminopt' ) . "</h2>"; ?>
     116    <?php echo "<h2>" . __( 'The Slide by SimpleReach', 'srslide_adminopt' ) . "</h2>"; ?>
    109117
    110118    <?php if ($sr_is_registered) {
     
    113121        $srlogin = get_option('srslide_sr_login');
    114122        $srslide_header_text = get_option('srslide_header_text');
     123        $srslide_style = get_option('srslide_styles');
    115124        $debug_info = create_debug_info();
    116125
     
    136145      <hr />
    137146
    138         <?php echo "<h3>" . __('Slide Settings', 'srslide_adminopt') . "</h3>"; ?>
     147        <?php echo "<h3>" . __('Display Settings', 'srslide_adminopt') . "</h3>"; ?>
    139148
    140149        <div style='float:left;'>
    141150            <form name="srslide_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
     151
    142152                <input type="hidden" name="srslide_save_hidden" value="Y">
    143153
    144                 <table border='0' cellspacing='5'>
     154                <table border='0'>
     155                    <tr>
     156                        <td>
     157                            <div style='margin-bottom:40px;'><?php _e("Edit Header (Max 30 char):"); ?></div>
     158                        </td>
     159                        <td colspan='2'>
     160                            <div style='margin-bottom:20px;'>
     161                                <input style='width:220px;' type="textbox" name="srslide_header_text" value='<?php echo $srslide_header_text; ?>' /><br />
     162                                <span style='font-size:10px;'><?php _e("All letters will be uppercase."); ?> &nbsp; (<?php _e("Default: RECOMMENDED FOR YOU"); ?>)</span>
     163                            </div>
     164                        </td>
     165                    </tr>
     166
     167                    <tr>
     168                        <td colspan='3'>
     169                            <div style='margin-bottom:10px;'>
     170                                <div style='margin-top:5px;float:left;width:80px;overflow:hidden;'><?php _e("Link Color:"); ?></div>
     171                                <?php
     172                                    $srslide_default_link_colors = array('#FE3F10', '#3B5998', '#CC0000');
     173                                    foreach ($srslide_default_link_colors as $color) {
     174                                ?>
     175                                    <div style='margin-top:7px;margin-left:5px;width:40px;overflow:hidden;float:left;'>
     176                                        <input type='radio' style='float:left;margin-top:3px;' name='srslide_style_link_color' value='<?php echo $color; ?>' <?php if ($srslide_style['link']['color'] == $color) { echo "CHECKED"; } ?>>
     177                                        <div style='border:1px solid;background-color:<?php echo $color; ?>;float:left;width:15px;height:15px;margin-left:5px;'></div>
     178                                    </div>
     179                                <?php
     180                                    }
     181                                ?>
     182                                    <input type='radio' name='srslide_style_link_color' value='other' <?php if (!in_array($srslide_style['link']['color'],$srslide_default_link_colors)) { echo "CHECKED"; } ?> style='margin-top:10px;float:left;margin-left:10px;'> &nbsp; <input style='margin-top:3px;width:60px;margin-left:-15px;' type="textbox" name="srslide_style_link_color_text" value='<?php if (!in_array($srslide_style['link']['color'],$srslide_default_link_colors)) { echo "{$srslide_style['link']['color']}"; } ?>' />
     183                                    <div style='margin-left:8px;font-size:12px;float:left;width:80px;overflow:hidden;line-height:16px;'><?php _e("hex code "); ?><br /><span style='font-size:10px;'><?php _e("(eg #FE3F10):"); ?></span></div>
     184                                </div>
     185                            </div>
     186                        </td>
     187                    </tr>
     188
     189                    <tr>
     190                        <td colspan='3'>
     191                            <span style='line-height:50px;'><?php _e("Shift The Slide up by: "); ?></span>
     192                            <select name='srslide_style_element_bottom'>
     193                                <option value='0px' <?php if ($srslide_style['element']['bottom'] == '0px') { echo "SELECTED"; } ?>>0px</option>
     194                                <option value='30px' <?php if ($srslide_style['element']['bottom'] == '30px') { echo "SELECTED"; } ?>>30px</option>
     195                                <option value='40px' <?php if ($srslide_style['element']['bottom'] == '40px') { echo "SELECTED"; } ?>>40px</option>
     196                                <option value='50px' <?php if ($srslide_style['element']['bottom'] == '50px') { echo "SELECTED"; } ?>>50px</option>
     197                                <option value='60px' <?php if ($srslide_style['element']['bottom'] == '60px') { echo "SELECTED"; } ?>>60px</option>
     198                            </select>
     199                        </td>
     200                    </tr>
     201
    145202                    <tr>
    146203                        <td colspan='3'>
    147204                            <input type="checkbox" name="srslide_show_logo" <?php echo $slide_show_logo; ?> />
    148                             <span style='line-height:35px;'><?php _e("I would like to display The Slide logo (increases engagement)"); ?></span>
    149                         </td>
    150                     </tr>
    151 
    152                     <tr>
    153                         <td>
    154                             <span><?php _e("Edit Header (Max 30 char):"); ?></span>
    155                         </td>
    156                         <td colspan='2'>
    157                             <input style='width:220px;' type="textbox" name="srslide_header_text" value='<?php echo $srslide_header_text; ?>' />
    158                         </td>
    159                     </tr>
    160                     <tr>
    161                         <td>&nbsp;</td>
    162                         <td colspan='2'>
    163                             <span style='font-size:10px;'>(<?php _e("default: RECOMMENDED FOR YOU"); ?>)</span>
    164                         </td>
    165                     </tr>
    166 
    167 
    168                     <tr>
    169                         <td style='text-align:right' colspan='3'>
    170                             <input style="font-size:14px;margin-top:5px;" type="submit" name="Submit" value="<?php _e('Save', 'srslide_adminopt' ); ?>" />
     205                            <span style='line-height:25px;'><?php _e("Display The Slide logo (increases engagement)"); ?></span>
    171206                        </td>
    172207                    </tr>
    173208                </table>
     209
     210                <input style="font-size:14px;margin-top:15px;padding:4px;" type="submit" name="Submit" value="<?php _e('Save', 'srslide_adminopt' ); ?>" />
    174211            </form>
    175212        </div>
    176213
    177214        <div style='float:right;'>
    178             <img style='margin-bottom:25px;border:1px solid;' src='/wp-content/plugins/srslide_wordpress/images/example.png'>
     215            <img style='margin-bottom:25px;border:1px solid;' src='/wp-content/plugins/srslide_wordpress/screenshot-1.png'>
    179216        </div>
    180217
  • simplereach-slide/trunk/srslide_functions.php

    r413935 r416668  
    1111function sr_plugin_version()
    1212{
    13     return "0.4.6";
     13    return "0.4.7";
     14}
     15
     16/**
     17 * Convert the $_POST variable into a style hash
     18 *
     19 * @author Eric Lubow <elubow@simplereach.com>
     20 * @param Object $POST Post object being shown on the page
     21 * @return Array $style An associative array of styles for The Slide
     22 */
     23function create_style_hash($POST)
     24{
     25    $style = array();
     26
     27    // Iterate over our $_POST var and rip out the styles to put into a hash
     28    foreach ($POST as $name => $value) {
     29        if (!preg_match('/^srslide_style_(.+?)_(.+?)$/',$name,$style_name)) { continue; }
     30        $style[$style_name[1]][$style_name[2]] = $value;
     31    }
     32
     33    return clean_style_options($style);
     34}
     35
     36/**
     37 * Remove the extra style options prior to save/send to SimpleReach
     38 *
     39 * @author Eric Lubow <elubow@simplereach.com>
     40 * @param Array $style The associative array of styles for The Slide
     41 * @return Array $style The clean associative array of styles for The Slide
     42 */
     43function clean_style_options($style)
     44{
     45    // Remove the link_color_text and just have link_color
     46    if ($style['link']['color'] == 'other') {
     47        $style['link']['color'] = check_hash($style['link']['color_text']);
     48    }
     49    unset($style['link']['color_text']);
     50
     51    return $style;
     52}
     53
     54/**
     55 * Add the leading '#' to a string if it doesn't exist
     56 *
     57 * @author Eric Lubow <elubow@simplereach.com>
     58 * @param String $value Any string
     59 * @return String $value String with the '#' added
     60 */
     61function check_hash($val)
     62{
     63    if (preg_match('/^#/',$val)) {
     64        return $val;
     65    } else {
     66        return "#{$val}";
     67    }
    1468}
    1569
     
    69123        $wptags = wp_get_post_tags($post->ID);
    70124        foreach ($wptags as $tag) {
    71             $tags .= addslashes($tag->name) . ",";
     125            $tags .= $tag->name . ",";
    72126        }
    73127        $tags = rtrim($tags,",");
    74128    }
    75129
    76     return $tags;
     130    return addslashes($tags);
    77131}
    78132
     
    83137 * @author Eric Lubow <elubow@simplereach.com>
    84138 * @param Object $post_data The result of the $_POST data from the registration
    85  * @return Nne
     139 * @return None
    86140 */
    87141function set_srslide_defaults($post_data)
     
    93147
    94148    update_option('srslide_header_text','RECOMMENDED FOR YOU');
     149
     150    $style_defaults = array(
     151        'element' => array(
     152            'bottom' => '0px'
     153        ),
     154        'link' => array(
     155            'color' => 'FE3F10'
     156        )
     157    );
     158    update_option('srslide_styles',$style_defaults);
     159}
     160
     161
     162/**
     163 * Update The Slide styles on the SimpleReach site
     164 *
     165 * @author Eric Lubow <elubow@simplereach.com>
     166 * @param Array $styles Style to be converted to JSON
     167 * @return String OK or error string
     168 */
     169function update_slide_styles()
     170{
     171    // Pull all the necessary options
     172    $srpid = get_option('srslide_pid');
     173    $srlogin = get_option('srslide_sr_login');
     174    $srapi_key = get_option('srslide_api_key');
     175    $srslide_style = get_option('srslide_styles');
     176
     177    // Setup our POST parameters
     178    $encoded_params = 'ts='.(int)gmdate('U').'&';
     179    $encoded_params .= "pid=".urlencode($srpid)."&";
     180    $encoded_params .= "login=".urlencode($srlogin)."&";
     181
     182    // Handle if the user's API key isn't saved in WP
     183    if (strlen($srapi_key) != 32) {
     184      $encoded_params .= "pass=".urlencode(get_option('srslide_sr_pass'))."&";
     185    } else {
     186      $encoded_params .= "api_key=".urlencode($srapi_key)."&";
     187    }
     188
     189    // Add the styles to the POST
     190    $style_array = array('style' => get_option('srslide_styles'));
     191    $encoded_params .= http_build_query($style_array);
     192
     193    // Curl call for registration
     194    $curl = curl_init();
     195    curl_setopt($curl, CURLOPT_URL, "https://www.simplereach.com/publisher/generate_slide_css");
     196    curl_setopt($curl, CURLOPT_POST, count(explode('&',$encoded_params)));
     197    curl_setopt($curl, CURLOPT_POSTFIELDS, $encoded_params);
     198    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     199    $curl_resp = curl_exec($curl);
     200    curl_close($curl);
     201
     202    // Decode the JSON
     203    $resp = json_decode($curl_resp);
     204
     205    if ($resp->{'success'}) {
     206        return "OK";
     207    } else {
     208        if ($resp->{'error'} == 'Incorrect Timestamp') {
     209            return "There was an error while you were attempting to register. Please try again or contact <a href='mailto:support@simplereach.com'>SimpleReach support</a> if you believe you have received this message in error.";
     210        } else if ($resp->{'error'} == 'Invalid Password') {
     211            return "The user name that you are attempting to register with already exists, but the password you entered was incorrect. Please try again or contact <a href='mailto:support@simplereach.com'>SimpleReach support</a> if you believe you have received this message in error.";
     212        } else {
     213            // We should never get here
     214            return "There was an error contacting SimpleReach. Please try saving your options again.";
     215        }
     216    }
     217
     218    // We should never get here either
     219    return "There was an error contacting SimpleReach. Please try your re-saving your options.";
    95220}
    96221
Note: See TracChangeset for help on using the changeset viewer.