Changeset 1245503
- Timestamp:
- 09/14/2015 10:56:20 PM (11 years ago)
- Location:
- my-optional-modules/trunk
- Files:
-
- 4 edited
-
class.myoptionalmodules-shortcodes.php (modified) (3 diffs)
-
includes/css/myoptionalmodules10.css (modified) (3 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
my-optional-modules/trunk/class.myoptionalmodules-shortcodes.php
r1245317 r1245503 3 3 * CLASS myoptionalmodules_shortcodes() 4 4 * 5 * File update: 10.1. 65 * File update: 10.1.7 6 6 * 7 7 * All shortcodes for My Optional Modules … … 216 216 shortcode_atts ( 217 217 array ( 218 'sub' => '' , 218 'sub' => '' , 219 'thread' => '' , 219 220 'limit' => 10 , 220 221 'title' => '' , … … 226 227 227 228 $sub = sanitize_text_field ( $sub ); 229 $thread = sanitize_text_field ( $thread ); 228 230 $limit = intval ( $limit ); 229 231 $title = sanitize_text_field ( $title ); 230 232 $output = null; 231 232 if ( $sub ) { 233 234 $url = "https://www.reddit.com/r/{$sub}/.rss?limit={$limit}"; 233 $count = 0; 234 235 if ( $sub || $thread ) { 236 237 if ( $sub && !$thread ) { 238 $url = "https://www.reddit.com/r/{$sub}/.rss?limit={$limit}"; 239 } elseif ( $thread && !$sub ) { 240 $url = "{$thread}/.rss?limit={$limit}"; 241 } else { 242 $url = null; 243 } 235 244 236 $content = file_get_contents( $url ); 237 238 $x = new SimpleXmlElement( $content ); 239 $x->channel->title = sanitize_text_field ( $x->channel->title ); 240 $x->channel->description = sanitize_text_field ( $x->channel->description ); 245 if ( $url ) { 241 246 242 if ( 'search results' != strtolower ( $x->channel->title ) ) { 243 244 $channel_title = strtolower( str_replace( array( 'https://www.reddit.com/r/', '/' ), '', $x->channel->link ) ); 247 $content = file_get_contents( $url ); 248 249 $x = new SimpleXmlElement( $content ); 250 $x->channel->title = sanitize_text_field ( $x->channel->title ); 251 $x->channel->description = sanitize_text_field ( $x->channel->description ); 245 252 246 if ( '%blank%' == $title ) { 247 $title = null; 248 } elseif ( $title ) { 249 $title = "<h1>{$title}</h1>"; 250 } elseif ( !$title ) { 251 $title = "<h1><a href='{$x->channel->link}'>{$x->channel->title}</a></h1>"; 253 if ( 'search results' != strtolower ( $x->channel->title ) ) { 254 255 $channel_title = strtolower( str_replace( array( 'https://www.reddit.com/r/', '/' ), '', $x->channel->link ) ); 256 257 if ( '%blank%' == $title ) { 258 $title = null; 259 } elseif ( $title ) { 260 $title = "<h1>{$title}</h1>"; 261 } elseif ( !$title ) { 262 $title = "<h1><a href='{$x->channel->link}'>{$x->channel->title}</a></h1>"; 263 } 264 265 if ( $sub && !$thread ) { 266 if ( $description ) { 267 $description = "<h2>{$x->channel->description}</h2>"; 268 } else { 269 $description = null; 270 } 271 } elseif ( $thread && !$sub ) { 272 $description = null; 273 $title = null; 274 } 275 276 $output .= " 277 <div class='mom-reddit-feed'> 278 {$title}{$description} 279 280 "; 281 foreach( $x->channel->item as $entry ){ 282 ++$count; 283 $post_type = null; 284 if( strpos( $entry->description, 'SC_OFF' ) !== false ){ 285 $post_type = "<small>(self.{$channel_title})</small>"; 286 } 287 if ( $sub && !$thread ) { 288 $output .= "<h3><a href='{$entry->link}'>{$entry->title} {$post_type}</a></h3>"; 289 } elseif ( $thread && !$sub ) { 290 if ( $count > 1 ) { 291 $output .= "<p>{$entry->description} <small><a href='{$entry->link}'>#</a></small></p>"; 292 } 293 } 294 } 295 $output .= "</div>"; 296 252 297 } 253 298 254 if ( $description ) {255 $description = "<h2>{$x->channel->description}</h2>";256 } else {257 $description = null;258 }259 260 $output .= "261 <div class='mom-reddit-feed'>262 {$title}{$description}263 264 ";265 foreach( $x->channel->item as $entry ){266 $post_type = null;267 if( strpos( $entry->description, 'SC_OFF' ) !== false ){268 $post_type = "<small>(self.{$channel_title})</small>";269 }270 $output .= "<h3><a href='{$entry->link}'>{$entry->title} {$post_type}</a></h3>";271 }272 $output .= "</div>";273 274 299 } 275 300 -
my-optional-modules/trunk/includes/css/myoptionalmodules10.css
r1245272 r1245503 5 5 border: none; 6 6 color: rgba(30,123,195,1); 7 display: block;7 8 8 text-decoration: none; 9 9 } … … 25 25 padding: 5% 0; 26 26 } 27 .mom-reddit-feed p { 28 clear: both; 29 display: block; 30 } 31 .mom-reddit-feed small { 32 display: inline; 33 clear: none; 34 margin: 10px; 35 } 27 36 .mom-reddit-feed h3 { 28 37 display: block; … … 122 131 } 123 132 .mom_shareLinks a{ 124 background-color: #fff; 125 color: #000; 133 border: none; 126 134 margin: 5px 5px 5px 0; 127 135 padding: 15px 25px; -
my-optional-modules/trunk/plugin.php
r1245317 r1245503 4 4 Plugin URI: 5 5 Description: Optional modules and additions for Wordpress. 6 Version: 10.1. 66 Version: 10.1.7 7 7 Author: boyevul 8 8 Author URI: -
my-optional-modules/trunk/readme.txt
r1245317 r1245503 98 98 customized to display your own title, and description should be a 1 or a 0 (to display (1) or not (0)). 99 99 100 Example: [mom_reddit sub='destinythegame' limit='5' title='You might be interested in' description='0'] 100 Designate a thread URL to pull comments for that thread. Comment output ignores title and sub attribute of shortcode. 101 102 Example: [mom_reddit sub='destinythegame' thread='' limit='5' title='You might be interested in' description='0'] 101 103 102 104 == Screenshots == … … 105 107 106 108 == Changelog == 107 = 10.1.4 / .5 / .6 = 109 110 = 10.1.7 = 108 111 * *Release Date - 14th, September, 2015* 109 112 * (added) [mom_reddit] for embedding subreddit feeds 113 * Remove background color from share links for better theme integration 110 114 111 115 = 10.1.3 =
Note: See TracChangeset
for help on using the changeset viewer.