WordPress

kanał — niestandardowy kanał RSS powodujący przekroczenie limitu czasu dla witryny

  • 17 stycznia, 2023
  • 5 min read
kanał — niestandardowy kanał RSS powodujący przekroczenie limitu czasu dla witryny


Mam witrynę z wiadomościami WordPress, która wymaga wysłania niestandardowego kanału RSS do określonego dystrybutora.

Problem polega na tym, że chociaż niestandardowy kanał zastępuje oryginalny, powoduje przekroczenie limitu czasu co około dwie godziny i nie mogę ustalić, co powoduje potencjalne przeciążenie. Oto kod:

<?php
/**
 * RSS2 Feed Template for displaying RSS2 Posts feed.
 *
 * @package WordPress
 */

header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=" . get_option( "blog_charset' ), true );
$more = 1;

echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';

/**
 * Fires between the xml and rss tags in a feed.
 *
 * @since 4.0.0
 *
 * @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments',
 *                        'rdf', 'atom', and 'atom-comments'.
 */
do_action( 'rss_tag_pre', 'rss2' );
?>
<channel>
    <title><?php // wp_title_rss(); ?> Tőzsdefórum | Minden ami tőzsde</title>
    <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    <link><?php bloginfo_rss( 'url' ); ?></link>
    <description><?php bloginfo_rss( 'description' ); ?></description>
    <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
    <language><?php bloginfo_rss( 'language' ); ?></language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>

    <?php
    // do_action( 'rss2_head' );

    while ( have_posts() ) :
        the_post();
        ?>
    <item>
        <title><?php the_title_rss(); ?></title>
        <?php
        $post_id = get_the_ID();
        $kiemelt = get_field( 'kiemelt_cikk' );
        $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
        $img = get_headers($image[0], 1);
        

        if ( is_array( $kiemelt ) ) {
            if ( in_array( 'igen', $kiemelt ) ) {

                $output="<hst:titlepage>1</hst:titlepage>";
                echo $output;
            }
        }?>
        <link><?php the_permalink_rss(); ?></link>
        <?php if ( get_comments_number() || comments_open() ) : ?>
        <comments><?php comments_link_feed(); ?></comments>
        <?php endif; ?>
        <dc:creator>
            <![CDATA[<?php the_author(); ?>]]>
        </dc:creator>
        <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?>
        </pubDate>
        <?php the_category_rss( 'rss2' )?>
        <guid isPermaLink="false"><?php the_guid(); ?></guid>
        <enclosure url="<?php
            if ( has_post_thumbnail( $post->ID ) ) {
                the_post_thumbnail_url();
            }
            ?>" length="<?php 
            if ( $img ) {
            echo $img["Content-Length"];
            }?>" type="image/jpg" />

        <?php if ( get_option( 'rss_use_excerpt' ) ) : ?>
        <description>
            <![CDATA[<?php the_excerpt_rss(); ?>]]>
        </description>
        <?php else : ?>
        <description>
            <![CDATA[<?php the_excerpt_rss(); ?>]]>
        </description>
        <?php $content = get_the_content_feed( 'rss2' ); ?>
        <?php if ( strlen( $content ) > 0 ) : ?>
        <content:encoded>
            <![CDATA[<?php echo $content; ?>]]>
        </content:encoded>
        <?php else : ?>
        <content:encoded>
            <![CDATA[<?php the_excerpt_rss(); ?>]]>
        </content:encoded>
        <?php endif; ?>
        <?php endif; ?>

        <?php if ( get_comments_number() || comments_open() ) : ?>
        <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss>
        <slash:comments><?php echo get_comments_number(); ?></slash:comments>
        <?php endif; ?>

        <?php rss_enclosure(); ?>

        <?php
        /**
         * Fires at the end of each RSS2 feed item.
         *
         * @since 2.0.0
         */
        do_action( 'rss2_item' );
        ?>
    </item>
    <?php endwhile; ?>
</channel>

Jedyny błąd, jaki udało mi się znaleźć w dzienniku, jest następujący:

[17-Jan-2023 11:43:03 UTC] PHP Warning:  get_headers( Failed to open stream: operation failed in /home/tozsdefo/public_html/wp-content/themes/tozsdeforum-theme/feed-rss2.php on line 49
[17-Jan-2023 11:43:03 UTC] PHP Warning:  Trying to access array offset on value of type bool in /home/tozsdefo/public_html/wp-content/themes/tozsdeforum-theme/feed-rss2.php on line 71
[17-Jan-2023 11:43:05 UTC] PHP Warning:  get_headers(): SSL: Handshake timed out in /home/tozsdefo/public_html/wp-content/themes/tozsdeforum-theme/feed-rss2.php on line 51
[17-Jan-2023 11:43:05 UTC] PHP Warning:  get_headers(): Failed to enable crypto in /home/tozsdefo/public_html/wp-content/themes/tozsdeforum-theme/feed-rss2.php on line 51
[17-Jan-2023 11:43:05 UTC] PHP Warning:  get_headers( Failed to open stream: operation failed in /home/tozsdefo/public_html/wp-content/themes/tozsdeforum-theme/feed-rss2.php on line 51
[17-Jan-2023 11:43:38 UTC] PHP Warning:  get_headers( Failed to open stream: Connection timed out in /home/tozsdefo/public_html/wp-content/themes/tozsdeforum-theme/feed-rss2.php on line 51

Usunąłem domenę witryny z dziennika błędów (website.hu) Jakieś sugestie, co może być przyczyną przeciążenia?

Warto przeczytać!  5 najlepszych wtyczek do katalogu biznesowego WordPress na rok 2024 (bezpłatne i płatne)


Źródło