first commit

This commit is contained in:
Ryan Ariana
2024-05-06 11:04:37 +07:00
commit aee061ddba
7322 changed files with 2918816 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$plugin_file = "gtranslate/gtranslate.php";
$deactivate_link = wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.urlencode($plugin_file ).'&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $plugin_file);
?>
<div class="error settings-error notice is-dismissible ">
<div class="weglot-error-plugin">
<img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNzRweCIgaGVpZ2h0PSIxNXB4IiB2aWV3Qm94PSIwIDAgNzQgMTUiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDU0LjEgKDc2NDkwKSAtIGh0dHBzOi8vc2tldGNoYXBwLmNvbSAtLT4KICAgIDx0aXRsZT5Mb2dvPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGcgaWQ9IlN5bWJvbHMt8J+SjvCfko7wn5KOIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0iTWVudS9Db2xvciIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC4wMDAwMDAsIC0xMy4wMDAwMDApIiBmaWxsPSIjMEExQTQyIiBmaWxsLXJ1bGU9Im5vbnplcm8iPgogICAgICAgICAgICA8ZyBpZD0iTG9nbyI+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMS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sprintf( esc_html__( '%1$s %2$s.', 'weglot' ), '<strong>GTranslate</strong>', ' plugin is activated. It creates compatibility issues with Weglot, we recommend to deactivate it to use Weglot' );
?>
</p>
<p>
<a href="<?php echo $deactivate_link; //phpcs:ignore ?>" class="button">
<?php echo esc_html__( 'Deactivate GTranslate plugin', 'weglot' ); ?>
</a>
</p>
</div>

View File

@@ -0,0 +1,15 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo esc_html__( 'Weglot Translate: You need to activate package php-json. If you need help, please contact your host or just ask us directly at support@weglot.com.', 'weglot' );
?>
</p>
</div>

View File

@@ -0,0 +1,15 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo esc_html__( 'Words limit reached: You have reached the maximum number of translated words in your plan. Please upgrade your account to translate more words.', 'weglot' );
?>
</p>
</div>

View File

@@ -0,0 +1,20 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
$tab_settings = Helper_Tabs_Admin_Weglot::get_full_tabs()[ Helper_Tabs_Admin_Weglot::SETTINGS ];
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo sprintf( esc_html__( 'Weglot Translate is installed but not yet configured, you need to configure Weglot here : %1$sWeglot configuration page%2$s. The configuration takes only 1 minute! ', 'weglot' ), '<a href="' . esc_url( $tab_settings['url'] ) . '">', '</a>' );
?>
</p>
</div>

View File

@@ -0,0 +1,15 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo esc_html__( 'Weglot Translate: You need to activate cURL. If you need help, just ask us directly at support@weglot.com.', 'weglot' );
?>
</p>
</div>

View File

@@ -0,0 +1,25 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
/* translators: 1 is a plugin name, 2 is Weglot version, 3 is current php version. */
echo sprintf( esc_html__( '%1$s requires PHP %2$s minimum, your website is actually running version %3$s.', 'weglot' ), '<strong>Weglot translate</strong>', '<code>' . esc_html( WEGLOT_PHP_MIN ) . '</code>', '<code>' . esc_html( phpversion() ) . '</code>' );
?>
</p>
<p>
<?php
echo esc_html__( 'If you are not able to upgrade, you can rollback to the previous version by using the button below.', 'weglot' );
?>
</p>
<p>
<a href="<?php echo wp_nonce_url( admin_url( 'admin-post.php?action=weglot_rollback' ), 'weglot_rollback' ); //phpcs:ignore ?>" class="button">
<?php echo esc_html__( 'Re-install version 1.13.1', 'weglot' ); ?>
</a>
</p>
</div>

View File

@@ -0,0 +1,23 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$plugin_file = "polylang/polylang.php";
$deactivate_link = wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.urlencode($plugin_file ).'&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $plugin_file);
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
/* translators: 1 is a plugin name, 2 is Weglot version, 3 is current php version. */
echo sprintf( esc_html__( '%1$s %2$s.', 'weglot' ), '<strong>Polylang</strong>', 'plugin is activated. It creates compatibility issues with Weglot, we recommend to deactivate it to use Weglot' );
?>
</p>
<p>
<a href="<?php echo $deactivate_link; //phpcs:ignore ?>" class="button">
<?php echo esc_html__( 'Deactivate Polylang plugin', 'weglot' ); ?>
</a>
</p>
</div>

View File

@@ -0,0 +1,15 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo sprintf( esc_html__( 'Weglot Translate: You need to activate the mod_rewrite module. You can find more information here : %1$sUsing Permalinks%2$s. If you need help, just ask us directly at support@weglot.com.', 'weglot' ), '<a target="_blank" href="https://codex.wordpress.org/Using_Permalinks">', '</a>' );
?>
</p>
</div>

View File

@@ -0,0 +1,23 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$plugin_file = "translatepress-multilingual/index.php";
$deactivate_link = wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.urlencode($plugin_file ).'&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $plugin_file);
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
/* translators: 1 is a plugin name, 2 is Weglot version, 3 is current php version. */
echo sprintf( esc_html__( '%1$s %2$s.', 'weglot' ), '<strong>TranslatePress</strong>', ' plugin is activated. It creates compatibility issues with Weglot, we recommend to deactivate it to use Weglot' );
?>
</p>
<p>
<a href="<?php echo $deactivate_link; //phpcs:ignore ?>" class="button">
<?php echo esc_html__( 'Deactivate TranslatePress plugin', 'weglot' ); ?>
</a>
</p>
</div>

View File

