Jannick Knudsen 4 anos atrás
pai
commit
61eabca14c
2 arquivos alterados com 73 adições e 2 exclusões
  1. 50 2
      plug_shortcodes.php
  2. 23 0
      tpl_default.php

+ 50 - 2
plug_shortcodes.php

@@ -25,6 +25,7 @@ if (!class_exists("plug_shortcodes")) {
 		function r_get_dom_posts($atts, $content = null) {
 			extract(shortcode_atts(array(
 				"num" => '5',
+				"cols" => '1',
 				"cat" => '',
 				"tpl" => 'default',
 				"wrap" => 'box',
@@ -48,15 +49,24 @@ if (!class_exists("plug_shortcodes")) {
 			$myposts = get_posts('numberposts=' . $num . '&order=DESC&orderby=post_date&category=' . $catid . "&exclude=" . implode(",", $r_get_posts_excluded));
 			ob_start();
 			ob_clean();
+			$myposts_length = count($myposts);
+			$myposts_index = 0;
 			foreach ($myposts as $post):
 				$r_get_posts_excluded[] = $post->ID;
 				setup_postdata($post);
 				if (file_exists(TEMPLATEPATH . '/tpl_' . $tpl . '.php')) {
 					include TEMPLATEPATH . '/tpl_' . $tpl . '.php';
 				} else {
-					include TEMPLATEPATH . '/tpl_default.php';
+					if (file_exists(TEMPLATEPATH . '/tpl_default.php')) {
+						include TEMPLATEPATH . '/tpl_default.php';
+
+					} else {
+						include dirname(__file__) . '/tpl_default.php';
+
+					}
 
 				}
+				$myposts_index++;
 			endforeach;
 
 			if (isset($_REQUEST['debug'])) {
@@ -71,7 +81,7 @@ if (!class_exists("plug_shortcodes")) {
 
 			$ret = ob_get_contents();
 			ob_clean();
-			$ret .= '';
+			$ret = '<div class="container mx-auto flex flex-wrap-reverse ">' . $ret . '</div>';
 
 			$post = $oldpost;
 
@@ -434,7 +444,45 @@ if (!function_exists("post_images")) {
 
 				array_push($images, $image);
 			}
+
 			return $images;
 		}
 	}
+
+	function post_content_images($postid) {
+		global $wpdb;
+		if (isset($postid)) {
+			$content_post = get_post($postid);
+			$content = $content_post->post_content;
+			$content = apply_filters('the_content', $content);
+
+			preg_match_all('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
+
+			return $matches[1];
+
+		}
+	}
+}
+
+function post_images2($postid) {
+	global $wpdb;
+	if (isset($postid)) {
+		$images = array();
+		$post_image_attachments = @$wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content FROM $wpdb->posts WHERE post_parent = '$postid' AND post_type = 'attachment' AND post_mime_type LIKE '%image%' ORDER BY menu_order ASC");
+
+		foreach ($post_image_attachments as $attachment) {
+			$url = get_attachment_link($attachment->ID);
+			$id = $attachment->ID;
+			$img_title = apply_filters('the_title', $attachment->post_title);
+			$thumbnail = wp_get_attachment_image_src($attachment->ID, 'thumbnail');
+			$medium = wp_get_attachment_image_src($attachment->ID, 'medium');
+			$large = wp_get_attachment_image_src($attachment->ID, 'large');
+			$xlarge = wp_get_attachment_image_src($attachment->ID, 'xlarge');
+			$full = wp_get_attachment_image_src($attachment->ID, 'full');
+			$image = array('title' => $img_title, 'id' => $id, 'url' => $url, 'thumbnail' => $thumbnail, 'medium' => $medium, 'large' => $large, 'xlarge' => $xlarge, 'full' => $full, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content);
+
+			array_push($images, $image);
+		}
+		return $images;
+	}
 }

+ 23 - 0
tpl_default.php

@@ -0,0 +1,23 @@
+
+<?php /*$image = post_image_($post->ID,'medium'); */
+$post_images = post_images($post->ID);
+$imageurl = get_the_post_thumbnail_url($post->ID);
+?>
+
+<article  id="post-<?php the_ID();?>">
+	<div class="image">
+		<?php post_badge();?>
+			<a href="<?php the_permalink()?>" title="<?php the_title_attribute();?>"><img src="<?php echo $imageurl ? $imageurl : $post_images[0]['large'][0]; ?>" alt="<?php the_title_attribute();?>"></a>
+		<h2><a href="<?php the_permalink()?>" rel="bookmark" title="Permanent link til <?php the_title_attribute();?>"><?php the_title();?></a></h2>
+	</div>
+	<div class="content">
+		<?php echo (is_single() . "LL"); ?>
+		xxx<?php the_content();?>xxx
+
+	</div>
+
+
+</article>
+
+
+