|
@@ -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;
|
|
|
+ }
|
|
|
}
|