Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/storeRss/ |
Upload File : |
<?php
namespace modules\storeRss;
class main extends \moduleMain {
use \modules\input\traits {
\modules\input\traits::__construct as __ConstructInput;
}
use \modules\output\traits {
\modules\output\traits::__construct as __ConstructOutput;
}
use \modules\config\traits {
\modules\config\traits::__construct as __ConstructConfig;
}
private $view;
public function __construct() {
parent::__construct(__DIR__);
$this->__ConstructConfig();
$this->__ConstructInput();
$this->__ConstructOutput();
}
public function Activate() {
// add <link> to html head
hook_add('html.head', [$this, '__meta'], 12);
// link to feed doc
$this->link('/feed', [$this, '__action_feed']);
}
public function __meta(&$html) {
$host = $this->hostname(TRUE);
$html .= "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Product Feed\" href=\"{$host}/feed/\" />\n";
}
protected function getCompany() {
$settings = $this->SettingGet('config.module_info', NULL);
return $settings['companyname'] ?? 'Acme Corporation';
}
public function __action_feed() {
// get all products
$content = '';
$products = hook_execute('product.list', []);
foreach($products as $item) {
$desc = str_replace('<br>', ' ', $item['sp_desc']);
$desc = strip_tags($desc);
$desc = trim(preg_replace('/\s+/', ' ', $desc));
$x = var_export($item, 1);
$availability = $item['stock'] > 0 ? 'in_stock' : 'out_of_stock';
$title = htmlspecialchars($item['sp_product']);
$desc = htmlspecialchars($desc);
$itemuri = str_replace('%2F', '/', rawurlencode($item['image']));
$content .= <<<BLOCK
<item>
<g:id>{$item['sp_sku']}</g:id>
<g:title>{$title}</g:title>
<g:description>{$desc}</g:description>
<g:link>{{LINK}}{$item['uri']}</g:link>
<g:image_link>{{LINK}}{$itemuri}</g:image_link>
<g:condition>new</g:condition>
<g:availability>$availability</g:availability>
<g:price>{$item['price']['full']} USD</g:price>
<g:shipping_weight>{$item['sp_weight']} g</g:shipping_weight>
<g:brand>{$item['brand']}</g:brand>
</item>
BLOCK;
}
/*
<g:shipping>
<g:country>US</g:country>
<g:service>Standard</g:service>
<g:price>7.99 USD</g:price>
</g:shipping>
*/
$body = <<<'BLOCK'
<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>{{COMPANY}} -- Products</title>
<link>{{LINK}}</link>
<atom:link href="{{LINK}}/feed/" rel="self" type="application/rss+xml" />
<description>Products</description>
<language>en-US</language>
<sy:updatePeriod>daily</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
{{CONTENT}}
</channel>
</rss>
BLOCK;
//header('Content-type: text/plain');
header('Content-type: application/rss+xml');
header('Content-disposition: inline; filename="rssfeed.xml"');
$body = str_replace('{{CONTENT}}', $content, $body);
$body = str_replace('{{LINK}}', $this->Hostname(TRUE), $body);
$body = str_replace('{{COMPANY}}', $this->getCompany(), $body);
die($body);
}
}