Changeset 470073
- Timestamp:
- 12/02/2011 02:46:59 AM (14 years ago)
- Location:
- auto-more-tag/trunk
- Files:
-
- 3 edited
-
auto-more-options-page.php (modified) (2 diffs)
-
auto-more.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
auto-more-tag/trunk/auto-more-options-page.php
r461477 r470073 14 14 <div class="wrap"> 15 15 <h2>Auto More Tag by <a href="http://travisweston.com/">Travis Weston</a></h2> 16 <?php $options = get_option('tw_auto_more_tag'); ?> 16 <?php $options = get_option('tw_auto_more_tag'); 17 if(isset($_GET['settings-updated']) && isset($options['auto_update']) && $options['auto_update'] == true){ 18 $this->updateAll(); 19 } 20 ?> 17 21 <?php 18 22 if(hasErrors($options['messages']) || hasNotices($options['messages']) || hasWarnings($options['messages'])){ … … 90 94 <label for="tw_auto_more_tag[credit_me]">Give Credit Where Credit is Due?</label> 91 95 <select id="tw_auto_more_tag[credit_me]" name="tw_auto_more_tag[credit_me]"> 92 <option value="0" <?php echo (!isset($options['credit_me']) || $options['credit_me'] == false) ? 'selected="SELECTED" ' : null; ?>/>No 93 <option value="1" <?php echo (isset($options['credit_me']) && $options['credit_me'] == true) ? 'selected="SELECTED" ' : null;?>/>Yes 96 <option value="0" <?php echo (isset($options['credit_me']) && $options['credit_me'] == false) ? 'selected="SELECTED" ' : null; ?>/>No 97 <option value="1" <?php echo (!isset($options['credit_me']) || $options['credit_me'] == true) ? 'selected="SELECTED" ' : null;?>/>Yes 98 </select> 99 </div> 100 <div> 101 <label for="tw_auto_more_tag[auto_update]">Auto Update Posts On Settings Update?</label> 102 <select id="tw_auto_more_tag[auto_update]" name="tw_auto_more_tag[auto_update]"> 103 <option value="1" <?php echo (!isset($options['auto_update']) || $options['auto_update'] == true) ? 'selected="SELECTED" ' : null;?>/>Yes 104 <option value="0" <?php echo (isset($options['auto_update']) && $options['auto_update'] == false) ? 'selected="SELECTED" ' : null;?>/>No 105 </select> 106 </div> 107 <div> 108 <label for="tw_auto_more_tag[ignore_man_tag]">Ignore Manually Inserted Tags?</label> 109 <select id="tw_auto_more_tag[ignore_man_tag]" name="tw_auto_more_tag[ignore_man_tag]"> 110 <option value="1" <?php echo (!isset($options['ignore_man_tag']) || $options['ignore_man_tag'] == true) ? 'selected="SELECTED" ' : null;?>/>Yes 111 <option value="0" <?php echo (isset($options['ignore_man_tag']) && $options['ignore_man_tag'] == false) ? 'selected="SELECTED" ' : null;?>/>No 94 112 </select> 95 113 </div> -
auto-more-tag/trunk/auto-more.php
r461477 r470073 6 6 Author: Travis Weston 7 7 Author URI: http://travisweston.com/ 8 Version: 2. 08 Version: 2.1 9 9 */ 10 file_put_contents('debug.log', 'test', FILE_APPEND); 10 11 11 if(!defined('TW_AUTO_MORE_TAG')){ 12 12 … … 20 20 21 21 public function __construct() { 22 global $wpdb; 23 24 $this->_db = &$wpdb; 25 22 26 self::$_instance = $this; 23 27 } … … 45 49 $length = $options['quantity']; 46 50 $breakOn = $options['break']; 47 48 $shortCode = strpos($data, '[amt_override'); 49 50 if($shortCode !== false){ 51 return $data; 51 52 $moreTag = strpos($data, '[amt_override]'); 53 54 if($moreTag !== false && $options['ignore_man_tag'] != true){ 55 56 return self::$_instance->manual($data); 57 52 58 } 53 59 … … 71 77 } 72 78 79 public function manual($data) { 80 81 $data = str_replace('<!--more-->', '', $data); 82 $data = str_replace('[amt_override]','[amt_override]<!--more-->', $data); 83 84 return $data; 85 86 } 87 73 88 public function byWord($data, $length, $breakOn) { 74 89 // UNUSED IN CURRENT VERSION … … 96 111 $temp = substr($data, 0, $pos); 97 112 $temp_end = substr($data, $pos); 113 if(empty($temp_end) || trim($temp_end) == null || strlen($temp_end) <= 0) 114 return $data; 115 98 116 $data = $temp.'<!--more-->'.$temp_end; 99 117 … … 127 145 $temp = substr($data, 0, $pos); 128 146 $temp_end = substr($data, $pos); 147 148 if(empty($temp_end) || trim($temp_end) == null) 149 return $data; 150 129 151 $data = $temp.'<!--more-->'.$temp_end; 130 152 … … 141 163 public function validateOptions($input){ 142 164 165 143 166 $start = $input; 144 167 145 168 $input['messages'] = array( 146 169 'errors' => array(), … … 164 187 } 165 188 189 $input['ignore_man_tag'] = (isset($input['ignore_man_tag']) && ((bool)$input['ignore_man_tag'] == true)) ? true : false; 190 166 191 $input['units'] = ((int)$input['units'] == 1) ? 1 : (((int)$input['units'] == 2) ? 2 : 3); 167 192 … … 184 209 185 210 $input['break'] = (isset($input['break']) && (int)$input['break'] == 2) ? 2 : 1; 186 187 $input['credit'] = true; 188 211 189 212 return $input; 190 213 … … 201 224 } 202 225 203 #public function manualOverride($atts, $content = null, $code = null){ 204 # #NOT CURRENTLY WORKING 205 # return '<!--more-->'; 206 #} 226 private function updateAll() { 227 228 $posts = get_posts(array( 229 'numberposts' => '-1', 230 'post_status' => 'publish', 231 'post_type' => 'post' 232 )); 233 234 if(count($posts) > 0){ 235 global $post; 236 foreach($posts as $post){ 237 setup_postdata($post); 238 $post->post_content = self::addTag($post->post_content); 239 wp_update_post($post); 240 } 241 } 242 243 } 244 245 public function manualOverride($atts, $content = null, $code = null){ 246 // We just want to make this tag disappear. Let's just make it go away now... 247 return null; 248 } 249 207 250 } 208 251 $tw_auto_more_tag = new tw_auto_more_tag(); … … 212 255 add_action('wp_footer', 'tw_auto_more_tag::doFooter'); 213 256 add_filter('content_save_pre', 'tw_auto_more_tag::addTag', '1', 2); 214 #add_shortcode('amt_override', array($tw_auto_more_tag, 'manualOverride')); 215 define('TW_AUTO_MORE_TAG', '<div style="text-align: center;"><a href="http://travisweston.com" target="_blank" style="font-size: 8pt;">Auto More Tag powered by TravisWeston.com</a></div>'); 257 add_shortcode('amt_override', array($tw_auto_more_tag, 'manualOverride')); 258 259 define('TW_AUTO_MORE_TAG', '<div style="text-align: center;"><a href="http://travisweston.com" target="_blank" style="font-size: 7pt;">PHP/MySQL Components, WordPress Plugins, and Technology Opinions at TravisWeston.com</a></div>'); 216 260 } -
auto-more-tag/trunk/readme.txt
r461477 r470073 5 5 Requires at least: 3.2.1 6 6 Tested up to: 3.2.1 7 Stable tag: 2. 07 Stable tag: 2.1 8 8 9 9 Allows you to add a More tag to your post automatically upon publication. … … 35 35 == Changelog == 36 36 37 = 2.1 = 38 39 Added option to automatically update when new settings are saved. This cycles through all your posts, and updates each one based on the new Auto More Tag settings. Also added in a shortcode for manual placement, for those times when you just have to do it yourself. 40 37 41 = 2.0 = 38 42
Note: See TracChangeset
for help on using the changeset viewer.