Plugin Directory

Changeset 478158


Ignore:
Timestamp:
12/20/2011 07:31:31 PM (14 years ago)
Author:
elubow
Message:

Update code to 0.5.9

Location:
simplereach-slide/trunk
Files:
5 edited

Legend:

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

    r464325 r478158  
    66Requires at least: 2.7
    77Tested up to: 3.2.1
    8 Stable tag: 0.5.8
     8Stable tag: 0.5.9
    99
    1010The Slide recommends related posts from within your site on a widget that "slides" in at the bottom of the page.
     
    5858
    5959== Changelog ==
     60
     61= 0.5.9 =
     62* Custom CSS file field
     63* Post end dates
     64* Additional debugging
     65* Lots of bug fixes
    6066
    6167= 0.5.8 =
  • simplereach-slide/trunk/srslide.php

    r464328 r478158  
    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.5.8
     6    Version: 0.5.9
    77    Author: SimpleReach
    88    Author URI: https://www.simplereach.com
    99    */
    1010
    11 define('SRSLIDE_PLUGIN_VERSION', '0.5.8');
     11define('SRSLIDE_PLUGIN_VERSION', '0.5.9');
    1212define('SRSLIDE_PLUGIN_DIR', dirname(__FILE__));
    1313define('SRSLIDE_PLUGIN_URL', plugin_dir_url(__FILE__));
     
    3030        $post_id = $post_id->ID;
    3131    }
    32 
    3332
    3433    // Return the content on anything other than post pages
     
    8483$offsetTag = (!empty($offset)) ? 'offset: \'' . $offset . '\',' : '';
    8584
    86 $rv = <<< SRSLIDE_SCRIPT_TAG
    87 <!-- SimpleReach Slide Plugin Version: {$SRSLIDE_PLUGIN_VERSION} -->
    88 <script type='text/javascript' id='simplereach-slide-tag'>
    89     __spr_config = {
    90       pid: '{$sr_pub_id}',
    91       title: '{$title}',
    92       ckw: '{$tags}',
    93       chan: '{$channels}',
    94       {$offsetTag}
    95       {$iconTag}
    96       no_slide: '{$disable_on_post}',
    97       slide_logo: {$slide_logo},
    98       pub: '{$published_date}',
    99       url: '{$canonical_url}',
    100       header: '{$header_text}'
    101     };
    102     var content = document.getElementById('simplereach-slide-tag').parentNode, loc;
    103     if (content.className){ loc = '.' + content.className; }
    104     if (content.id){ loc = '#' + content.id; }
    105     __spr_config.loc = loc || content;
    106     (function(){
    107       var s = document.createElement('script');
    108       s.async = true;
    109       s.type = 'text/javascript';
    110       s.src = document.location.protocol + '//d8rk54i4mohrb.cloudfront.net/js/slide.js';
    111       __spr_config.css = document.location.protocol + '//d8rk54i4mohrb.cloudfront.net/css/p/$sr_pub_id.css';
    112       (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
    113     })();
    114 </script>
    115 
    116 SRSLIDE_SCRIPT_TAG;
     85$use_css_url = '\'document.location.protocol + \'//d8rk54i4mohrb.cloudfront.net/css/p/'.$sr_pub_id.'.css\'';
     86$css_option = get_option('srslide_css_option');
     87if ($css_option == 2) {
     88    $css_url = get_option('srslide_css_url');
     89    if (function_exists('filter_var')) {
     90        if (filter_var($css_url,FILTER_VALIDATE_URL)) {
     91            $use_css_url = "'".$css_url."'";
     92        }
     93    }
     94    else {
     95        $use_css_url = "'".str_replace(array('"',"'",'<'),array(''),$css_url)."'";
     96    }
     97}
     98
     99
     100
     101    $rv = '<!-- SimpleReach Slide Plugin Version: '.$SRSLIDE_PLUGIN_VERSION.' -->'."\n";
     102    $rv .= '<script type=\'text/javascript\' id=\'simplereach-slide-tag\'>'."\n";
     103    $rv .= '    __spr_config = {'."\n";
     104    $rv .= '      pid: \''.$sr_pub_id.'\','."\n";
     105    $rv .= '      title: \''.$title.'\','."\n";
     106    $rv .= '      ckw: \''.$tags.'\','."\n";
     107    $rv .= '      chan: \''.$channels.'\','."\n";
     108    if (!empty($offsetTag)) {
     109        $rv .= '      '.$offsetTag.''."\n";
     110    }
     111    if (!empty($iconTag)) {
     112        $rv .= '      '.$iconTag.''."\n";
     113    }
     114    if ($post_end_date = get_post_meta($post_id,'_srslide_post_end_date',true)) {
     115        $end_date_pattern = '/(\d+)\-(\d+)\-(\d+)\s+(\d+):(\d+):(\d+)/';
     116        if (preg_match($end_date_pattern,$post_end_date)) {
     117            $rv .= '      end: \''.$post_end_date.'\','."\n";
     118        }
     119    }
     120    $rv .= '      no_slide: \''.$disable_on_post.'\','."\n";
     121    $rv .= '      slide_logo: '.$slide_logo.','."\n";
     122    $rv .= '      pub: \''.$published_date.'\','."\n";
     123    $rv .= '      url: \''.$canonical_url.'\','."\n";
     124    $rv .= '      header: \''.$header_text.'\''."\n";
     125    $rv .= '    };'."\n";
     126    $rv .= '    var content = document.getElementById(\'simplereach-slide-tag\').parentNode, loc;'."\n";
     127    $rv .= '    if (content.className){ loc = \'.\' + content.className; }'."\n";
     128    $rv .= '    if (content.id){ loc = \'#\' + content.id; }'."\n";
     129    $rv .= '    __spr_config.loc = loc || content;'."\n";
     130    $rv .= '    (function(){'."\n";
     131    $rv .= '    var s = document.createElement(\'script\');'."\n";
     132    $rv .= '      s.async = true;'."\n";
     133    $rv .= '      s.type = \'text/javascript\';'."\n";
     134    $rv .= '      s.src = document.location.protocol + \'//d8rk54i4mohrb.cloudfront.net/js/slide.js\';'."\n";
     135    $rv .= '      __spr_config.css = '.$use_css_url.';'."\n";
     136    $rv .= '      var tg = document.getElementsByTagName(\'head\')[0];'."\n";
     137    $rv .= '      if (!tg) {tg = document.getElementsByTagName(\'body\')[0];}'."\n";
     138    $rv .= '      if (tg) {tg.appendChild(s);}'."\n";
     139    $rv .= '    })();'."\n";
     140    $rv .= '</script>'."\n";
    117141
    118142    return $content . $rv;
  • simplereach-slide/trunk/srslide_admin.php

    r458725 r478158  
    1111    $srslide_style_element_bottom = (!empty($_POST['srslide_style_element_bottom'])) ? $_POST['srslide_style_element_bottom'] : '';
    1212    $srslide_use_pages            = (!empty($_POST['srslide_use_pages']));
     13    $srslide_css_option            = (!empty($_POST['srslide_css_option'])) ? $_POST['srslide_css_option'] : 1;
     14    $srslide_css_url            = (!empty($_POST['srslide_css_url'])) ? $_POST['srslide_css_url'] : '';
    1315
    1416    // Set up debug info and support link
     
    5153            update_option('srslide_pid', $_POST['srslide_pid']);
    5254        }
     55
     56
     57    $url_error = false;
     58    if ($srslide_css_option != 2) {
     59        $srslide_css_url = '';
     60        update_option('srslide_css_option',1);
     61        update_option('srslide_css_url', '');
     62    }
     63    else {
     64        if (function_exists('filter_var')) {
     65            if (!filter_var($srslide_css_url,FILTER_VALIDATE_URL)) {
     66                array_push($errors, __("You selected a custom CSS URL, but the URL you entered is blank or invalid.",'srslide'));
     67                $url_error = true;
     68            }
     69        }
     70        else {
     71            $srslide_css_url = str_replace(array('"',"'",'<'),array(''),$srslide_css_url);
     72        }
     73        if (!$url_error) {
     74            update_option('srslide_css_option',2);
     75            update_option('srslide_css_url', $srslide_css_url);
     76        }
     77    }
     78
    5379
    5480        // Convert the style settings into a hash and save it
     
    205231              $slide_cat_as_chan = '';
    206232            }
     233
     234        $srslide_css_option = get_option('srslide_css_option');
     235        $srslide_css_url = get_option('srslide_css_url');
    207236    ?>
    208237
     
    304333                        </td>
    305334                    </tr>
     335                   <tr>
     336                        <td colspan="3">
     337                               Stylesheet:&nbsp;
     338                                  <input type="radio" name="srslide_css_option" value="1" <?php echo ($srslide_css_option != 2) ? 'Checked' : ''; ?>>&nbsp;Default&nbsp;&nbsp;
     339                  <input type="radio" name="srslide_css_option" value="2" <?php echo ($srslide_css_option == 2) ? 'Checked' : ''; ?>>&nbsp;Custom&nbsp;&nbsp;
     340                  &nbsp;&nbsp;URL:&nbsp;
     341                <input type="textbox" name="srslide_css_url" size="30" value="<?php echo ($srslide_css_option == 2) ? $srslide_css_url : ''; ?>">
     342                        </td>
     343                    </tr>
     344
    306345                </table>
    307346
  • simplereach-slide/trunk/srslide_functions.php

    r464325 r478158  
    9595    $attrs['curl_https_enabled'] = _srslide_get_curl_ssl_enabled();
    9696    $attrs['wp_plugins']         = _srslide_get_wp_plugins();
     97    if ($theme_name = get_current_theme()) {
     98    $attrs['theme']          = $theme_name;
     99    $theme_data = get_theme_data(get_stylesheet_directory().'/style.css' );
     100    if (is_array($theme_data)) {
     101        foreach ($theme_data as $k=>$v) {
     102            $attrs['theme_'.$k] = $v;
     103        }
     104    }
     105    }
    97106    $str = '';
    98107    foreach ($attrs as $attr => $value) {
     
    151160        }
    152161    } else {
    153         return 'NONE'; 
     162        return 'NONE';
    154163    }
    155164}
     
    335344
    336345/**
    337  * srslide_post_url 
    338  * 
    339  * @param mixed $url 
    340  * @param array $data 
     346 * srslide_post_url
     347 *
     348 * @param mixed $url
     349 * @param array $data
    341350 * @access public
    342351 * @return void
     
    351360        }
    352361    } catch (Exception $e) {
    353         $url = preg_replace('/https/', 'http', $url); 
     362        $url = preg_replace('/https/', 'http', $url);
    354363
    355364        if (extension_loaded('curl')) {
     
    384393}
    385394
    386 function _srslideStreamPostUrl($url, $data=array()) 
     395function _srslideStreamPostUrl($url, $data=array())
    387396{
    388397    if (!extension_loaded('openssl')) {
     
    415424
    416425function srslide_validate_password($password) {
    417     return preg_match('/^[a-z0-9_-]{6,20}$/i', $password);
     426    return preg_match('/^[a-z0-9_-!;,]{6,99}$/i', $password);
    418427}
    419428?>
  • simplereach-slide/trunk/srslide_post.php

    r464325 r478158  
    1212    if (function_exists('add_meta_box')) {
    1313        add_meta_box('srslide',__('The Slide', 'srslide'), 'srslide_meta','post');
     14    add_meta_box('srslide',__('The Slide', 'srslide'), 'srslide_meta','page');
    1415    }
    1516}
     
    3940    $tags           = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_srslide_tags', true)));
    4041    $disable_slide_on_post  = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_srslide_disable_on_post', true)));
     42    if ($post_end_date             = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_srslide_post_end_date', true)))) {
     43    $end_date_pattern = '/(\d+)\-(\d+)\-(\d+)\s+(\d+):(\d+):(\d+)/';
     44    if (preg_match($end_date_pattern,$post_end_date,$matches)) {
     45            $post_end_year = $matches[1];
     46        $post_end_month = $matches[2];
     47        $post_end_day = $matches[3];
     48        $post_end_hour = $matches[4];
     49        $post_end_minute = $matches[5];
     50        $post_end_meridian = 1;
     51        if ($post_end_hour > 12) {
     52            $post_end_hour -= 12;
     53            $post_end_meridian = 2;
     54        }
     55    }
     56    }
    4157    ?>
    4258    <div id="srslide_meta_box">
     
    5672            </tr>
    5773            <tr>
     74                <th scope="row"><?php print __('End Date:', 'srslide') ?></th>
     75                <td>
     76                        <select name="srslide_post_end_month" id="srslide_post_end_month" value="">
     77<?php
     78$month_list = array('0' => '-----', '01' => 'January', '02' => 'February',
     79            '03' => 'March', '04' => 'April', '05' => 'May',
     80            '06' => 'June', '07' => 'July', '08' => 'August',
     81            '09' => 'September', '10' => 'October', '11' => 'November',
     82            '12' => 'December');
     83foreach ($month_list as $k=>$v) {
     84    echo "\t\t\t\t".'<option value="'.$k.'"';
     85    if ($k == $post_end_month) {
     86        echo ' selected >';
     87    }
     88    else {
     89        echo '>';
     90    }
     91    echo $v.'</option>'."\n";
     92}
     93?>
     94                        </select>
     95                        <select name="srslide_post_end_day" id="srslide_post_end_day" value="">
     96                <option value='0'>------</option>
     97<?php
     98for ($i=1; $i <= 31; $i++) {
     99    $j = sprintf("%02d",$i);
     100        echo "\t\t\t\t".'<option value="'.$j.'"';
     101        if ($i == $post_end_day) {
     102                echo ' selected';
     103        }
     104        echo '>'.$j.'</option>'."\n";
     105}
     106?>
     107                        </select>
     108                        <select name="srslide_post_end_year" id="srslide_post_end_year" value="">
     109<?php
     110$year = (int) date("Y");
     111$maxyear = $year + 5;
     112for ($i = $year;$i < $maxyear;$i++) {
     113        echo "\t\t\t\t".'<option value="'.$i.'"';
     114    if ($i == $post_end_year) {
     115        echo ' selected';
     116    }
     117    echo '>'.$i.'</option>'."\n";
     118}
     119?>
     120                        </select>
     121
     122                        <select name="srslide_post_end_hour" id="srslide_post_end_hour" value="">
     123<?php
     124for ($i = 1;$i < 13;$i++) {
     125        echo "\t\t\t\t".'<option value="'.$i.'"';
     126        if ($i == $post_end_hour) {
     127                echo ' selected';
     128        }
     129        echo '>'.$i.'</option>'."\n";
     130}
     131?>
     132                        </select>
     133                        <select name="srslide_post_end_minute" id="srslide_post_end_minute" value="">
     134<?php
     135for ($i = 0;$i < 60;$i++) {
     136    $j = sprintf("%02d",$i);
     137        echo "\t\t\t\t".'<option value="'.$j.'"';
     138        if ($i == $post_end_minute) {
     139                echo ' selected';
     140        }
     141        echo '>'.$j.'</option>'."\n";
     142}
     143?>
     144                        </select>
     145<input type="radio" name="srslide_post_end_meridian" value="1" <?php echo ($post_end_meridian != 2) ? 'Checked' : ''; ?>>&nbsp;AM&nbsp;&nbsp;
     146<input type="radio" name="srslide_post_end_meridian" value="2" <?php echo ($post_end_meridian == 2) ? 'Checked' : ''; ?>>&nbsp;PM&nbsp;&nbsp;
     147
     148
     149
     150                </td>
     151            </tr>
     152            <tr>
    58153                <th scope="row"><?php print __('Disable Slide on post:', 'srslide') ?></th>
    59                 <td><input name="srslide_disable_on_post" id="srslide_disable_on_post" type="checkbox" <?php if ($disable_slide_on_post) echo 'checked="1"'; ?> /></td>
    60             </tr>
     154                <td><input name="srslide_disable_on_post" id="srslide_disable_on_post" type="checkbox"  <?php if ($disable_slide_on_post) echo 'checked="1"'; ?> /></td>
     155            </tr>
     156
    61157        </table>
    62158    </div>
     
    106202    $tags           = (!empty($_POST['srslide_tags']))      ? $_POST['srslide_tags'] : '';
    107203    $icon           = (!empty($_POST['srslide_article_icon']))  ? $_POST['srslide_article_icon'] : '';
     204    $post_end_month     = (!empty($_POST['srslide_post_end_month']))    ? $_POST['srslide_post_end_month'] : '';
     205    $post_end_day             = (!empty($_POST['srslide_post_end_day']))    ? $_POST['srslide_post_end_day'] : '';
     206    $post_end_year             = (!empty($_POST['srslide_post_end_year']))    ? $_POST['srslide_post_end_year'] : '';
     207    $post_end_hour             = (!empty($_POST['srslide_post_end_hour']))    ? $_POST['srslide_post_end_hour'] : '';
     208    $post_end_minute             = (!empty($_POST['srslide_post_end_minute']))    ? $_POST['srslide_post_end_minute'] : '';
     209    $post_end_meridian             = (!empty($_POST['srslide_post_end_meridian']))    ? $_POST['srslide_post_end_meridian'] : '';
    108210
    109211    // Clear everything out first to start with a clean slate
     
    112214    delete_post_meta($id, '_srslide_article_icon');
    113215    delete_post_meta($id, '_srslide_disable_on_post');
     216    delete_post_meta($id, '_srslide_post_end_date');
    114217
    115218    // Ignore if the slide should be hidden
     
    153256        add_post_meta($id, '_srslide_article_icon', $icon);
    154257    }
    155 }
    156 ?>
     258
     259    if (($post_end_month > 0) && ($post_end_day > 0)) {
     260        if (checkdate($post_end_month,$post_end_day,$post_end_year)) {
     261            if ($post_end_meridian == 2) {
     262                $post_end_hour += 12;
     263            }
     264            $post_end_date = sprintf("%04d-%02d-%02d %02d:%02d:00",$post_end_year,$post_end_month,$post_end_day,$post_end_hour,$post_end_minute);
     265            add_post_meta($id,'_srslide_post_end_date',$post_end_date);
     266        }
     267    }
     268}
     269?>
Note: See TracChangeset for help on using the changeset viewer.