• Resolved Peter Raschendorfer

    (@petersplugins)


    Is it safe to use WPSEO_Options::get( ‘enable_xml_sitemap’ ) in my plugin to detect if the XML sitemap feature is activated?

    Or is there any other function for plugin developers to use?

    Thanks in advance.

    Regards,
    Peter

Viewing 4 replies - 1 through 4 (of 4 total)
  • Sa?a

    (@stodorovic)

    You can use something like this, but it’s possible that Yoast will change it in the future (example it’s possible that this class could be moved to other namespace). Other way is checking existence of object $GLOBALS['wpseo_sitemaps'] (Probably easier and faster way).

    From other side, if someone deactivates Yoast SEO then it’s possible PHP fatal error. I recommend to you check existence of the method with method_exists before calling it. Something like this:

    if ( method_exists( 'WPSEO_Options', 'get' ) && WPSEO_Options::get( 'enable_xml_sitemap' ) ) {
    	/* sitemaps are enabled */
    }
    
    Thread Starter Peter Raschendorfer

    (@petersplugins)

    Many thanks for your response. I’m aware of that. That is exactly the reason for my question. I’d like to know from someone from Yoast if it is future proof to use this method or not. Therefore, I don’t mark this topic as resolved. Maybe I can get feedback from Yoast.

    Sa?a

    (@stodorovic)

    I think that checking of the object $wpseo_sitemaps (class WPSEO_Sitemaps) is easier/faster way because other plugins use method register_sitemap to add custom sitemaps (I use this method). You can look an example – here.

    If you want better answer then I think that you should post this question on github.

    Plugin Support Jerlyn

    (@jerparx)

    Closed. No further concerns.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘developer question’ is closed to new replies.