Changeset 1264295
- Timestamp:
- 10/12/2015 05:43:58 PM (10 years ago)
- Location:
- my-optional-modules/trunk
- Files:
-
- 4 edited
-
class.mom-reddit.php (modified) (14 diffs)
-
includes/css/css.css (modified) (2 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
my-optional-modules/trunk/class.mom-reddit.php
r1263789 r1264295 3 3 * CLASS mom-reddit() 4 4 * 5 * File last update: 11.1. 25 * File last update: 11.1.3 6 6 * 7 7 * Embed a subreddit into WordPress … … 50 50 shortcode_atts ( 51 51 array ( 52 'sub' => '' , 53 'search' => '' , 54 'sort' => 'relevance' , 55 'thread' => '' , 56 'sticky' => 1 , 57 'score' => 0 , 58 'thumbs' => 1 , 59 'nsfw' => 1 , 60 'type' => 'all' , 61 'amount' => '25' , 62 'header' => 1 , 63 'credit' => 1 , 64 'from' => 'all' , 52 'sub' => '' , 53 'search' => '' , 54 'sort' => 'relevance' , 55 'thread' => '' , 56 'sticky' => 1 , 57 'score' => 0 , 58 'thumbs' => 1 , 59 'thumbs_l' => 1 , 60 'nsfw' => 1 , 61 'type' => 'all' , 62 'amount' => '25' , 63 'header' => 1 , 64 'header_t' => '' , 65 'credit' => 1 , 66 'from' => 'all' , 67 'site' => 1 , 68 'meta' => 1 , 69 'grid' => 0 , 65 70 ), 66 71 $atts … … 68 73 ); 69 74 70 $count = 0; 71 $sub = strtolower ( sanitize_text_field ( $sub ) ); 72 $search = sanitize_text_field ( $search ); 73 $relevance = strtolower ( sanitize_text_field ( $sort ) ); 74 $type = strtolower ( sanitize_text_field ( $type ) ); 75 $from = strtolower ( $from ); 76 $sticky = intval ( $sticky ); 77 $score = intval ( $score ); 78 $thumbs = intval ( $thumbs ); 79 $nsfw = intval ( $nsfw ); 80 $header = intval ( $header ); 81 $credit = intval ( $credit ); 82 75 $count = 0; 76 $sub = strtolower ( sanitize_text_field ( $sub ) ); 77 $search = sanitize_text_field ( $search ); 78 $relevance = strtolower ( sanitize_text_field ( $sort ) ); 79 $type = strtolower ( sanitize_text_field ( $type ) ); 80 $from = strtolower ( $from ); 81 $sticky = intval ( $sticky ); 82 if ( '-1' != $score ): 83 $score = intval ( $score ); 84 endif; 85 $thumbs = intval ( $thumbs ); 86 $thumbs_l = intval ( $thumbs_l ); 87 $nsfw = intval ( $nsfw ); 88 $header = intval ( $header ); 89 $header_t = sanitize_text_field ( $header_t ); 90 $credit = intval ( $credit ); 91 $site = intval ( $site ); 92 $meta = intval ( $meta ); 83 93 $output_open = null; 84 94 $post = null; … … 86 96 $header_output = null; 87 97 $credit_output = null; 98 $grid_active = null; 99 $thumb_class = ' class="thumb"'; 100 $grid = intval ( $grid ); 101 if ( $grid ): 102 $grid_active = 'id="myoptionalmodules-grid-active"'; 103 $thumb_class = null; 104 endif; 88 105 89 106 if ( $sub ): … … 99 116 100 117 if ( $header ): 101 $header_output = "<span class='title-bar'><a href='//reddit.com/r/{$sub}'>r/{$sub}</a></span>"; 118 if ( $header_t ): 119 $header_output = "<span class='title-bar'>{$header_t}</span>"; 120 else: 121 $header_output = "<span class='title-bar'><a href='//reddit.com/r/{$sub}'>r/{$sub}</a></span>"; 122 endif; 102 123 endif; 103 124 … … 112 133 <div class='myoptionalmodules-subreddit'> 113 134 {$header_output} 114 <div class='inner' >{$credit_output}";135 <div class='inner'{$grid_active}>{$credit_output}"; 115 136 foreach ( $sub_data as $value ): 116 137 ++$count; 138 $link_to = null; 139 $date = null; 117 140 $domain = null; 118 141 $title = null; 119 142 $url = null; 143 $url_raw = null; 120 144 $permalink = null; 121 145 $author = null; … … 127 151 $points = null; 128 152 $is_nsfw = null; 153 $raw_score = null; 129 154 $over18 = false; 130 155 $div = 'nonstickied'; … … 138 163 $stickied = '<i class="fa fa-sticky-note"> sticky</i>'; 139 164 endif; 140 if ( $value->data->domain ):165 if ( $value->data->domain && $site ): 141 166 $domain_raw = sanitize_text_field ( $value->data->domain ); 142 167 $domain = sanitize_text_field ( $value->data->domain ); … … 147 172 endif; 148 173 if ( $value->data->url ): 149 $url = esc_url ( $value->data->url ); 150 $url = "<a href='{$url}'>{$title}</a>"; 174 $url_raw = esc_url ( $value->data->url ); 175 $url = esc_url ( $value->data->url ); 176 $url = "<a href='{$url}'>{$title}</a>"; 151 177 endif; 152 178 if ( $value->data->gilded ): … … 162 188 $comments = "<a href='{$permalink}'><em>no comments</em></a>"; 163 189 endif; 164 if ( $value->data->score ): 165 $raw_score = intval ( $value->data->score ); 166 $points = intval ( $value->data->score ); 167 $points = "<span class='listing-score'>{$points}</span>"; 168 else: 169 $points = '<span class="listing-score">0</span>'; 190 if ( '-1' == $score ): 191 $points = null; 192 else: 193 if ( $value->data->score ): 194 $raw_score = intval ( $value->data->score ); 195 $points = intval ( $value->data->score ); 196 $points = "<span class='listing-score'>{$points}</span>"; 197 else: 198 $points = '<span class="listing-score">0</span>'; 199 endif; 170 200 endif; 171 201 if ( $value->data->author ): … … 173 203 $author = " by <a href='//reddit.com/user/{$author}'>{$author}</a>"; 174 204 endif; 175 if ( $value->data->created_utc ):205 if ( $value->data->created_utc && $meta ): 176 206 $date = $value->data->created_utc; 177 207 $date_readable = date( 'Y-m-d H:i:s' , $date ); … … 179 209 $date = "submitted {$author} {$date} ago"; 180 210 endif; 181 if ( $value->data->thumbnail && false == $is_self ): 182 183 if ( true == $value->data->over_18 ): 184 $thumb = null; 185 $is_nsfw = '<span class="nsfw">nsfw</span>'; 211 if ( $value->data->thumbnail ): 212 if ( 'self' == $value->data->thumbnail ): 213 $thumb = null; 186 214 else: 187 if ( !strpos ( strtolower ( $value->data->title ) , 'spoiler' ) ): 188 $padding = 'image'; 189 $thumb = esc_url ( $value->data->thumbnail ); 190 $thumb = "<img src='{$thumb}' class='thumb' />"; 215 if ( 'default' == $value->data->thumbnail ): 216 $thumb = null; 191 217 else: 192 $thumb = null; 218 if ( !strpos ( strtolower ( $value->data->title ) , 'spoiler' ) ): 219 $padding = 'image'; 220 $thumb = esc_url ( $value->data->thumbnail ); 221 if ( !$thumbs_l ): 222 $link_to = $url_raw; 223 else: 224 $link_to = $permalink; 225 endif; 226 if ( $url_raw ): 227 $thumb = "<a href='{$link_to}'><img src='{$thumb}'{$thumb_class}/></a>"; 228 else: 229 $thumb = "<a href='{$link_to}'><img src='{$thumb}'{$thumb_class}/></a>"; 230 endif; 231 else: 232 $thumb = null; 233 endif; 193 234 endif; 194 235 endif; 195 196 236 else: 197 237 $thumb = null; … … 203 243 endif; 204 244 205 if ( $score >= $raw_score ):245 if ( $score >= $raw_score && $score >= 0 ): 206 246 $post .= ''; 207 247 elseif ( !$sticky && 'stickied' == $div ): … … 214 254 $post .= ''; 215 255 else: 216 $post .= " 217 <div class='reddit-item-listing {$div} {$padding}'> 218 {$points}{$stickied} 219 {$thumb} 220 <span class='listing-title'> 221 {$url} {$domain} 222 </span> 223 <span class='listing-date'> 224 {$date} 225 </span> 226 <span class='listing-information'> 227 {$is_nsfw} {$comments} 228 </span> 229 </div> 230 "; 256 if ( $grid ): 257 $post .= "{$thumb}"; 258 else: 259 $post .= " 260 <div class='reddit-item-listing {$div} {$padding}'> 261 {$points}{$stickied} 262 {$thumb} 263 <span class='listing-title'> 264 {$url} {$domain} 265 </span> 266 <span class='listing-date'> 267 {$date} 268 </span> 269 <span class='listing-information'> 270 {$is_nsfw} {$comments} 271 </span> 272 </div> 273 "; 274 endif; 231 275 endif; 232 276 -
my-optional-modules/trunk/includes/css/css.css
r1263789 r1264295 9 9 position: relative; 10 10 } 11 /** 12 * Seamless Responsive Photo Grid | CSS-Tricks 13 * //css-tricks.com/seamless-responsive-photo-grid/ 14 */ 15 #myoptionalmodules-grid-active { 16 /* Prevent vertical gaps */ 17 line-height: 0; 18 -webkit-column-count: 5; 19 -webkit-column-gap: 0px; 20 -moz-column-count: 5; 21 -moz-column-gap: 0px; 22 column-count: 5; 23 column-gap: 0px; 24 } 25 #myoptionalmodules-grid-active img { 26 /* Just in case there are inline attributes */ 27 height: auto !important; 28 padding: 5px; 29 width: 100% !important; 30 } 31 #myoptionalmodules-grid-active img:hover { 32 opacity: .6; 33 } 11 34 .myoptionalmodules-subreddit a { 12 border: none; 35 border-color: rgba(0,0,0,.1); 36 border-style: solid; 37 border-width: 0 0 1px 0; 13 38 box-shadow: none; 39 padding: 0 0 3px 0; 14 40 text-decoration: none; 15 41 } … … 832 858 } 833 859 860 @media (max-width: 1200px) { 861 #myoptionalmodules-grid-active { 862 -moz-column-count: 4; 863 -webkit-column-count: 4; 864 column-count: 4; 865 } 866 } 867 @media (max-width: 1000px) { 868 #myoptionalmodules-grid-active { 869 -moz-column-count: 3; 870 -webkit-column-count: 3; 871 column-count: 3; 872 } 873 } 874 @media (max-width: 800px) { 875 #myoptionalmodules-grid-active { 876 -moz-column-count: 2; 877 -webkit-column-count: 2; 878 column-count: 2; 879 } 880 } 881 @media (max-width: 400px) { 882 #myoptionalmodules-grid-active { 883 -moz-column-count: 1; 884 -webkit-column-count: 1; 885 column-count: 1; 886 } 887 } 888 834 889 @media screen and (max-width: 31.250em ) { 835 890 .mom_cat-container { -
my-optional-modules/trunk/plugin.php
r1263789 r1264295 3 3 Plugin Name: My Optional Modules 4 4 Description: Optional modules and additions for Wordpress. 5 Version: 11.1. 25 Version: 11.1.3 6 6 Author: boyevul 7 7 */ -
my-optional-modules/trunk/readme.txt
r1263789 r1264295 4 4 Requires at least: 4.1 5 5 Tested up to: 4.3.2 6 Stable tag: 11.1. 26 Stable tag: 11.1.3 7 7 8 8 An assortment of functions to enhance WordPress. … … 122 122 1. `sort` :: combine with `search` to sort results :: top,relevance,new,comments,relevance2 :: default: relevance 123 123 1. `sticky` :: include sticky posts :: 1(yes) 0(no) :: default: 1 124 1. `score` :: exclude posts below a certain score :: default: 1 124 1. `score` :: exclude posts below a certain score :: -1 to disable, 0+ for point-based exclusions :: default: 1 125 1. `thumbs` :: whether to display thumbnails or not :: 1(on) 0(off) :: default: 1 126 1. `thumbs_l` :: whether to link to reddit thread or URL :: 1(reddit) 0(URL) :: default: 1 125 127 1. `nsfw` :: show posts that are marked as NSFW :: 1(yes) 0(no) :: default: 1 126 128 1. `type` :: which type of posts to show :: all, self, or links :: default: all 127 129 1. `amount` :: how many results to return :: default: 25 128 130 1. `header` :: display link back to sub on reddit :: 1(yes) 0(no) :: default: 1 131 1. `header_t` :: instead of link back, display this text in header instead :: default: none 129 132 1. `credit` :: display powered by text :: 1(yes) 0(no) :: default: 1 130 133 1. `from` :: determine when to draw posts from :: hour,day,week,month,year,all :: default: all 131 132 `sub` examples: sub, sub/new, sub/rising, sub/controversial, sub/top. 133 134 Example: [mom_reddit sub='all' search='' sort='relevance' sticky=1 score=0 nsfw=1 type=all amount=25 header=1 credit=1 from='all'] 134 1. `site` :: display domain information next to title :: 1(on) 0(off) :: default: 1 135 1. `meta` :: display author and submission date information :: 1(on) 0(off) :: default: 1 136 1. `grid` :: returns a grid of images (and only images) :: 1(on) 0(off) :: default: 0 137 138 sub examples: sub, sub/new, sub/rising, sub/controversial, sub/top. 139 140 Example: [mom_reddit sub='all' search='' sort='relevance' sticky=1 score=0 nsfw=1 type=all amount=25 header=1 credit=1 from='all' site=1 meta=1] 135 141 136 142 == Screenshots == … … 139 145 140 146 == Changelog == 147 = 11.1.3 = 148 * *Release Date - 12th, October, 2015* 149 * [mom_reddit] additional parameters (including a grid mode) 150 141 151 = 11.1 / 11.1.1 / 11.1.2 = 142 152 * *Release Date - 11th, October, 2015*
Note: See TracChangeset
for help on using the changeset viewer.