@@ -0,0 +1,23 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$plugin_file = "sitepress-multilingual-cms/sitepress.php";
$deactivate_link = wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.urlencode($plugin_file ).'&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $plugin_file);
?>
<div class="error settings-error notice is-dismissible">
<p>
<?php
/* translators: 1 is a plugin name, 2 is Weglot version, 3 is current php version. */
echo sprintf( esc_html__( '%1$s %2$s.', 'weglot' ), '<strong>WPML Multilingual CMS</strong>', ' plugin is activated. It creates compatibility issues with Weglot, we recommend to deactivate it to use Weglot' );
?>
</p>
<p>
<a href="<?php echo $deactivate_link; //phpcs:ignore ?>" class="button">
<?php echo esc_html__( 'Deactivate WPML Multilingual CMS plugin', 'weglot' ); ?>
</a>
</p>
</div>

View File

@@ -0,0 +1,26 @@
<?php
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<nav class="nav-tab-wrapper">
<?php
foreach ( $this->tabs as $key => $weglot_tab ) {
$class_active = ( $this->tab_active === $key ) ? 'nav-tab-active' : '';
if ( Helper_Tabs_Admin_Weglot::STATUS !== $key ) {
?>
<a
href="<?php echo esc_url( $weglot_tab['url'] ); ?>"
class="nav-tab <?php echo esc_attr( $class_active ); ?>">
<?php echo esc_html( $weglot_tab['title'] ); ?>
</a>
<?php
}
}
?>
</nav>

View File

@@ -0,0 +1,117 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
use WeglotWP\Services\Option_Service_Weglot;
$this->option_services = weglot_get_service( 'Option_Service_Weglot' );
$organization_slug = $this->option_services->get_option('organization_slug');
$project_slug = $this->option_services->get_option('project_slug');
$project_dashboard_url = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/translations/languages/', 'weglot' );
$project_slug_url = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/translations/slugs/', 'weglot' );
$project_url_exclusions = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/settings/exclusions#excluded-urls', 'weglot' );
$project_blocks_exclusions = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/settings/exclusions#excluded-blocks', 'weglot' );
$project_switcher_editor = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/settings/language-switcher/editor', 'weglot' );
$project_auto_redirect = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/settings/general', 'weglot' );
$project_pageviews = esc_url( 'https://dashboard.weglot.com/workspaces/' . $organization_slug . '/projects/'. $project_slug .'/statistics/page-views/', 'weglot' );
$url_form = wp_nonce_url(
add_query_arg(
[
'action' => 'weglot_save_settings',
'tab' => $this->tab_active,
],
admin_url( 'admin-post.php' )
),
'weglot_save_settings'
);
?>
<div id="wrap-weglot">
<?php
if ( ! $this->options['has_first_settings'] ) :
?>
<div id="weglot-wrapper-infobox" class="wrap wrap-left">
<div class="weglot-infobox weglot-wp-menu">
<h3><img src="<?php echo esc_url(WEGLOT_DIRURL.'app/images/logo-wg.svg' ); ?>"></h3>
<div>
<ul>
<li><a href="#main_configuration"><?php esc_html_e( 'Main configuration', 'weglot' ) ?></a></li>
<li><a href="#language_button_position"><?php esc_html_e( 'Language button position', 'weglot' ) ?></a></li>
<li><a href="#translation_exclusion"><?php esc_html_e( 'Translation Exclusion', 'weglot' ) ?></a></li>
<li><a href="#other_options"><?php esc_html_e( 'Other options', 'weglot' ) ?></a></li>
</ul>
</div>
<blockquote class="text-cen">Weglot - <?php echo esc_html(WEGLOT_VERSION); ?></blockquote>
</div>
<div class="weglot-infobox weglot-info-translation-box">
<h3><?php esc_html_e( 'Where are my translations?', 'weglot' ); ?></h3>
<div>
<p><?php esc_html_e( 'You can find all your translations in your Weglot account:', 'weglot' ); ?></p>
<a href="<?php echo esc_url( $project_dashboard_url ); ?>"
target="_blank" class="weglot-editbtn">
<?php esc_html_e( 'Edit my translations', 'weglot' ); ?>
</a>
<p><span
class="wp-menu-image dashicons-before dashicons-welcome-comments"></span><?php esc_html_e( 'When you edit your translations in Weglot, remember to clear your cache (if you have a cache plugin) to make sure you see the latest version of your page)', 'weglot' ); ?>
</p>
</div>
</div>
</div>
<?php
endif;
?>
<div class="wrap">
<form method="post" id="mainform" action="<?php echo esc_url( $url_form ); ?>">
<?php
switch ( $this->tab_active ) {
case Helper_Tabs_Admin_Weglot::SETTINGS:
default:
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/settings.php';
if ( ! $this->options['has_first_settings'] ) {
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/appearance.php';
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/advanced.php';
}
break;
case Helper_Tabs_Admin_Weglot::STATUS:
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/status.php';
break;
case Helper_Tabs_Admin_Weglot::SUPPORT:
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/support.php';
break;
}
if ( ! in_array( $this->tab_active, [ Helper_Tabs_Admin_Weglot::STATUS ], true ) ) {
submit_button();
}
?>
<input type="hidden" name="tab" value="<?php echo esc_attr( $this->tab_active ); ?>">
</form>
<?php if ( ! $this->options['has_first_settings'] ) : ?>
<hr>
<span class="dashicons dashicons-heart"></span>&nbsp;
<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/weglot?rate=5#postform">
<?php esc_html_e( 'Love Weglot? Give us 5 stars on WordPress.org', 'weglot' ); ?>
</a>
<p class="weglot-five-stars">
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo sprintf( esc_html__( 'If you need any help, you can contact us via email us at %1$ssupport@weglot.com%2$s.', 'weglot' ), '<a href="mailto:support@weglot.com?subject=Need help from WP plugin admin" target="_blank">', '</a>' );
echo ' ';
// translators: 1 HTML Tag, 2 HTML Tag
echo sprintf( esc_html__( 'You can also check our %1$sFAQ%2$s.', 'weglot' ), '<a href="http://support.weglot.com/" target="_blank">', '</a>' ); ?>
</p>
<hr>
<?php endif; ?>
</div>
</div>

