PluginProbe
CSS & JavaScript Toolbox / 8.0
CSS & JavaScript Toolbox v8.0
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | framework/wordpress/feed.php +29 -32 12.08.0 View file →
@@ -1,68 +1,65 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 /**
7 -*
7 +*
8 8 */
9 9 class CJT_Framework_Wordpress_Feed {
10 -
10 +
11 11 /**
12 12 * put your comment there...
13 - *
13 + *
14 14 * @var mixed
15 15 */
16 16 protected $feed;
17 -
17 +
18 18 /**
19 19 * put your comment there...
20 - *
20 + *
21 21 * @var mixed
22 22 */
23 23 protected $fields;
24 -
24 +
25 25 /**
26 26 * put your comment there...
27 - *
27 + *
28 28 * @var mixed
29 29 */
30 30 protected $path;
31 -
31 +
32 32 /**
33 33 * put your comment there...
34 - *
34 + *
35 35 * @var mixed
36 36 */
37 37 protected $site;
38 -
38 +
39 39 /**
40 40 * put your comment there...
41 - *
41 + *
42 42 * @param mixed $site
43 43 * @param mixed $path
44 44 * @return CJT_Framework_Wordpress_Feed
45 45 */
46 - public function __construct($site, $path, $fields)
47 - {
48 -
46 + public function __construct($site, $path, $fields) {
47 + # Initialize.
49 48 $this->site =& $site;
50 49 $this->path =& $path;
51 50 $this->fields = $fields;
52 -
53 51 # Request server => get raw XML feed
54 - $feed = wp_remote_get( "http://{$this->site}/{$this->path}" );
55 -
52 + $feed = wp_remote_get("http://{$this->site}/{$this->path}");
56 53 # Getting XML content
57 - $xmlContent = ( is_array( $feed ) && ( $feed[ 'response' ][ 'code' ] == 200 ) ) ?
58 - wp_remote_retrieve_body( $feed ) :
54 + $xmlContent = ((gettype($feed) !== 'WP_Error') && ($feed['response']['code'] == 200)) ?
55 + wp_remote_retrieve_body($feed) :
59 56 '<cjterrorrequest>
60 57 <channel cjt_error="true">
61 58 <item>
62 - <title>ERROR !!!</title>
63 - <description>ERROR Fetching data from CJT Server</description>
64 - <link>https://css-javascript-toolbox.com/</link>
59 + <title>ERROR</title>
60 + <description>ERROR</description>
61 + <link>http://css-javascript-toolbox.com/</link>
65 62 </item>
66 63 </channel>
67 64 </cjterrorrequest>';
68 65 # Creating feed
@@ -67,12 +64,12 @@
67 64 </cjterrorrequest>';
68 65 # Creating feed
69 66 $this->feed = new SimpleXMLElement($xmlContent);
70 67 }
71 -
68 +
72 69 /**
73 70 * put your comment there...
74 - *
71 + *
75 72 */
76 73 public function getAllItems() {
77 74 // Initialize.
78 75 $items = array();
@@ -87,14 +84,14 @@
87 84 # Add to list
88 85 $items[] = $item;
89 86 }
90 87 # Return items.
91 - return $items;
88 + return $items;
92 89 }
93 90
94 91 /**
95 92 * put your comment there...
96 - *
93 + *
97 94 * @param mixed $count
98 95 */
99 96 public function getLatestItems($count) {
100 97 # Initialize.
@@ -116,22 +113,22 @@
116 113 # Add to list
117 114 $items[] = $item;
118 115 }
119 116 # Return items.
120 - return $items;
117 + return $items;
121 118 }
122 119
123 120 /**
124 121 * put your comment there...
125 - *
122 + *
126 123 */
127 124 protected function getPath() {
128 125 return $this->path;
129 126 }
130 -
127 +
131 128 /**
132 129 * put your comment there...
133 - *
130 + *
134 131 */
135 132 public function getSite() {
136 133 return $this->site;
137 134 }
@@ -137,9 +134,9 @@
137 134 }
138 135
139 136 /**
140 137 * put your comment there...
141 - *
138 + *
142 139 */
143 140 public function isError() {
144 141 return !$this->feed || $this->feed->channel->attributes()->cjt_error;
145 142 }