Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
addresses #449 by adding info to woo status report
Browse files Browse the repository at this point in the history
Adds current language, polylang default language, polylang languages
and whether WooCommerce translation files are downloaded
  • Loading branch information
Jon007 committed Aug 1, 2019
1 parent b497c7c commit c827695
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/Hyyan/WPI/Admin/StatusReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

use Hyyan\WPI\Tools\TranslationsDownloader;

/*
*
*/
add_action( 'woocommerce_system_status_report', 'wpi_status_report' );
function wpi_status_report() {
?>

<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="WooCommerce Polylang Integration"><h2><?php esc_html_e( 'WooCommerce Polylang Integration', 'woo-poly-integration' ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="Language Locale"><?php esc_html_e( 'Language Locale', 'woo-poly-integration' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The current language used by WordPress. Default = English', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( get_locale() ); ?></td>
</tr>
<tr>
<td data-export-label="Polylang Language Locale"><?php esc_html_e( 'Polylang Default Language Locale', 'woo-poly-integration' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The default language set in Polylang', 'woo-poly-integration' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( pll_default_language( 'locale' ) ); ?></td>
</tr>
<tr>
<td data-export-label="Polylang Available Languages"><?php esc_html_e( 'Polylang Available Languages', 'woo-poly-integration' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The available languages in Polylang', 'woo-poly-integration' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php
$langs = pll_languages_list( array( 'fields' => 'locale' ) );

foreach ( $langs as $langId => $langLocale ) {
echo($langLocale);
$downloaded = TranslationsDownloader::isDownloaded( $langLocale );
$location = sprintf(
trailingslashit( WP_LANG_DIR )
. 'plugins/woocommerce-%s.mo', $langLocale
);
if ( $downloaded ) {
echo(' (WooCommerce translation file found OK at ' . $location . ') ');
} else {
echo(' Warning - missing WooCommerce translation file NOT found at ' . $location . ' ');
}
echo '<br/>';
}
?></td>
</tr>
</tbody>
</table>

<?php
}
?>
8 changes: 8 additions & 0 deletions src/Hyyan/WPI/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct()

add_action('init', array($this, 'activate'));
add_action('plugins_loaded', array($this, 'loadTextDomain'));
add_action( 'admin_init', array( __CLASS__, 'admin_activate' ) );

add_action( 'pll_add_language', array( __CLASS__, 'handleNewLanguage' ) );

Expand All @@ -53,6 +54,13 @@ public function __construct()
}
}

/*
* enable admin features in admin mode
*/
public static function admin_activate() {
include_once( plugin_dir_path( __FILE__ ) . 'Admin/StatusReport.php');
}

/*
* when new language is added in polylang, flag that default pages should be rechecked
* (try not to download immediately as translation files will not be downloaded yet)
Expand Down

0 comments on commit c827695

Please sign in to comment.