post_type ) && ( $post->post_type === 'wplng_translation' || $post->post_type === 'wplng_slug' ) ) { return true; } return false; } /** * Customize the admin footer text displayed on wpLingua option pages. * * @param string $text The default footer text. * @return string The customized footer text for wpLingua pages. */ function wplng_admin_footer_text( $text ) { if ( wplng_is_wplingua_admin_page() ) { $text = ' '; if ( empty( wplng_get_api_data() ) ) { $text .= esc_html__( 'Thank you for choosing wpLingua!', 'wplingua' ); } else { $text .= sprintf( esc_html__( 'If you like wpLingua please leave us a %1$s rating. A huge thanks!', 'wplingua' ), '★★★★★' ); } } return $text; } /** * Set custom update_footer text on wpLingua options pages * * @param string $text The default footer text to be modified. * @return string The customized footer text for wpLingua pages. */ function wplng_update_footer( $text ) { if ( wplng_is_wplingua_admin_page() ) { $text = ''; $text .= 'wplingua.com'; $text .= ' | '; $text .= ''; $text .= 'GitHub'; $text .= ' | '; $text .= esc_html__( 'Version', 'wplingua' ); $text .= ' ' . esc_html( WPLNG_PLUGIN_VERSION ); } return $text; } /** * Add 'Settings' link on wpLingua in the plugin list * * @param array $settings * @return array */ function wplng_settings_link( $settings ) { $url = add_query_arg( 'page', 'wplingua-settings', get_admin_url() . 'admin.php' ); $link = ''; $link .= esc_html__( 'Settings', 'wplingua' ); $link .= ''; $settings[] = $link; return $settings; } /** * Redirect to the wpLingua settings page upon plugin activation. * * @param string $plugin The plugin file path that was activated. * @return void */ function wplng_plugin_activation_redirect( $plugin ) { if ( ! wp_doing_ajax() && WPLNG_PLUGIN_FILE === $plugin ) { wp_safe_redirect( admin_url( 'admin.php?page=wplingua-settings' ) ); exit(); } } /** * Display a notice if the plugin is activate but not configured * * @return void */ function wplng_admin_notice_no_key_set() { $url = add_query_arg( 'page', 'wplingua-settings', get_admin_url() . 'admin.php' ); $html = '
'; $html .= '

'; $html .= ' '; $html .= esc_html__( 'wpLingua - Translation solution for multilingual website', 'wplingua' ); $html .= '

'; $html .= '

'; $html .= esc_html__( 'wpLingua is installed, but not yet configured. You are just a few clicks away from making your website multilingual!', 'wplingua' ); $html .= '
'; $html .= ''; $html .= esc_html__( 'Go to the configuration page', 'wplingua' ); $html .= ''; $html .= '

'; $html .= '
'; echo $html; } /** * Get the list of activated incompatible plugins * * @return array [Plugin name => Plugin file] */ function wplng_get_incompatible_plugins() { if ( ! function_exists( 'is_plugin_active' ) ) { require_once ABSPATH . '/wp-admin/includes/plugin.php'; } /** * Get incompatible plugins */ $incompatible_list = array( 'Automatic Translator' => 'auto-translate/auto-translate.php', 'Autoglot' => 'autoglot/autoglot.php', 'clonable' => 'clonable/clonable-wp.php', 'ConveyThis Translate' => 'conveythis-translate/index.php', 'Falang' => 'falang/falang.php', 'Google Translator' => 'google-language-translator/google-language-translator.php', 'Google Website Translator' => 'google-website-translator/google-website-translator.php', 'Gtranslate' => 'gtranslate/gtranslate.php', 'linguise' => 'linguise/linguise.php', 'Lokalise' => 'lokalise/lokalise.php', 'localizejs' => 'localizejs/localizejs.php', 'Multilanguage' => 'multilanguage/multilanguage.php', 'Polylang' => 'polylang/polylang.php', 'TranslatePress' => 'translatepress-multilingual/index.php', 'WEGLOT' => 'weglot/weglot.php', 'WPML' => 'sitepress-multilingual-cms/sitepress.php', 'WP Multilang' => 'wp-multilang/wp-multilang.php', ); $incompatible_detected = array(); foreach ( $incompatible_list as $name => $file ) { if ( is_plugin_active( $file ) ) { $incompatible_detected[ $name ] = $file; } } return $incompatible_detected; } /** * Display a notice if an incompatible plugin is detected. * * @return void|string Outputs the admin notice or returns nothing if no conflicts are found. */ function wplng_admin_notice_incompatible_plugin() { $incompatible_plugins = wplng_get_incompatible_plugins(); if ( empty( $incompatible_plugins ) ) { return; } $html = '
$file ) { $deactivate_url = wp_nonce_url( add_query_arg( array( 'action' => 'deactivate', 'plugin' => urlencode( $file ), ), get_admin_url() . 'plugins.php' ), 'deactivate-plugin_' . $file ); $deactivate_title = sprintf( esc_html__( 'Deactivate plugin: %1$s', 'wplingua' ), $name ); $html .= '
  • '; $html .= '' . esc_html( $name ) . ' | '; $html .= ''; $html .= esc_html__( 'Deactivate', 'wplingua' ); $html .= ''; $html .= '
  • '; } $html .= ''; $html .= '

    '; $url_manage_plugins = add_query_arg( 'plugin_status', 'active', get_admin_url() . 'plugins.php' ); $html .= '= 0 ) { return; } $html = '