[RSS] Feed ne gre skozi validacijo
 
Balonar 16. dec 2015 08:48:49 Pridružen od:
27. jan 2008
2350 objav
2609 255 41
#1

Oj



Do včeraj je vse super delalo (RSS post iz WPja pošiljamo preko mailchimpa), danes pa mi javlja error in ni več automated pošiljanja




This feed does not validate.

line 1, column 26: XML parsing error: <unknown>:1:26: XML or text declaration not at start of entity [help]

<!-- html is corrupted --><?xml version="1.0" encoding="UTF-8"?>




v kodi pa sem nasel sledece


function today_posts_feed()
{
global $wpdb;
header('Content-type: text/xml; charset=utf-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Datum aus Vergangenheit
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\">";
echo "<channel>";
echo "<title>".get_option('rtp_channel_title')."</title>";
echo "<link>".get_option('rtp_channel_link')."</link>";
echo "<description><![CDATA[".get_option('rtp_channel_desc')."]]></description>";
echo "<language>".get_option('rtp_channel_lang')."</language>";
echo "<pubDate>".date("D, d M Y H:i:s O")."</pubDate>";
echo "<lastBuildDate>".date("D, d M Y H:i:s O")."</lastBuildDate>";

Feed Validation Service



any idea?



Hvala


všeč(0) ni všeč(0) spam(0)
 
pavarti 16. dec 2015 11:39:54 Pridružen od:
26. okt 2011
445 objav
587 92 14
#2

Na začetku XMLja imaš tole: <!-- html is corrupted -->. Izbriši pa potem poiskusi.


všeč(0) ni všeč(0) spam(0)
 
Balonar 16. dec 2015 12:36:32 Pridružen od:
27. jan 2008
2350 objav
2609 255 41
#3

nimam .. v kodi ga nikjer ni :(



tole je cel file


<?php
/*
Plugin Name: Today Posts RSS Feed
Description: Today Posts RSS Feed
Version: 1.0
Author: Kosolapov Oleg
License: GPLv2 or later
*/


function today_posts_feed()
{
global $wpdb;
header('Content-type: text/xml; charset=utf-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Datum aus Vergangenheit
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\">";
echo "<channel>";
echo "<title>".get_option('rtp_channel_title')."</title>";
echo "<link>".get_option('rtp_channel_link')."</link>";
echo "<description><![CDATA[".get_option('rtp_channel_desc')."]]></description>";
echo "<language>".get_option('rtp_channel_lang')."</language>";
echo "<pubDate>".date("D, d M Y H:i:s O")."</pubDate>";
echo "<lastBuildDate>".date("D, d M Y H:i:s O")."</lastBuildDate>";

$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'post_status' => 'publish'
);
$excludecats = get_option('rtp_exclude_cats');
$exclude_ids = explode(',', str_replace(' ', '', $excludecats));
if (count($exclude_ids) > 0)
$args['category__not_in'] = $exclude_ids;
$q = new WP_Query($args);

while ($q->have_posts())
{
$q->the_post();
global $post;

$today = strtotime(date('Y-m-d'));
$created = strtotime(date('Y-m-d', strtotime($post->post_date)));
$expire_ts = get_post_meta($post->ID, '_expiration-date', true);
if (!$expire_ts)
$expire_ts = time() + 60 * 60 * 24 * 2;
$expire = strtotime(date('Y-m-d', $expire_ts));

if ($today >= $created && $today <= $expire)
{
echo "<item>";
echo "<title><![CDATA[".$post->post_title."]]></title>";
echo "<link>".get_permalink($post->ID)."</link>";
echo "<guid>".get_permalink($post->ID)."</guid>";
$img = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
$fimg = get_attached_file(get_post_thumbnail_id($post->ID));

if ($img) {
echo "<enclosure url=\"" . $img . "\" length=\"" . filesize($fimg) . "\" type=\"" . mime_content_type($fimg) . "\" />";
echo "<media:content url=\"".$img."\" medium=\"image\" width=\"250px\" />";
}
//echo "<location><![CDATA[".get_post_meta($post->ID, "prizorisce", true)."]]></location>";
$location = get_post_meta($post->ID, "prizorisce", true);
$time = date('H:i', strtotime($post->post_date));
echo "<pubDate>".date("D, d M Y H:i:s O")."</pubDate>";
$desc = '';
if ($location)
$desc .= '<span style="font-weight: bold;">KJE:</span> '.$location.'<br>';
if ($time)
$desc .= '<span style="font-weight: bold;">KDAJ:</span> '.$time.'<br>';
$desc .= get_the_excerpt();
echo "<description><![CDATA[".$desc."]]></description>";
echo "</item>";
}
}

echo "</channel>";
echo "</rss>";
}

function rss_today_posts_admin_menu()
{
add_menu_page('Today Posts RSS', 'Today Posts RSS', 'administrator', __FILE__, 'rss_today_posts_settings_page');
add_action( 'admin_init', 'register_rss_today_posts_settings' );
}

function register_rss_today_posts_settings()
{
register_setting( 'rss-today-posts-settings-group', 'rtp_channel_title' );
register_setting( 'rss-today-posts-settings-group', 'rtp_channel_link' );
register_setting( 'rss-today-posts-settings-group', 'rtp_channel_desc' );
register_setting( 'rss-today-posts-settings-group', 'rtp_channel_lang' );
register_setting( 'rss-today-posts-settings-group', 'rtp_exclude_cats' );
}

function rss_today_posts_settings_page()
{
global $wpdb;

?>
<div class="wrap">
<h2>Today Posts RSS Feed</h2>
<form method="post" action="options.php">
<?php settings_fields( 'rss-today-posts-settings-group' ); ?>
<table class="form-table ps-form-table">
<tr valign="top">
<th scope="row">Channel Title</th>
<td valign="top"><input type="text" name="rtp_channel_title" value="<?php echo htmlspecialchars(get_option('rtp_channel_title')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Channel Link</th>
<td valign="top"><input type="text" name="rtp_channel_link" value="<?php echo htmlspecialchars(get_option('rtp_channel_link')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Channel Description</th>
<td valign="top"><textarea name="rtp_channel_desc"><?php echo htmlspecialchars(get_option('rtp_channel_desc')); ?></textarea></td>
</tr>
<tr valign="top">
<th scope="row">Channel Language</th>
<td valign="top"><input type="text" name="rtp_channel_lang" value="<?php echo htmlspecialchars(get_option('rtp_channel_lang')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Exclude Category IDs</th>
<td valign="top"><input type="text" name="rtp_exclude_cats" value="<?php echo htmlspecialchars(get_option('rtp_exclude_cats')); ?>" /></td>
</tr>
</table>

<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>

</form>

</div>
<?php
}

function add_rss_today_posts()
{
add_feed('rss_posts', 'today_posts_feed');
global $wp_rewrite;
$wp_rewrite->flush_rules(true);
}

add_action('init', 'add_rss_today_posts');
add_action('admin_menu', 'rss_today_posts_admin_menu');
register_activation_hook( __FILE__, 'rss_today_posts_scheduler_install' );

function rss_today_posts_scheduler_install()
{
update_option('rtp_channel_lang', 'en-us');
}
všeč(0) ni všeč(0) spam(0)
 
slayer 16. dec 2015 12:44:39 Pridružen od:
4. jul 2011
472 objav
295 32 11
#4

Nekaj mora biti z HTML kodo v postu. Poglej zadnje zapise.


všeč(0) ni všeč(0) spam(0)
 
Balonar 16. dec 2015 12:50:30 Pridružen od:
27. jan 2008
2350 objav
2609 255 41
#5

stvar je v tem, da se je to zgodilo iz danes na jutri .. brez kakrpnihkoli posegov .. zato pa imamo automated RSS


všeč(0) ni všeč(0) spam(0)
 
Balonar 16. dec 2015 13:42:06 Pridružen od:
27. jan 2008
2350 objav
2609 255 41
#6

Sem našel notranjega sovražnika. Dodal sem plugin WP Fastest Cache .. z izklopljenim pluginom problem izgine


všeč(0) ni všeč(0) spam(0)
 
 

🔒 Za odgovor na to temo se moraš prijaviti.

Prijavi se