backend file type
Showing
1 changed file
with
23 additions
and
1 deletions
| ... | @@ -202,7 +202,29 @@ function resources_fav(){ | ... | @@ -202,7 +202,29 @@ function resources_fav(){ |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | 204 | ||
| 205 | function getIsExternLink($link) { | ||
| 206 | if (strpos($link,'brokers') === -1 && strpos($link,'localhost') === -1 && strpos($link,'mailto:') === -1 && strpos($link,'tel:') === -1 && strpos($link,'#') !== 0) { | ||
| 207 | if ($link !== "/" && $link !== "#" && strpos($link,'/') !== 0) { | ||
| 208 | return true; | ||
| 209 | } | ||
| 210 | } | ||
| 211 | } | ||
| 205 | 212 | ||
| 213 | function getFileTypeClass($filename) { | ||
| 214 | |||
| 215 | if (strpos($filename,'.pdf') !== false) { | ||
| 216 | return('pdf'); | ||
| 217 | } else if (strpos($filename,'.xls') !== false) { | ||
| 218 | return('xls'); | ||
| 219 | } else if (strpos($filename,'mailto:') !== false) { | ||
| 220 | return('mailto'); | ||
| 221 | } else if (strpos($filename,'tel:') !== false) { | ||
| 222 | return('tel'); | ||
| 223 | } else if (getIsExternLink($filename)) { | ||
| 224 | return('extern'); | ||
| 225 | } | ||
| 226 | |||
| 227 | } | ||
| 206 | 228 | ||
| 207 | function resources($id, $taxes, $is_fav = false){ | 229 | function resources($id, $taxes, $is_fav = false){ |
| 208 | 230 | ||
| ... | @@ -234,7 +256,7 @@ function resources($id, $taxes, $is_fav = false){ | ... | @@ -234,7 +256,7 @@ function resources($id, $taxes, $is_fav = false){ |
| 234 | 256 | ||
| 235 | <tr class="table-like__item"> | 257 | <tr class="table-like__item"> |
| 236 | <td class="item"> | 258 | <td class="item"> |
| 237 | <a target="_blank" role="button" class="item-link" href="<?php echo wp_get_attachment_url($id); ?>"><?php echo $post->post_title; ?></a> | 259 | <a target="_blank" role="button" class="item-link <?= getFileTypeClass(wp_get_attachment_url($id)) ?>" href="<?php echo wp_get_attachment_url($id); ?>"><?php echo $post->post_title; ?></a> |
| 238 | <span class='updated-at'> | 260 | <span class='updated-at'> |
| 239 | <?php if($is_new && !empty($updated_at)) { ?> | 261 | <?php if($is_new && !empty($updated_at)) { ?> |
| 240 | <b>NEW:</b> <?= date('M d/Y', strtotime($updated_at)) ?> | 262 | <b>NEW:</b> <?= date('M d/Y', strtotime($updated_at)) ?> | ... | ... |
-
Please register or sign in to post a comment