예제 #1
0
파일: modules.php 프로젝트: GordonDiggs/hm3
 public function process()
 {
     if (array_key_exists('uid', $this->request->get)) {
         $wp_details = $this->user_config->get('wp_connect_details', array());
         if ($wp_details) {
             $details = wp_get_notice_detail($wp_details, $this->request->get['uid']);
             if (is_array($details) && !empty($details)) {
                 if (preg_match("/^wordpress_0_(\\d)+\$/", $this->request->get['uid'])) {
                     $parts = explode('_', $this->request->get['uid'], 3);
                     $wp_id = $parts[2];
                     $post = array('counts[' . $wp_id . ']' => 5);
                     $res = wp_fetch_content($wp_details, WPCOM_READ_URL, $post);
                     if (!is_array($res) || !array_key_exists('success', $res) || $res['success'] != 1) {
                         Hm_Msgs::add('ERRUnable to update read status of WordPress notification');
                     }
                 }
                 $this->out('wp_notice_details', $details);
             }
         }
     }
 }
예제 #2
0
function wp_get_related_posts($before_title="", $after_title="") {
	if (wp_should_exclude()) {
		return;
	}

	global $wpdb, $post;
	$wp_rp = get_option("wp_rp");

	$output = "";

	$content = wp_fetch_content();
	$related_posts = $content['posts'];
	$wp_rp_title = $content['title'];

	$wp_rp_theme = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : WP_RP_THEME_PLAIN;
	$wp_rp_theme_url = WP_RP_STATIC_BASE_URL . WP_RP_THEMES_PATH . $wp_rp_theme;

	if ($related_posts) {
		$output = wp_generate_related_posts_list_items($related_posts);
	} else {
		$wp_no_rp_text = isset($wp_rp["wp_no_rp_text"]) ? $wp_rp["wp_no_rp_text"] : "";
		if (!$wp_no_rp_text) {
			$wp_no_rp_text = $wp_rp_title;
		}
		$wp_rp_title = "";
		$output = '<li>' . $wp_no_rp_text . '</li>';
	}

	$output = '<ul class="related_post">' . $output . '</ul>';

	$wp_rp_title_tag = isset($wp_rp["wp_rp_title_tag"]) ? $wp_rp["wp_rp_title_tag"] : WP_RP_TITLE_TAG_DEFAULT;
	if ($before_title) {
		if ($wp_rp_title != '') {
			$output = $before_title.$wp_rp_title .$after_title. $output;
		}
	} else {
		if ($wp_rp_title != '') {
			$output =  '<'.$wp_rp_title_tag.'  class="related_post_title">'.$wp_rp_title .'</'.$wp_rp_title_tag.'>'. $output;
		}
	}

 	// figure out how to use wp_enqueue_style
	$wp_rp_theme_style_loader = '<script type="text/javascript">
		setTimeout(function () {
			var link = document.createElement("link");
			link.rel = "stylesheet";
			link.href= "' . $wp_rp_theme_url . '";
			link.type= "text/css";
			document.getElementsByTagName("body")[0].appendChild(link);
		}, 1);
		</script>';

	$output .= $wp_rp_theme_style_loader;

	return $output;
}