View File

@@ -0,0 +1,185 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use Weglot\Client\Client;
use Weglot\Util\Regex\RegexEnum;
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
use WeglotWP\Helpers\Helper_Excluded_Type;
$options_available = array(
'exclude_urls' => array(
'key' => 'exclude_urls',
'label' => __( 'Exclusion URL', 'weglot' ),
'description' => __( 'Add URL that you want to exclude from translations. You can use regular expression to match multiple URLs. ', 'weglot' ),
),
'exclude_blocks' => array(
'key' => 'exclude_blocks',
'label' => __( 'Exclusion Blocks', 'weglot' ),
'description' => __( 'Enter the CSS selector of blocks you don\'t want to translate (like a sidebar, a menu, a paragraph, etc...)', 'weglot' ),
),
'auto_redirect' => array(
'key' => 'auto_redirect',
'label' => __( 'Auto redirection', 'weglot' ),
'description' => __( 'Check if you want to redirect users based on their browser language.', 'weglot' ),
),
'email_translate' => array(
'key' => 'email_translate',
'label' => __( 'Translate email', 'weglot' ),
'description' => __( 'Check to translate all emails who use function wp_mail', 'weglot' ),
),
'translate_amp' => array(
'key' => 'translate_amp',
'label' => __( 'Translate AMP', 'weglot' ),
'description' => __( 'Translate AMP page', 'weglot' ),
),
'active_search' => array(
'key' => 'active_search',
'label' => __( 'Search WordPress', 'weglot' ),
'description' => __( 'Allow your users to search in the language they use.', 'weglot' ),
),
'private_mode' => array(
'key' => 'private_mode',
'label' => __( 'Private mode', 'weglot' ),
'description' => __( 'Check if your only want admin users to see the translations', 'weglot' ),
),
'active_wc_reload' => array(
'key' => 'active_wc_reload',
'label' => __( '[WooCommerce] : Prevent reload cart', 'weglot' ),
'description' => __( 'You should only enable this option if you have translation errors on your cart widget.', 'weglot' ),
),
'page_views_enabled' => array(
'key' => 'page_views_enabled',
'label' => __( 'Page views tracking (beta)', 'weglot' ),
'description' => __( 'You can enable tracking of page views. This will save the country and browser language of visitors.', 'weglot' ),
),
);
?>
<h3 id="translation_exclusion"><?php esc_html_e( 'Translation Exclusion (Optional)', 'weglot' ); ?> </h3>
<hr>
<p><?php esc_html_e( 'By default, every page is translated. You can exclude parts of a page or a full page here.', 'weglot' ); ?></p>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['exclude_urls']['key'] ); ?>">
<?php echo esc_html( $options_available['exclude_urls']['label'] ); ?>
</label>
<p class="sub-label"><?php echo esc_html( $options_available['exclude_urls']['description'] ); ?></p>
</th>
<td class="forminp forminp-text">
<a class="btn btn-soft" href="<?php echo esc_url( $project_url_exclusions ); ?>" target="_blank"><span
class="dashicons dashicons-admin-generic"></span> <?php esc_html_e( 'Manage URL to exclude', 'weglot' ); ?>
</a>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['exclude_blocks']['key'] ); ?>">
<?php echo esc_html( $options_available['exclude_blocks']['label'] ); ?>
</label>
<p class="sub-label"><?php echo esc_html( $options_available['exclude_blocks']['description'] ); ?></p>
</th>
<td class="forminp forminp-text">
<a class="btn btn-soft" href="<?php echo esc_url( $project_blocks_exclusions ); ?>" target="_blank"><span
class="dashicons dashicons-admin-generic"></span> <?php esc_html_e( 'Manage block to exclude', 'weglot' ); ?>
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="other_options"><?php esc_html_e( 'Other options (Optional)', 'weglot' ); ?></h3>
<hr>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['auto_redirect']['key'] ); ?>">
<?php echo esc_html( $options_available['auto_redirect']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[auto_switch]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['auto_redirect']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['auto_redirect']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['auto_redirect']['description'] ); ?></p>
<p><small><span class="wp-menu-image dashicons-before dashicons-welcome-comments"></span>You can configure the auto redirection further in your Weglot <a href="<?php echo esc_url( $project_auto_redirect ); ?>" title="Go to your Weglot dasboard" target="_blank"> dashboard</a>.</small></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['email_translate']['key'] ); ?>">
<?php echo esc_html( $options_available['email_translate']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][translate_email]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['email_translate']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['email_translate']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['email_translate']['description'] ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['translate_amp']['key'] ); ?>">
<?php echo esc_html( $options_available['translate_amp']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][translate_amp]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['translate_amp']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['translate_amp']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['translate_amp']['description'] ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['active_search']['key'] ); ?>">
<?php echo esc_html( $options_available['active_search']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][translate_search]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['active_search']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['active_search']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['active_search']['description'] ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['page_views_enabled']['key'] ); ?>">
<?php echo esc_html( $options_available['page_views_enabled']['label'] ); ?>
</label>
<p class="sub-label"><?php echo esc_html( $options_available['page_views_enabled']['description'] ); ?></p>
</th>
<td class="forminp forminp-text">
<?php if ( $this->options['page_views_enabled'] ) : ?>
<p class="description"><a target="_blank" href="<?php echo esc_url( $project_pageviews ); ?>" title="Page views tracking is activated">Page views tracking</a> is <b>activated</b></p>
<?php else : ?>
<p class="description"><a target="_blank" href="<?php echo esc_url( $project_pageviews ); ?>" title="Page views tracking is deactivated">Page views tracking</a> is <b>deactivated</b></p>
<?php endif; ?>
<p><small><span class="wp-menu-image dashicons-before dashicons-welcome-comments"></span><?php esc_html_e( 'When you enable page views tracking, Weglot plugin will send statistics about your visitors\' browser language and country. You can then view this data in your Weglot account, for example your visitors\' most common country or most common language. Note that these statistics are completely anonymous.', 'weglot' ); ?></small></p>
</td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,373 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
use WeglotWP\Helpers\Helper_Flag_Type;
$options_available = [
'type_flags' => [
'key' => 'type_flags',
'label' => __( 'Type of flags', 'weglot' ),
'description' => '',
],
'is_fullname' => [
'key' => 'is_fullname',
'label' => __( 'Is fullname', 'weglot' ),
'description' => __( "Check if you want the name of the language. Don't check if you want the language code.", 'weglot' ),
],
'with_name' => [
'key' => 'with_name',
'label' => __( 'With name', 'weglot' ),
'description' => __( 'Check if you want to display the name of languages.', 'weglot' ),
],
'is_dropdown' => [
'key' => 'is_dropdown',
'label' => __( 'Is dropdown', 'weglot' ),
'description' => __( 'Check if you want the button to be a dropdown box.', 'weglot' ),
],
'with_flags' => [
'key' => 'with_flags',
'label' => __( 'With flags', 'weglot' ),
'description' => __( 'Check if you want flags in the language button.', 'weglot' ),
],
'override_css' => [
'key' => 'override_css',
'label' => __( 'Override CSS', 'weglot' ),
'description' => __( "Don't change it unless you want a specific style for your button.", 'weglot' ),
],
'flag_css' => [
'key' => 'flag_css',
],
'switcher_editor' => [
'key' => 'switcher_editor',
'label' => __( 'Custom position?', 'weglot' ),
'description' => __( 'You can place the button anywhere in your site using our switcher editor in your Weglot Dashboard', 'weglot' ),
],
];
?>
<style id="weglot-css-flag-css"></style>
<style id="weglot-css-inline"></style>
<?php if ( empty( $this->option_services->get_switchers_editor_button() ) ) { ?>
<h3 id="language_button_design">
<?php echo esc_html__( 'Language button design', 'weglot' ) . ' ' . esc_html__( '(Optional)', 'weglot' ); ?>
</h3>
<hr/>
<?php } ?>
<table class="form-table">
<tbody>
<?php if ( empty( $this->option_services->get_switchers_editor_button() ) ) { ?>
<tr valign="top">
<th scope="row" class="titledesc">
<label>
<?php echo esc_html__( 'Button preview', 'weglot' ); ?>
</label>
</th>
<td class="forminp forminp-text">
<?php echo $this->button_services->get_html( 'weglot-preview' ); //phpcs:ignore ?>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['is_dropdown']['key'] ); ?>">
<?php echo esc_html( $options_available['is_dropdown']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][button_style][is_dropdown]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['is_dropdown']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['is_dropdown']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['is_dropdown']['description'] ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['with_flags']['key'] ); ?>">
<?php echo esc_html( $options_available['with_flags']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][button_style][with_flags]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['with_flags']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['with_flags']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['with_flags']['description'] ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['type_flags']['key'] ); ?>">
<?php echo esc_html( $options_available['type_flags']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<select
class="wg-input-select"
name="<?php echo esc_attr( sprintf( '%s[custom_settings][button_style][flag_type]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['type_flags']['key'] ); ?>"
>
<option
<?php selected( $this->options[ $options_available['type_flags']['key'] ], Helper_Flag_Type::RECTANGLE_MAT ); ?>
data-value="<?php echo esc_attr( Helper_Flag_Type::get_flag_number_with_type( Helper_Flag_Type::RECTANGLE_MAT ) ); ?>"
value="<?php echo esc_attr( Helper_Flag_Type::RECTANGLE_MAT ); ?>"
>
<?php esc_html_e( 'Rectangle mat', 'weglot' ); ?>
</option>
<option
<?php selected( $this->options[ $options_available['type_flags']['key'] ], Helper_Flag_Type::SHINY ); ?>
data-value="<?php echo esc_attr( Helper_Flag_Type::get_flag_number_with_type( Helper_Flag_Type::SHINY ) ); ?>"
value="<?php echo esc_attr( Helper_Flag_Type::SHINY ); ?>"
>
<?php esc_html_e( 'Rectangle shiny', 'weglot' ); ?>
</option>
<option
<?php selected( $this->options[ $options_available['type_flags']['key'] ], Helper_Flag_Type::SQUARE ); ?>
data-value="<?php echo esc_attr( Helper_Flag_Type::get_flag_number_with_type( Helper_Flag_Type::SQUARE ) ); ?>"
value="<?php echo esc_attr( Helper_Flag_Type::SQUARE ); ?>"
>
<?php esc_html_e( 'Square', 'weglot' ); ?>
</option>
<option
<?php selected( $this->options[ $options_available['type_flags']['key'] ], Helper_Flag_Type::CIRCLE ); ?>
data-value="<?php echo esc_attr( Helper_Flag_Type::get_flag_number_with_type( Helper_Flag_Type::CIRCLE ) ); ?>"
value="<?php echo esc_attr( Helper_Flag_Type::CIRCLE ); ?>"
>
<?php esc_html_e( 'Circle', 'weglot' ); ?>
</option>
</select>
<div class="flag-style-openclose"><?php esc_html_e( 'Change country flags', 'weglot' ); ?></div>
<p id="custom_flag_tips">You are still using old flags. To use new SVG flags, make sure you are using
the default flags (if you have some custom CSS related to background-position or background-image,
remove it). Then save your settings and you will be using the flags</p>
<div class="flag-style-wrapper" style="display:none;">
<select class="flag-en-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose English flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'United Kingdom (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'United States', 'weglot' ); ?></option>
<option value=2><?php esc_html_e( 'Australia', 'weglot' ); ?></option>
<option value=3><?php esc_html_e( 'Canada', 'weglot' ); ?></option>
<option value=4><?php esc_html_e( 'New Zealand', 'weglot' ); ?></option>
<option value=5><?php esc_html_e( 'Jamaica', 'weglot' ); ?></option>
<option value=6><?php esc_html_e( 'Ireland', 'weglot' ); ?></option>
</select>
<select class="flag-es-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose Spanish flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'Spain (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'Mexico', 'weglot' ); ?></option>
<option value=2><?php esc_html_e( 'Argentina', 'weglot' ); ?></option>
<option value=3><?php esc_html_e( 'Colombia', 'weglot' ); ?></option>
<option value=4><?php esc_html_e( 'Peru', 'weglot' ); ?></option>
<option value=5><?php esc_html_e( 'Bolivia', 'weglot' ); ?></option>
<option value=6><?php esc_html_e( 'Uruguay', 'weglot' ); ?></option>
<option value=7><?php esc_html_e( 'Venezuela', 'weglot' ); ?></option>
<option value=8><?php esc_html_e( 'Chile', 'weglot' ); ?></option>
<option value=9><?php esc_html_e( 'Ecuador', 'weglot' ); ?></option>
<option value=10><?php esc_html_e( 'Guatemala', 'weglot' ); ?></option>
<option value=11><?php esc_html_e( 'Cuba', 'weglot' ); ?></option>
<option value=12><?php esc_html_e( 'Dominican Republic', 'weglot' ); ?></option>
<option value=13><?php esc_html_e( 'Honduras', 'weglot' ); ?></option>
<option value=14><?php esc_html_e( 'Paraguay', 'weglot' ); ?></option>
<option value=15><?php esc_html_e( 'El Salvador', 'weglot' ); ?></option>
<option value=16><?php esc_html_e( 'Nicaragua', 'weglot' ); ?></option>
<option value=17><?php esc_html_e( 'Costa Rica', 'weglot' ); ?></option>
<option value=18><?php esc_html_e( 'Puerto Rico', 'weglot' ); ?></option>
<option value=19><?php esc_html_e( 'Panama', 'weglot' ); ?></option>
</select>
<select class="flag-fr-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose French flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'France (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'Belgium', 'weglot' ); ?></option>
<option value=2><?php esc_html_e( 'Canada', 'weglot' ); ?></option>
<option value=3><?php esc_html_e( 'Switzerland', 'weglot' ); ?></option>
<option value=4><?php esc_html_e( 'Luxemburg', 'weglot' ); ?></option>
</select>
<select class="flag-ar-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose Arabic flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'Saudi Arabia (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'Algeria', 'weglot' ); ?></option>
<option value=2><?php esc_html_e( 'Egypt', 'weglot' ); ?></option>
<option value=3><?php esc_html_e( 'Iraq', 'weglot' ); ?></option>
<option value=4><?php esc_html_e( 'Jordan', 'weglot' ); ?></option>
<option value=5><?php esc_html_e( 'Kuwait', 'weglot' ); ?></option>
<option value=6><?php esc_html_e( 'Lebanon', 'weglot' ); ?></option>
<option value=7><?php esc_html_e( 'Libya', 'weglot' ); ?></option>
<option value=8><?php esc_html_e( 'Morocco', 'weglot' ); ?></option>
<option value=14><?php esc_html_e( 'Oman', 'weglot' ); ?></option>
<option value=9><?php esc_html_e( 'Qatar', 'weglot' ); ?></option>
<option value=10><?php esc_html_e( 'Syria', 'weglot' ); ?></option>
<option value=11><?php esc_html_e( 'Tunisia', 'weglot' ); ?></option>
<option value=12><?php esc_html_e( 'United Arab Emirates', 'weglot' ); ?></option>
<option value=13><?php esc_html_e( 'Yemen', 'weglot' ); ?></option>
</select>
<select class="flag-zh-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose Simplified Chinese flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'China (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'Taiwan', 'weglot' ); ?></option>
<option value=2><?php esc_html_e( 'Hong Kong', 'weglot' ); ?></option>
</select>
<select class="flag-tw-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose Traditional Chinese flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'Taiwan (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'China', 'weglot' ); ?></option>
<option value=2><?php esc_html_e( 'Hong Kong', 'weglot' ); ?></option>
</select>
<select class="flag-pt-type wg-input-select">
<option value=0><?php esc_html_e( 'Choose Portuguese flag:', 'weglot' ); ?></option>
<option value=0><?php esc_html_e( 'Portugal (default)', 'weglot' ); ?></option>
<option value=1><?php esc_html_e( 'Brazil', 'weglot' ); ?></option>
</select>
<p><?php esc_html_e( 'If you want to use a different flag, just ask us.', 'weglot' ); ?></p>
</div>
<textarea id="flag_css"
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['flag_css']['key'] ) ); ?>"
style="display:none;"><?php echo esc_html( $this->options['flag_css'] ); ?></textarea>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['with_name']['key'] ); ?>">
<?php echo esc_html( $options_available['with_name']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][button_style][with_name]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['with_name']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['with_name']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['with_name']['description'] ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['is_fullname']['key'] ); ?>">
<?php echo esc_html( $options_available['is_fullname']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[custom_settings][button_style][full_name]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['is_fullname']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['is_fullname']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['is_fullname']['description'] ); ?></p>
</td>
</tr>
<?php } ?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['override_css']['key'] ); ?>">
<?php echo esc_html( $options_available['override_css']['label'] ); ?>
</label>
<p class="sub-label"><?php echo esc_html( $options_available['override_css']['description'] ); ?></p>
</td>
</th>
<td class="forminp forminp-text">
<textarea
class="wg-input-textarea"
id="<?php echo esc_attr( $options_available['override_css']['key'] ); ?>"
type="text"
rows="10"
cols="30"
name="<?php echo esc_attr( sprintf( '%s[custom_settings][button_style][custom_css]', WEGLOT_SLUG ) ); ?>"
placeholder=".country-selector {
margin-bottom: 20px;
}"><?php echo $this->options[ $options_available['override_css']['key'] ]; //phpcs:ignore?></textarea>
</tr>
<?php if ( empty( $this->option_services->get_switchers_editor_button() ) ) { ?>
</tbody>
</table>
<?php } ?>
<h3 id="language_button_position">
<?php echo esc_html_e( 'Language button position', 'weglot' ) . ' ' . esc_html__( '(Optional)', 'weglot' ); ?>
</h3>
<hr/>
<p><?php esc_html_e( 'Where will the language button be on my website? By default, bottom right.', 'weglot' ); ?></p>
<table class="form-table">
<?php if ( isset( $this->options['is_menu'] ) && $this->options['is_menu'] ) : ?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="is_menu>">
<?php echo esc_html__( 'In menu (Weglot translate V1) ?', 'weglot' ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="is_menu"
id="is_menu"
type="checkbox"
checked
style="display:inline-block;"
>
<div class="notice notice-error is-dismissible"
style="display: inline-block; position: relative; width: 80%; vertical-align: middle;">
<p>
<?php
// translators: 1 HTML Tag, 2 HTML Tag
echo esc_html__( 'Warning, this feature will be depreciated. We strongly advise you to uncheck the option and use and use the functionality: "In menu".', 'weglot' );
?>
</p>
</div>
</td>
</tr>
<?php endif; ?>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'In menu?', 'weglot' ); ?></th>
<td>
<?php echo sprintf( esc_html__( 'You can place the button in a menu area. Go to %1$sAppearance → Menus%2$s and drag and drop the Weglot Translate Custom link where you want.', 'weglot' ), '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '">', '</a>' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'As a widget?', 'weglot' ); ?></th>
<td>
<?php echo sprintf( esc_html__( 'You can place the button in a widget area. Go to %1$sAppearance → Widgets%2$s and drag and drop the Weglot Translate widget where you want.', 'weglot' ), '<a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">', '</a>' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'With a shortcode?', 'weglot' ); ?></th>
<td>
<?php esc_html_e( 'You can use the Weglot shortcode [weglot_switcher] wherever you want to place the button.', 'weglot' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'In the source code?', 'weglot' ); ?></th>
<td>
<?php esc_html_e( 'You can add the code &lt;div id=&quot;weglot_here&quot;&gt;&lt;/div&gt; wherever you want in the source code of your HTML page. The button will appear at this place.', 'weglot' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['switcher_editor']['key'] ); ?>">
<?php echo esc_html( $options_available['switcher_editor']['label'] ); ?>
</label>
<p class="sub-label"><?php echo esc_html( $options_available['switcher_editor']['description'] ); ?></p>
</th>
<td class="forminp forminp-text">
<a class="btn btn-soft"
href="<?php echo esc_url( $project_switcher_editor ); ?>"
target="_blank"><span
class="dashicons dashicons-admin-generic"></span> <?php esc_html_e( 'Use switcher editor', 'weglot' ); ?>
</a>
</td>
</tr>
</table>
<template id="li-button-tpl">
<li class="wg-li {CLASSES} {CODE_LANGUAGE}" data-code-language="{CODE_LANGUAGE}">
<a href="#">{LABEL_LANGUAGE}</a></li>
</template>

View File

@@ -0,0 +1,213 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
// manage link to add utm for tracking where in instawp env.
$instawp = get_option( 'weglot_instawp' );
$signup_link = esc_url( 'https://dashboard.weglot.com/register-wordpress' );
if ( $instawp ) {
$signup_link = esc_url( 'https://dashboard.weglot.com/register-wordpress?utm_source=partners&utm_medium=integration&utm_campaign=insta-wp' );
}
$options_available = apply_filters(
'weglot_tabs_admin_options_available', [
'api_key_private' => [
'key' => 'api_key_private',
'label' => __( 'API Key', 'weglot' ),
'description' => sprintf( esc_html__( 'Log in to %1$sWeglot%2$s to get your API key.', 'weglot' ), '<a target="_blank" href="' . $signup_link . '">', '</a>' ),
],
'language_from' => [
'key' => 'original_language',
'label' => __( 'Original language', 'weglot' ),
'description' => 'What is the original (current) language of your website?',
],
'languages' => [
'key' => 'destination_language',
'label' => __( 'Destination languages', 'weglot' ),
'description' => sprintf( esc_html__( 'Choose languages you want to translate into. Supported languages can be found %1$shere%2$s.', 'weglot' ), '<a target="_blank" href="https://weglot.com/documentation/available-languages/">', '</a>' ),
],
]
);
$user_info = $this->user_api_services->get_user_info();
$plans = $this->user_api_services->get_plans();
?>
<h3 id="main_configuration"><?php esc_html_e( 'Main configuration', 'weglot' ); ?></h3>
<hr>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['api_key_private']['key'] ); ?>">
<?php echo esc_html( $options_available['api_key_private']['label'] ); ?>
</label>
<p class="sub-label"><?php echo $options_available['api_key_private']['description']; //phpcs:ignore ?></p>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['api_key_private']['key'] ) ); ?>"
id="<?php echo esc_attr( $options_available['api_key_private']['key'] ); ?>"
type="text"
required
placeholder="wg_XXXXXXXXXXXX"
value="<?php echo esc_attr( $this->options[ $options_available['api_key_private']['key'] ] ); ?>"
>
<br>
<?php
if ( $this->options['has_first_settings'] ) {
?>
<p class="description"><?php echo esc_html_e( 'If you don\'t have an account, you can create one in 20 seconds !', 'weglot' ); ?></p>
<?php
}
?>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['language_from']['key'] ); ?>">
<?php echo esc_html( $options_available['language_from']['label'] ); ?>
</label>
<p class="sub-label"><?php echo $options_available['language_from']['description']; //phpcs:ignore ?></p>
</th>
<td class="forminp forminp-text">
<select
class="weglot-select weglot-select-original"
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, 'language_from' ) ); ?>"
id="<?php echo esc_attr( $options_available['language_from']['key'] ); ?>"
>
<?php
$wplang = 'en';
if ( ! empty( get_option( 'WPLANG' ) ) ) {
$wplang = substr( get_option( 'WPLANG' ), 0, 2 );
}
$original_languages_possible = $this->language_services->get_languages_available( [ 'sort' => true ] );
foreach ( $original_languages_possible as $language ) {
if ( $language->getInternalCode() !== 'br' ) {
?>
<?php if ( $this->options['has_first_settings'] ) { ?>
<option
value="<?php echo esc_attr( $language->getInternalCode() ); ?>"
<?php selected( $language->getInternalCode(), $wplang ); ?>
>
<?php esc_html_e( $language->getEnglishName(), 'weglot' ); //phpcs:ignore ?>
</option>
<?php
} else { ?>
<option
value="<?php echo esc_attr( $language->getInternalCode() ); ?>"
<?php selected( $language->getInternalCode(), $this->options[ $options_available['language_from']['key'] ] ); ?>
>
<?php esc_html_e( $language->getEnglishName(), 'weglot' ); //phpcs:ignore ?>
</option>
<?php }
}
}
?>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['languages']['key'] ); ?>">
<?php echo esc_html( $options_available['languages']['label'] ); ?>
</label>
<p class="sub-label"><?php echo $options_available['languages']['description']; //phpcs:ignore ?></p>
</th>
<td class="forminp forminp-text">
<select
class="weglot-select weglot-select-destination"
style="display:none"
name="<?php echo esc_attr( sprintf( '%s[languages][][language_to]', WEGLOT_SLUG ) ); ?>"
id="<?php echo esc_attr( $options_available['languages']['key'] ); ?>"
multiple="true"
required
>
<?php
$languages = $this->language_services->get_all_languages();
$destination_languages = $this->language_services->get_destination_languages( true );
foreach ( $destination_languages as $language ) :
?>
<option
value="<?php echo esc_attr( $language->getInternalCode() ); ?>"
selected="selected">
<?php echo esc_html( $language->getLocalName() ); ?>
</option>
<?php endforeach; ?>
<?php foreach ( $languages as $language ) : ?>
<option
value="<?php echo esc_attr( $language->getInternalCode() ); ?>"
<?php selected( true, in_array( $language, $destination_languages, true ) ); ?>
>
<?php echo esc_html( $language->getLocalName() ); ?>
</option>
<?php endforeach; ?>
</select>
<?php
if ( $user_info && isset( $user_info['plan_id'] ) && $user_info['plan_id'] <= 1 ) {
?>
<p class="description">
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
<?php echo sprintf( esc_html__( 'On the free plan, you can choose one language and use a maximum of 2000 words. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
</p>
<?php
} elseif ( isset( $user_info['plan_id'] ) && in_array( $user_info['plan_id'], $plans['starter_free']['ids'] ) ) { //phpcs:ignore
?>
<p class="description">
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
<?php echo sprintf( esc_html__( 'On the Starter plan, you can choose one language. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
</p>
<?php
} elseif ( isset( $user_info['plan_id'] ) && in_array( $user_info['plan_id'], $plans['business']['ids'] ) ) { //phpcs:ignore
?>
<p class="description">
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
<?php echo sprintf( esc_html__( 'On the Business plan, you can choose 3 languages. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
</p>
<?php
} elseif ( isset( $user_info['plan_id'] ) && in_array( $user_info['plan_id'], $plans['pro']['ids'] ) ) { //phpcs:ignore
?>
<p class="description">
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
<?php echo sprintf( esc_html__( 'On the Pro plan, you can choose 5 languages. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
</p>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
<?php if ( ! $this->options['has_first_settings'] && $this->options['show_box_first_settings'] ) : ?>
<?php $this->option_services->set_option_by_key( 'show_box_first_settings', false ); ?>
<div id="weglot-box-first-settings" class="weglot-box-overlay">
<div class="weglot-box">
<a class="weglot-btn-close"><?php esc_html_e( 'Close', 'weglot' ); ?></a>
<h3 class="weglot-box--title"><?php esc_html_e( 'Well done! Your website is now multilingual.', 'weglot' ); ?></h3>
<p class="weglot-box--text"><?php esc_html_e( 'Go on your website, there is a language switcher bottom right. Try it :)', 'weglot' ); ?></p>
<a class="button button-primary" href="<?php echo esc_url( home_url() ); ?>" target="_blank">
<?php esc_html_e( 'Go on my front page.', 'weglot' ); ?>
</a>
<p class="weglot-box--subtext"><?php esc_html_e( 'Next step, customize the language button as you want and manually edit your translations directly in your Weglot account.', 'weglot' ); ?></p>
</div>
</div>
<?php
if ( $this->options[ $options_available['languages']['key'] ] && count( $this->options[ $options_available['languages']['key'] ] ) > 0 ) :
?>
<iframe
style="visibility:hidden;"
src="<?php echo esc_url( sprintf( '%s/%s', home_url(), $this->options[ $options_available['languages']['key'] ][0]['language_to'] ) ); ?>/"
width="1" height="1">
</iframe>
<?php endif; ?>
<?php endif; ?>

View File

@@ -0,0 +1,157 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use Weglot\WeglotContext;
?>
<h2><?php esc_html_e( 'Status', 'weglot' ); ?></h2>
<?php
$php_min_54 = true;
if ( version_compare( phpversion(), '5.4', '<' ) ) {
$php_min_54 = false;
}
$options = weglot_get_options();
?>
<div class="wrap">
<table class="widefat" cellspacing="0" id="status">
<thead>
<tr>
<th colspan="3" data-export-label="WordPress Environment"><h2>WordPress environment</h2></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php esc_html_e( 'Home URL', 'weglot' ); ?></td>
<td><?php echo esc_html( home_url() ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Site URL', 'weglot' ); ?></td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Weglot version', 'weglot' ); ?></td>
<td><?php echo esc_html( WEGLOT_VERSION ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'WordPress version', 'weglot' ); ?></td>
<td><?php echo esc_html( get_bloginfo( 'version' ) ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Is multisite', 'weglot' ); ?></td>
<td>
<?php echo is_multisite() ? 'Yes' : '-'; ?>
</td>
</tr>
<tr>
<td><?php esc_html_e( 'WordPress Debug mode', 'weglot' ); ?></td>
<td>
<?php if ( defined( WP_DEBUG ) && WP_DEBUG ): //phpcs:ignore ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php endif; ?>
</td>
</tr>
<tr>
<td><?php esc_html_e( 'Permalink Structure', 'weglot' ); ?></td>
<td><?php echo esc_html( get_option( 'permalink_structure' ) ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Language', 'weglot' ); ?></td>
<td><?php echo esc_html( get_locale() ); ?></td>
</tr>
</tbody>
</table>
<br />
<table class="widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Server Environment"><h2><?php esc_html_e( 'Server environment', 'weglot' ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php esc_html_e( 'Server info', 'weglot' ); ?></td>
<td><?php echo ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) ? $_SERVER['SERVER_SOFTWARE'] : 'Unknown' //phpcs:ignore ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'PHP Version', 'weglot' ); ?></td>
<td>
<?php echo phpversion(); //phpcs:ignore ?>
<?php if ( ! $php_min_54 ) : ?>
<mark class="error">
<span class="dashicons dashicons-warning"></span> -
<?php echo esc_html__( 'We need a minimum PHP version : 5.4.', 'weglot' ); ?>
</mark>
<?php endif; ?>
</td>
</tr>
<tr>
<td><?php esc_html_e( 'Module mod_rewrite', 'weglot' ); ?></td>
<td>
<?php echo $apache_mod_rewrite; //phpcs:ignore ?>
</td>
</tr>
</tbody>
</table>
<br />
<table class="widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Server Environment"><h2><?php esc_html_e( 'Weglot environment', 'weglot' ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php esc_html_e( 'Original Language', 'weglot' ); ?></td>
<td><?php echo esc_html( $this->language_services->get_original_language()->getInternalCode() ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Destination Language', 'weglot' ); ?></td>
<td>
<?php foreach ( $this->language_services->get_destination_languages_external( true ) as $language ) : ?>
<?php echo esc_attr( sprintf( '%s - ', $language ) ); ?>
<?php endforeach; ?>
</td>
</tr>
<tr>
<td><?php esc_html_e( 'Exclude URLs', 'weglot' ); ?></td>
<td>
<?php
if ( ! empty( $options['exclude_urls'] ) ) :
foreach ( $options['exclude_urls'] as $t => $exclude_url ) :
if ( empty( $exclude_url['type'] ) || empty( $exclude_url['value'] ) ) {
continue;
}
echo esc_html( $exclude_url['type'] . ' - ' . $exclude_url['value'] ) . '<br/>';
endforeach;
else :
esc_html_e( 'Empty', 'weglot' );
endif;
?>
</td>
</tr>
<tr>
<td><?php esc_html_e( 'Exclude Blocks', 'weglot' ); ?></td>
<td><?php echo esc_html( implode( $options['exclude_blocks'], ' - ' ) ); ?></td>
</tr>
</tbody>
</table>
<br />
<div class="widefat">
<h2><?php esc_html_e( 'Custom URLS', 'weglot' ); ?></h2>
<pre><?php var_export( $options['custom_urls'] ); // phpcs:ignore ?></pre>
</div>
</div>

View File

@@ -0,0 +1,42 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$options_available = [
'active_wc_reload' => [
'key' => 'active_wc_reload',
'label' => __( '[WooCommerce] : Prevent reload cart', 'weglot' ),
'description' => __( 'You should only enable this option if you have translation errors on your cart widget.', 'weglot' ),
],
];
?>
<h3><?php esc_html_e( 'Options for support', 'weglot' ); ?> </h3>
<hr>
<table class="form-table">
<tbody>
<?php if ( $this->wc_active_services->is_active() ) : ?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $options_available['active_wc_reload']['key'] ); ?>">
<?php echo esc_html( $options_available['active_wc_reload']['label'] ); ?>
</label>
</th>
<td class="forminp forminp-text">
<input
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['active_wc_reload']['key'] ) ); ?>"
id="<?php echo esc_attr( $options_available['active_wc_reload']['key'] ); ?>"
type="checkbox"
<?php checked( $this->options[ $options_available['active_wc_reload']['key'] ], 1 ); ?>
>
<p class="description"><?php echo esc_html( $options_available['active_wc_reload']['description'] ); ?></p>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>