Changeset 478158
- Timestamp:
- 12/20/2011 07:31:31 PM (14 years ago)
- Location:
- simplereach-slide/trunk
- Files:
-
- 5 edited
-
readme.txt (modified) (2 diffs)
-
srslide.php (modified) (3 diffs)
-
srslide_admin.php (modified) (4 diffs)
-
srslide_functions.php (modified) (6 diffs)
-
srslide_post.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simplereach-slide/trunk/readme.txt
r464325 r478158 6 6 Requires at least: 2.7 7 7 Tested up to: 3.2.1 8 Stable tag: 0.5. 88 Stable tag: 0.5.9 9 9 10 10 The Slide recommends related posts from within your site on a widget that "slides" in at the bottom of the page. … … 58 58 59 59 == Changelog == 60 61 = 0.5.9 = 62 * Custom CSS file field 63 * Post end dates 64 * Additional debugging 65 * Lots of bug fixes 60 66 61 67 = 0.5.8 = -
simplereach-slide/trunk/srslide.php
r464328 r478158 4 4 Plugin URI: https://www.simplereach.com 5 5 Description: After installation, you must click '<a href='options-general.php?page=SimpleReach-Slide'>Settings → SimpleReach Slide</a>' to turn on The Slide. 6 Version: 0.5. 86 Version: 0.5.9 7 7 Author: SimpleReach 8 8 Author URI: https://www.simplereach.com 9 9 */ 10 10 11 define('SRSLIDE_PLUGIN_VERSION', '0.5. 8');11 define('SRSLIDE_PLUGIN_VERSION', '0.5.9'); 12 12 define('SRSLIDE_PLUGIN_DIR', dirname(__FILE__)); 13 13 define('SRSLIDE_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 30 30 $post_id = $post_id->ID; 31 31 } 32 33 32 34 33 // Return the content on anything other than post pages … … 84 83 $offsetTag = (!empty($offset)) ? 'offset: \'' . $offset . '\',' : ''; 85 84 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'); 87 if ($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"; 117 141 118 142 return $content . $rv; -
simplereach-slide/trunk/srslide_admin.php
r458725 r478158 11 11 $srslide_style_element_bottom = (!empty($_POST['srslide_style_element_bottom'])) ? $_POST['srslide_style_element_bottom'] : ''; 12 12 $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'] : ''; 13 15 14 16 // Set up debug info and support link … … 51 53 update_option('srslide_pid', $_POST['srslide_pid']); 52 54 } 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 53 79 54 80 // Convert the style settings into a hash and save it … … 205 231 $slide_cat_as_chan = ''; 206 232 } 233 234 $srslide_css_option = get_option('srslide_css_option'); 235 $srslide_css_url = get_option('srslide_css_url'); 207 236 ?> 208 237 … … 304 333 </td> 305 334 </tr> 335 <tr> 336 <td colspan="3"> 337 Stylesheet: 338 <input type="radio" name="srslide_css_option" value="1" <?php echo ($srslide_css_option != 2) ? 'Checked' : ''; ?>> Default 339 <input type="radio" name="srslide_css_option" value="2" <?php echo ($srslide_css_option == 2) ? 'Checked' : ''; ?>> Custom 340 URL: 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 306 345 </table> 307 346 -
simplereach-slide/trunk/srslide_functions.php
r464325 r478158 95 95 $attrs['curl_https_enabled'] = _srslide_get_curl_ssl_enabled(); 96 96 $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 } 97 106 $str = ''; 98 107 foreach ($attrs as $attr => $value) { … … 151 160 } 152 161 } else { 153 return 'NONE'; 162 return 'NONE'; 154 163 } 155 164 } … … 335 344 336 345 /** 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 341 350 * @access public 342 351 * @return void … … 351 360 } 352 361 } catch (Exception $e) { 353 $url = preg_replace('/https/', 'http', $url); 362 $url = preg_replace('/https/', 'http', $url); 354 363 355 364 if (extension_loaded('curl')) { … … 384 393 } 385 394 386 function _srslideStreamPostUrl($url, $data=array()) 395 function _srslideStreamPostUrl($url, $data=array()) 387 396 { 388 397 if (!extension_loaded('openssl')) { … … 415 424 416 425 function 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); 418 427 } 419 428 ?> -
simplereach-slide/trunk/srslide_post.php
r464325 r478158 12 12 if (function_exists('add_meta_box')) { 13 13 add_meta_box('srslide',__('The Slide', 'srslide'), 'srslide_meta','post'); 14 add_meta_box('srslide',__('The Slide', 'srslide'), 'srslide_meta','page'); 14 15 } 15 16 } … … 39 40 $tags = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_srslide_tags', true))); 40 41 $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 } 41 57 ?> 42 58 <div id="srslide_meta_box"> … … 56 72 </tr> 57 73 <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'); 83 foreach ($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 98 for ($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; 112 for ($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 124 for ($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 135 for ($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' : ''; ?>> AM 146 <input type="radio" name="srslide_post_end_meridian" value="2" <?php echo ($post_end_meridian == 2) ? 'Checked' : ''; ?>> PM 147 148 149 150 </td> 151 </tr> 152 <tr> 58 153 <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 61 157 </table> 62 158 </div> … … 106 202 $tags = (!empty($_POST['srslide_tags'])) ? $_POST['srslide_tags'] : ''; 107 203 $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'] : ''; 108 210 109 211 // Clear everything out first to start with a clean slate … … 112 214 delete_post_meta($id, '_srslide_article_icon'); 113 215 delete_post_meta($id, '_srslide_disable_on_post'); 216 delete_post_meta($id, '_srslide_post_end_date'); 114 217 115 218 // Ignore if the slide should be hidden … … 153 256 add_post_meta($id, '_srslide_article_icon', $icon); 154 257 } 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.