PluginProbe
FeedWordPress / 2020.0118
FeedWordPress v2020.0118
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / template-functions.php

template-functions.php in FeedWordPress 2020.0118, at template-functions.php

157 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 ################################################################################
3 ## TEMPLATE API: functions to make your templates syndication-aware ############
4 ################################################################################
5
6 /**
7 * is_syndicated: Tests whether the current post in a Loop context, or a post
8 * given by ID number, was syndicated by FeedWordPress. Useful for templates
9 * to determine whether or not to retrieve syndication-related meta-data in
10 * displaying a post.
11 *
12 * @param int $id The post to check for syndicated status. Defaults to the current post in a Loop context.
13 * @return bool TRUE if the post's meta-data indicates it was syndicated; FALSE otherwise
14 */
15 function is_syndicated ($id = NULL) {
16 $p = new FeedWordPressLocalPost($id);
17 return $p->is_syndicated();
18 } /* function is_syndicated() */
19
20 function feedwordpress_display_url ($url, $before = 60, $after = 0) {
21 $bits = parse_url($url);
22
23 // Strip out crufty subdomains
24 if (isset($bits['host'])) :
25 $bits['host'] = preg_replace('/^www[0-9]*\./i', '', $bits['host']);
26 endif;
27
28 // Reassemble bit-by-bit with minimum of crufty elements
29 $url = (isset($bits['user'])?$bits['user'].'@':'')
30 .(isset($bits['host'])?$bits['host']:'')
31 .(isset($bits['path'])?$bits['path']:'')
32 .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
33 .(isset($bits['query'])?'?'.$bits['query']:'');
34
35 if (strlen($url) > ($before+$after)) :
36 $url = substr($url, 0, $before).'.'.substr($url, 0 - $after, $after);
37 endif;
38
39 return $url;
40 } /* feedwordpress_display_url () */
41
42 function get_syndication_source_property ($original, $id, $local, $remote = NULL) {
43 $p = new FeedWordPressLocalPost($id);
44 return $p->meta($local, array("unproxy" => $original, "unproxied setting" => $remote));
45 } /* function get_syndication_source_property () */
46
47 function get_syndication_source_link ($original = NULL, $id = NULL) {
48 $p = new FeedWordPressLocalPost($id);
49 return $p->syndication_source_link($original);
50 } /* function get_syndication_source_link() */
51
52 function the_syndication_source_link ($original = NULL, $id = NULL) {
53 echo get_syndication_source_link($original, $id);
54 } /* function the_syndication_source_link() */
55
56 function get_syndication_source ($original = NULL, $id = NULL) {
57 $p = new FeedWordPressLocalPost($id);
58 return $p->syndication_source($original);
59 } /* function get_syndication_source() */
60
61 function the_syndication_source ($original = NULL, $id = NULL) {
62 echo get_syndication_source($original, $id);
63 } /* function the_syndication_source () */
64
65 function get_syndication_feed ($original = NULL, $id = NULL) {
66 $p = new FeedWordPressLocalPost($id);
67 return $p->syndication_feed($original);
68 } /* function get_syndication_feed() */
69
70 function the_syndication_feed ($original = NULL, $id = NULL) {
71 echo get_syndication_feed($original, $id);
72 } /* function the_syndication_feed() */
73
74 function get_syndication_feed_guid ($original = NULL, $id = NULL) {
75 $p = new FeedWordPressLocalPost($id);
76 return $p->syndication_feed_guid($original);
77 } /* function get_syndication_feed_guid () */
78
79 function the_syndication_feed_guid ($original = NULL, $id = NULL) {
80 echo get_syndication_feed_guid($original, $id);
81 } /* function the_syndication_feed_guid () */
82
83 function get_syndication_feed_id ($id = NULL) {
84 $p = new FeedWordPressLocalPost($id);
85 return $p->feed_id();
86 } /* function get_syndication_feed_id () */
87
88 function the_syndication_feed_id ($id = NULL) {
89 echo get_syndication_feed_id($id);
90 } /* function the_syndication_feed_id () */
91
92 function get_syndication_feed_object ($id = NULL) {
93 $p = new FeedWordPressLocalPost($id);
94 return $p->feed();
95 } /* function get_syndication_feed_object() */
96
97 function get_feed_meta ($key, $id = NULL) {
98 $ret = NULL;
99
100 $link = get_syndication_feed_object($id);
101 if (is_object($link) and isset($link->settings[$key])) :
102 $ret = $link->settings[$key];
103 endif;
104 return $ret;
105 } /* function get_feed_meta() */
106
107 function get_syndication_permalink ($id = NULL) {
108 $p = new FeedWordPressLocalPost($id);
109 return $p->syndication_permalink();
110 } /* function get_syndication_permalink () */
111
112 function the_syndication_permalink ($id = NULL) {
113 echo get_syndication_permalink($id);
114 } /* function the_syndication_permalink () */
115
116 /**
117 * get_local_permalink: returns a string containing the internal permalink
118 * for a post (whether syndicated or not) on your local WordPress installation.
119 * This may be useful if you want permalinks to point to the original source of
120 * an article for most purposes, but want to retrieve a URL for the local
121 * representation of the post for one or two limited purposes (for example,
122 * linking to a comments page on your local aggregator site).
123 *
124 * @param $id The numerical ID of the post to get the permalink for. If empty,
125 * defaults to the current post in a Loop context.
126 * @return string The URL of the local permalink for this post.
127 *
128 * @uses get_permalink()
129 * @global $feedwordpress_the_original_permalink
130 *
131 * @since 2010.0217
132 */
133 function get_local_permalink ($id = NULL) {
134 global $feedwordpress_the_original_permalink;
135
136 // get permalink, and thus activate filter and force global to be filled
137 // with original URL.
138 $url = get_permalink($id);
139 return $feedwordpress_the_original_permalink;
140 } /* get_local_permalink() */
141
142 /**
143 * the_original_permalink: displays the contents of get_original_permalink()
144 *
145 * @param $id The numerical ID of the post to get the permalink for. If empty,
146 * defaults to the current post in a Loop context.
147 *
148 * @uses get_local_permalinks()
149 * @uses apply_filters
150 *
151 * @since 2010.0217
152 */
153 function the_local_permalink ($id = NULL) {
154 print apply_filters('the_permalink', get_local_permalink($id));
155 } /* function the_local_permalink() */
156
157