• Hi

    I went through the Functions Reference document on your website and couldn’t find if there is any function that checks if Polylang is active before using the functions so I made this function myself:

    function is_polylang_active() {
      return function_exists('pll_the_languages');
    }

    I’m then using it like

    if (is_polylang_active()) { .... }

    Is that ok?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can use is_plugin_active( ‘polylang/polylang.php’ ) But the author recommends checking if function exists before using it, example

    if ( function_exists( 'pll_count_posts' ) ) { }

    That would be more proper then checking if plugin active every single time.

    Thread Starter ashkanahmadi

    (@ashkanahmadi)

    Hi Luke.

    Perfect thank you so much. In this case, then I would wrap everything that is PolyLang-dependant in that if statement before ? For example:

    if ( function_exists( 'pll_the_languages' ) ) {
       $all_languages = pll_the_languages(
          array( 
             'raw' => 1
          )
       );
    }

    welcome, correct!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Does PolyLang have a built-in function that checks if PolyLang is active?’ is closed to new replies.