Ver Fonte

Bumped version to 0.0.62

Jannick Knudsen há 4 anos atrás
pai
commit
4559fc1b3e
5 ficheiros alterados com 121 adições e 4 exclusões
  1. 1 1
      VERSION
  2. 1 0
      VERSIONLOG
  3. 1 1
      package.json
  4. 116 0
      plug_shortcodes.php
  5. 2 2
      plugin.php

+ 1 - 1
VERSION

@@ -1 +1 @@
-v0.0.61
+v0.0.62

+ 1 - 0
VERSIONLOG

@@ -60,3 +60,4 @@ v0.0.58
 v0.0.59
 v0.0.60
 v0.0.61
+v0.0.62

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dagsplug",
-  "version": "0.0.61",
+  "version": "0.0.62",
   "description": "",
   "main": "script_backend.js",
   "scripts": {

+ 116 - 0
plug_shortcodes.php

@@ -1,4 +1,7 @@
 <?php
+if (!defined('DOM_SLUG')) {
+	define('DOM_SLUG', str_replace(".", "-", $_SERVER['HTTP_HOST']));
+}
 
 if (!class_exists("plug_shortcodes")) {
 	class plug_shortcodes {
@@ -16,7 +19,63 @@ if (!class_exists("plug_shortcodes")) {
 			add_shortcode('acc-page', array(&$this, 'getpage'));
 
 			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) {
@@ -45,6 +104,9 @@ if (!class_exists("plug_shortcodes")) {
 				setup_postdata($post);
 				if (file_exists(TEMPLATEPATH . '/tpl_' . $tpl . '.php')) {
 					include TEMPLATEPATH . '/tpl_' . $tpl . '.php';
+				} else {
+					include TEMPLATEPATH . '/tpl_default.php';
+
 				}
 			endforeach;
 
@@ -297,3 +359,57 @@ if (!class_exists("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>';
+
+					}
+
+				}
+
+			}
+
+		}
+
+	}
+}

+ 2 - 2
plugin.php

@@ -4,7 +4,7 @@ Plugin Name: dagsopt
 Plugin URI: https://git.tum.dk/tum.dk/dagsplug/
 Description: Tools
 Author: iskedk
-Version: 0.0.61
+Version: 0.0.62
 Date: 2021-01-14
 Author URI: https://iske.dk/
 Text Domain: dagsopt
@@ -17,7 +17,7 @@ function wppluginspage() {
 $wp_dagsopt = new dagsopt();
 
 class dagsopt {
-	var $version = "0.0.61";
+	var $version = "0.0.62";
 	var $publish_date = "2021-01-14";
 	var $pluginname;
 	var $plugintitle;