|
@@ -1,4 +1,7 @@
|
|
<?php
|
|
<?php
|
|
|
|
+if (!defined('DOM_SLUG')) {
|
|
|
|
+ define('DOM_SLUG', str_replace(".", "-", $_SERVER['HTTP_HOST']));
|
|
|
|
+}
|
|
|
|
|
|
if (!class_exists("plug_shortcodes")) {
|
|
if (!class_exists("plug_shortcodes")) {
|
|
class plug_shortcodes {
|
|
class plug_shortcodes {
|
|
@@ -16,7 +19,63 @@ if (!class_exists("plug_shortcodes")) {
|
|
add_shortcode('acc-page', array(&$this, 'getpage'));
|
|
add_shortcode('acc-page', array(&$this, 'getpage'));
|
|
|
|
|
|
add_shortcode('posts', array(&$this, 'r_get_posts'));
|
|
add_shortcode('posts', array(&$this, 'r_get_posts'));
|
|
|
|
+ add_shortcode('domposts', array(&$this, 'r_get_dom_posts'));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ function r_get_dom_posts($atts, $content = null) {
|
|
|
|
+ extract(shortcode_atts(array(
|
|
|
|
+ "num" => '5',
|
|
|
|
+ "cat" => '',
|
|
|
|
+ "tpl" => 'default',
|
|
|
|
+ "wrap" => 'box',
|
|
|
|
+ ), $atts));
|
|
|
|
+ global $post, $r_get_posts_excluded, $r_get_posts_cat_collect;
|
|
|
|
+ $oldpost = $post;
|
|
|
|
+ if (defined("DOM_SLUG")) {
|
|
|
|
+ $caten = get_category_by_slug(DOM_SLUG);
|
|
|
|
+ } else {
|
|
|
|
+ $caten = get_category_by_slug($cat);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ $ret = '';
|
|
|
|
+ if ($caten) {
|
|
|
|
+ $catid = $caten->cat_ID;
|
|
|
|
+ } else {
|
|
|
|
+ $catid = 3;
|
|
|
|
+ }
|
|
|
|
+ $r_get_posts_cat_collect[] = $catid;
|
|
|
|
+
|
|
|
|
+ $myposts = get_posts('numberposts=' . $num . '&order=DESC&orderby=post_date&category=' . $catid . "&exclude=" . implode(",", $r_get_posts_excluded));
|
|
|
|
+ ob_start();
|
|
|
|
+ ob_clean();
|
|
|
|
+ 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';
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ endforeach;
|
|
|
|
+
|
|
|
|
+ if (isset($_REQUEST['debug'])) {
|
|
|
|
+ echo ("atts:" . print_r($atts, true) . "\n");
|
|
|
|
+ echo ("CAT:" . $cat . "\n");
|
|
|
|
+ echo ("caten:" . print_r($caten, true) . "\n");
|
|
|
|
+ echo ("posts:" . print_r($myposts, true) . "\n");
|
|
|
|
+ echo ("r_get_posts_cat_collect:" . print_r($r_get_posts_cat_collect, true) . "\n");
|
|
|
|
+ echo ("r_get_posts_excluded:" . print_r($r_get_posts_excluded, true) . "\n");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ret = ob_get_contents();
|
|
|
|
+ ob_clean();
|
|
|
|
+ $ret .= '';
|
|
|
|
+
|
|
|
|
+ $post = $oldpost;
|
|
|
|
|
|
|
|
+ return $ret;
|
|
}
|
|
}
|
|
|
|
|
|
function r_get_posts($atts, $content = null) {
|
|
function r_get_posts($atts, $content = null) {
|
|
@@ -45,6 +104,9 @@ if (!class_exists("plug_shortcodes")) {
|
|
setup_postdata($post);
|
|
setup_postdata($post);
|
|
if (file_exists(TEMPLATEPATH . '/tpl_' . $tpl . '.php')) {
|
|
if (file_exists(TEMPLATEPATH . '/tpl_' . $tpl . '.php')) {
|
|
include TEMPLATEPATH . '/tpl_' . $tpl . '.php';
|
|
include TEMPLATEPATH . '/tpl_' . $tpl . '.php';
|
|
|
|
+ } else {
|
|
|
|
+ include TEMPLATEPATH . '/tpl_default.php';
|
|
|
|
+
|
|
}
|
|
}
|
|
endforeach;
|
|
endforeach;
|
|
|
|
|
|
@@ -297,3 +359,57 @@ if (!class_exists("plug_shortcodes")) {
|
|
$this->dagsopt['plug_shortcodes'] = $plug_shortcodes;
|
|
$this->dagsopt['plug_shortcodes'] = $plug_shortcodes;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+if (!function_exists("post_image_")) {
|
|
|
|
+ function post_image_($postid, $format = "thumbnail") {
|
|
|
|
+ global $wpdb;
|
|
|
|
+ $image = array();
|
|
|
|
+ if (isset($postid)) {
|
|
|
|
+ $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 ID ASC LIMIT 1");
|
|
|
|
+ foreach ($post_image_attachments as $attachment) {
|
|
|
|
+ $url = get_attachment_link($attachment->ID);
|
|
|
|
+ $id = $attachment->ID;
|
|
|
|
+ $img_title = apply_filters('the_title', $attachment->post_title);
|
|
|
|
+ $srcc = wp_get_attachment_image_src($attachment->ID, $format);
|
|
|
|
+ if (defined("WP_SITEURL_SEC")) {
|
|
|
|
+ $srcc[0] = str_replace(WP_SITEURL_SEC, WP_SITEURL_CDN, $srcc[0]);
|
|
|
|
+ }
|
|
|
|
+ $image = array('title' => $img_title, 'id' => $id, 'url' => $url, 'src' => $srcc, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $image;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+if (!function_exists("post_badge")) {
|
|
|
|
+
|
|
|
|
+ function post_badge() {
|
|
|
|
+ echo '<div class="badge_buy"></div>';
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (is_restricted()) {
|
|
|
|
+ echo '<div class="badge_buy"><a href="/abonnement/">Køb abonnement</a></div>';
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ if (in_category('492') && !(in_category('9') || in_category(125))) {
|
|
|
|
+ echo '<div class="badge_member"><a href="/wp-admin" style="float: left; margin-left: -100px; background-color: #777777;">Perspektiv</a></div>';
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ if (in_category('9') || in_category(125)) {
|
|
|
|
+ if (in_category('492')) {
|
|
|
|
+ echo '<div class="badge_member"><a href="/wp-admin" style="float: left; margin-left: -100px; background-color: #777777;">Perspektiv</a> <a href="/wp-admin">Kun for abonnenter</a></div>';
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ echo '<div class="badge_member"><a href="/wp-admin">Kun for abonnenter</a></div>';
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|