| @@ -1,59 +1,59 @@ | ||
| 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) | |
| 46 | + public function __construct($site, $path, $fields) | |
| 47 | 47 | { |
| 48 | - | |
| 48 | + | |
| 49 | 49 | $this->site =& $site; |
| 50 | 50 | $this->path =& $path; |
| 51 | 51 | $this->fields = $fields; |
| 52 | - | |
| 52 | + | |
| 53 | 53 | # Request server => get raw XML feed |
| 54 | 54 | $feed = wp_remote_get( "http://{$this->site}/{$this->path}" ); |
| 55 | - | |
| 55 | + | |
| 56 | 56 | # Getting XML content |
| 57 | 57 | $xmlContent = ( is_array( $feed ) && ( $feed[ 'response' ][ 'code' ] == 200 ) ) ? |
| 58 | 58 | wp_remote_retrieve_body( $feed ) : |
| 59 | 59 | '<cjterrorrequest> |
| @@ -60,9 +60,9 @@ | ||
| 60 | 60 | <channel cjt_error="true"> |
| 61 | 61 | <item> |
| 62 | 62 | <title>ERROR !!!</title> |
| 63 | 63 | <description>ERROR Fetching data from CJT Server</description> |
| 64 | - <link>https://css-javascript-toolbox.com/</link> | |
| 64 | + <link>http://css-javascript-toolbox.com/</link> | |
| 65 | 65 | </item> |
| 66 | 66 | </channel> |
| 67 | 67 | </cjterrorrequest>'; |
| 68 | 68 | # Creating feed |
| @@ -67,12 +67,12 @@ | ||
| 67 | 67 | </cjterrorrequest>'; |
| 68 | 68 | # Creating feed |
| 69 | 69 | $this->feed = new SimpleXMLElement($xmlContent); |
| 70 | 70 | } |
| 71 | - | |
| 71 | + | |
| 72 | 72 | /** |
| 73 | 73 | * put your comment there... |
| 74 | - * | |
| 74 | + * | |
| 75 | 75 | */ |
| 76 | 76 | public function getAllItems() { |
| 77 | 77 | // Initialize. |
| 78 | 78 | $items = array(); |
| @@ -87,14 +87,14 @@ | ||
| 87 | 87 | # Add to list |
| 88 | 88 | $items[] = $item; |
| 89 | 89 | } |
| 90 | 90 | # Return items. |
| 91 | - return $items; | |
| 91 | + return $items; | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * put your comment there... |
| 96 | - * | |
| 96 | + * | |
| 97 | 97 | * @param mixed $count |
| 98 | 98 | */ |
| 99 | 99 | public function getLatestItems($count) { |
| 100 | 100 | # Initialize. |
| @@ -116,22 +116,22 @@ | ||
| 116 | 116 | # Add to list |
| 117 | 117 | $items[] = $item; |
| 118 | 118 | } |
| 119 | 119 | # Return items. |
| 120 | - return $items; | |
| 120 | + return $items; | |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * put your comment there... |
| 125 | - * | |
| 125 | + * | |
| 126 | 126 | */ |
| 127 | 127 | protected function getPath() { |
| 128 | 128 | return $this->path; |
| 129 | 129 | } |
| 130 | - | |
| 130 | + | |
| 131 | 131 | /** |
| 132 | 132 | * put your comment there... |
| 133 | - * | |
| 133 | + * | |
| 134 | 134 | */ |
| 135 | 135 | public function getSite() { |
| 136 | 136 | return $this->site; |
| 137 | 137 | } |
| @@ -137,9 +137,9 @@ | ||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * put your comment there... |
| 141 | - * | |
| 141 | + * | |
| 142 | 142 | */ |
| 143 | 143 | public function isError() { |
| 144 | 144 | return !$this->feed || $this->feed->channel->attributes()->cjt_error; |
| 145 | 145 | } |