Файловый менеджер - Редактировать - /home/infrafs/INFRABIKEIT/wp-content/plugins/weglot.tar
Назад
weglot-compatibility.php 0000644 00000004322 15134111570 0011424 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Compatibility WP < 4.7.0 */ if ( ! function_exists( 'wp_doing_ajax' ) ) { function wp_doing_ajax() { /** * Filters whether the current request is a WordPress Ajax request. * * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request. * * @since 4.7.0 * */ return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); } } if ( ! function_exists( 'is_rest' ) ) { /** * Checks if the current request is a WP REST API request. * * Case #1: After WP_REST_Request initialisation * Case #2: Support "plain" permalink settings * Case #3: URL Path begins with wp-json/ (your REST prefix) * Also supports WP installations in subfolders * * @returns boolean * @author matzeeable */ function is_rest() { $prefix = rest_get_url_prefix(); if ( defined( 'REST_REQUEST' ) && REST_REQUEST // (#1) || isset( $_GET['rest_route'] ) //phpcs:ignore && strpos( trim( $_GET['rest_route'], '\\/' ), $prefix, 0 ) === 0 ) { //phpcs:ignore return true; } // (#3) $rest_url = wp_parse_url( site_url( $prefix ) ); $current_url = wp_parse_url( add_query_arg( array() ) ); if( !isset( $current_url['path'] ) || !isset( $rest_url['path'] ) ) { return false; } else { return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0; } } } /** * Compatibility for library weglot-php PHP 5.4 */ if ( ! function_exists( 'array_column' ) ) { function array_column( array $input, $column_key, $index_key = null ) { $array = array(); foreach ( $input as $value ) { if ( ! array_key_exists( $column_key, $value ) ) { trigger_error( "Key \"$column_key\" does not exist in array" ); return false; } if ( is_null( $index_key ) ) { $array[] = $value[ $column_key ]; } else { if ( ! array_key_exists( $index_key, $value ) ) { trigger_error( "Key \"$index_key\" does not exist in array" ); return false; } if ( ! is_scalar( $value[ $index_key ] ) ) { trigger_error( "Key \"$index_key\" does not contain scalar value" ); return false; } $array[ $value[ $index_key ] ] = $value[ $column_key ]; } } return $array; } } weglot-functions.php 0000644 00000011636 15134111570 0010571 0 ustar 00 <?php use Weglot\Client\Api\LanguageCollection; use Weglot\Client\Api\LanguageEntry; use WeglotWP\Services\Request_Url_Service_Weglot; if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Get a service Weglot * @param string $service * @return object * @throws Exception * @since 2.0 * */ function weglot_get_service( $service ) { return Context_Weglot::weglot_get_context()->get_service( $service ); } /** * Get all options * @return array * @throws Exception * @since 2.0 * */ function weglot_get_options() { return Context_Weglot::weglot_get_context()->get_service( 'Option_Service_Weglot' )->get_options(); } /** * Get option * @param string $key * @return mixed * @throws Exception * @since 2.0 */ function weglot_get_option( $key ) { return Context_Weglot::weglot_get_context()->get_service( 'Option_Service_Weglot' )->get_option( $key ); } /** * Get original language * @return string * @throws Exception * @since 2.0 */ function weglot_get_original_language() { return weglot_get_option( 'original_language' ); } /** * Get current language * @return string * @throws Exception * @since 2.0 */ function weglot_get_current_language() { return Context_Weglot::weglot_get_context()->get_service( 'Request_Url_Service_Weglot' )->get_current_language()->getInternalCode(); } /** * Get current language * @return string * @throws Exception * @since 2.0 */ function weglot_get_current_language_custom() { return Context_Weglot::weglot_get_context()->get_service( 'Request_Url_Service_Weglot' )->get_current_language()->getExternalCode(); } /** * Get current language code from custom language * @return string * @throws Exception * @since 2.0 */ function weglot_get_current_language_code_from_custom_language() { return Context_Weglot::weglot_get_context()->get_service( 'Request_Url_Service_Weglot' )->get_current_language()->getExternalCode(); } /** * Get destination language with filters * @return string * @throws Exception * @since 2.0 */ function weglot_get_destination_languages() { return Context_Weglot::weglot_get_context()->get_service( 'Option_Service_Weglot' )->get_destination_languages(); } /** * Get Request Url Service * @since 2.0 * @return Request_Url_Service_Weglot */ function weglot_get_request_url_service() { return Context_Weglot::weglot_get_context()->get_service( 'Request_Url_Service_Weglot' ); } /** * Get languages available on Weglot * @return LanguageCollection * @throws Exception * @since 2.0 */ function weglot_get_languages_available() { return Context_Weglot::weglot_get_context()->get_service( 'Language_Service_Weglot' )->get_languages_available(); } /** * Get button selector HTML * @since 2.0 * @param string $add_class * @return string */ function weglot_get_button_selector_html( $add_class = '' ) { return Context_Weglot::weglot_get_context()->get_service( 'Button_Service_Weglot' )->get_html( $add_class ); } /** * Get exclude urls * @since 2.0 * @return array */ function weglot_get_exclude_urls() { return Context_Weglot::weglot_get_context()->get_service( 'Option_Service_Weglot' )->get_exclude_urls(); } /** * Get translate AMP option * @since 2.0 * @return bool */ function weglot_get_translate_amp_translation() { return Context_Weglot::weglot_get_context()->get_service( 'Option_Service_Weglot' )->get_option_custom_settings( 'translate_amp' ); } /** * Get current full url * @since 2.0 * @return string */ function weglot_get_current_full_url() { return weglot_create_url_object( weglot_get_request_url_service()->get_full_url() )->getForLanguage( weglot_get_request_url_service()->get_current_language() ); } /** * Is eligible url * @since 2.0 * @param string $url * @return boolean */ function weglot_is_eligible_url( $url ) { return Context_Weglot::weglot_get_context()->get_service( 'Request_Url_Service_Weglot' )->is_eligible_url( $url ); } /** * Get API KEY Weglot * @since 2.0 * @version 3.0.0 * @return string */ function weglot_get_api_key() { return weglot_get_option( 'api_key_private' ); } /** * Get auto redirect option * @since 2.0 * @return boolean */ function weglot_has_auto_redirect() { return weglot_get_option( 'auto_redirect' ); } /** * @since 2.0.4 * @param string $url * @return Weglot\Util\Url */ function weglot_create_url_object( $url ) { return weglot_get_request_url_service()->create_url_object( $url ); } function weglot_get_full_url_no_language() { return weglot_create_url_object( weglot_get_request_url_service()->get_full_url() )->getForLanguage( weglot_get_service('Language_Service_Weglot')->get_original_language() ); } function weglot_get_postid_from_url() { return url_to_postid( weglot_get_full_url_no_language() ); //phpcs:ignore } /** * @since 2.4.0 * @return string */ function weglot_get_rest_current_url_path() { $prefix = rest_get_url_prefix(); $current_url = wp_parse_url( add_query_arg( array() ) ); return apply_filters( 'weglot_get_rest_current_url_path', $current_url['path'] ); } changelog.md 0000644 00000047200 15134111570 0007016 0 ustar 00 <!-- logo --> <img src="https://cdn.weglot.com/logo/logo-hor.png" height="40" /> # Change Log ## 4.0.2 (30/05/2023) = * Update: Change PHP_INT_MAX to 200 in class-pages-weglot.php * Bug: Add esc_url to $_SERVER['REQUEST_URI'] on class-translate-paghe-weglot.com * Bug: Aria-expanded label remains true when it should say false on switcher ## 4.0.1 (02/05/2023) = * Bug: Fix call to undefined revert_callback value on class RegexCheckerProvider * Update: Update message about translated url option (available with Pro plan and more) ## 4.0 (25/04/2023) = * Add: Add switcher gallery implementation * Add: Add PHP 8 compatibility fix deprecated (PHPStan) * Add: Add external_enabled to translate external links * Add: Add language subdirectory to the rel=”prev” and rel=”next” links on WordPress * Add: Add filter to manage hreflang * Add: Manage media_enabled and external_enabled options * Add: Add compatibility with wp rentals plugin and theme * Add: Add mPDF Engine for translate pdf (WP Overnight) * Add: Don't translate link when the target is excluded * Update: Improve filter active translation * Update: Hide Language Switcher when all language pairs are set to private * Bug: Fix call to .json call to prevent create empty settings * Bug: Fix empty slug issue : prevent (do not save empty slug on transient) * Bug: Fix issue with Klaviyo plugin * Bug: Don't hide custom css block when custom switcher is added * Bug: getInternalCode() is called on an element that is ‘null’ * Bug: Duplicate ID when multiple language switchers are present on the same page * Fix: PHP Notice on third party cache enabler * Fix: PHP Notice Undefined array key “SERVER_PROTOCOL” when running Cron * Fix: Fix accessibility issue on the switcher * Fix: Fix issue from wp vip go standard * Fix: PHP Notice Undefined property: stdClass::$post_name ##3.9.2 (30/01/2023) = * Bug: hotfix js file ##3.9.1 (30/01/2023) = * Bug: add english in destination language list during installation if original language is different * Update: Prevent using empty .json settings file during install ##3.9 (17/01/2023) = * Update: Add whitelist mode * Update: Add notices messages if other translate plugin is active * Update: Add index text for translate ldjson * Update: Translate pdf from Germanized pdf plugins * Bug: Fix cookie issue with WP Rocket (mandatory cookies) * Bug: Check if index query exist before use it * Update: Fix wp vip code issue (wp parse url instead of native parse_url) * Update: Check WPLANG on first install instead of put 'en' by default * Bug: Add filter to prevent issue with Gform upload input ajax * Bug: Fix issue with FluentCRM, WP social Ninja and Fluent Support ##3.8.3 (15/11/2022) = * Bug: Prevent Ajax call from original lang to original lang * Bug: Fix PHP Warning on class-replace-url-service line 192 * Update: Add index 'text' to ld+json translated value ##3.8.2 (08/11/2022) = * Bug: Update cdn url for pageviews replace cdn-api-weglot.com by cdn-api.weglot.com ##3.8.1 (18/10/2022) = * Bug: Default is_rtl value for custom_languages * Bug: Update render button for gutenberg editor * Bug: Improve UI for adding excluded block * Add: Update assets for wordpress.org ##3.8 (11/10/2022) = * Add: Add ajax checker for woocommerce variations cart popin * Add: Rework switcher. Generate it direclty on render method * Add: Add vary header accept language on redirect * Bug: Fix rtl issue * Bug: Add missing ; on pageviews script * Bug: Send code lang instead of name for wp search query * Bug: Don't translate pdf on original language (woocommerce PDF invoice plugin) * Bug: Prevent add twice weglot_language post meta on woocommerce order * Bug: Prevent block translate if ajax referer are not exclude ##3.7.4 (19/09/2022) = * Bugfix: Update CA Root Certificates from Mozilla ##3.7.3 (05/07/2022) = * Bugfix: Remove mod_rewrite check with apache_get_module() * Bugfix: Fix problem with empty switcher from switcher editor * Bugfix: Compatibility with gravitform upload input ##3.7.2 (20/06/2022) = * Bugfix: Fix bug between apache_get_module() and wpengine.com * Add: Add changelog file into plugin directory ##3.7.1 (15/06/2022) = * Add: Disable translate pdf and add filter to activate ite ##3.7 (08/06/2022) * Add: Translate pdf service * Add: Optimize button accessibility * Add: Pageviews integration * Add: Add switcher editor integration * Add: Woocommerce translate all mail * Add: Do not translate .eps or .txt * Add: Detect if switcher is child of an iframe and if so, don't display it * Add: Reduce api call on wp-admin ##3.6.1 (02/03/2022) * Bugfix: Fix hide button option on switcher menu * Bugfix: Fix bug VE not translated * Bugfix: Fix bug add Custom full name for orginal language ##3.6 (23/02/2022) * Add: Advance exclude url option * Add: Add blocks for gutenberg (wp 5.9) * Add: Disable autoswitch for weglot visual editor * Add: Add Forminator (plugin de WPMUDEV) compatibility * Add: Disable weglot on rankmath sitemap * Add: Add hook filter to replace_url method * Bugfix: php8 parameters order * Bugfix: Refresh destination language list * Bugfix: Display hreflang even url have parameters ##3.5 (07/12/2021) * Add: Autoswitch work on all page not only on homepage * Add: Exclude url doesn't generate redirection * Add: Add switcher from switcher editor * Add: Call API from cdn to translate * Add: Limited call API for deactivate account * Bugfix: Problem with gform and multisite * Bugfix: Fix hreflang generation with Cyrillic url * Bugfix: Weglot search option now works even if we're not on a main_query ##3.4 (15/09/2021) * Add: All 404 pages are excluded from translation if you exclude /404 in the Weglot dashboard * Improved performance: Files for multilingual compatibility with other plugins are only called when necessary * Bugfix: Autoswitch feature now works with custom languages * Bugfix: Password reset link in translated emails now works * Bugfix: WooCommerce emails are now translated when using custom languages * Bugfix: Fixed warning in 404 styles.css.map * Bugfix: Autoswitch doesn't redirect when visitor comes from an external link from now on ##3.3.6 (15/06/2021) * Add new flag from dashboard * Improve hreflang display * Dynamise limit languages check * Fix bug when excluded URL /cart gives empty URL * Fix small bug on multisite where we translated links from / website when located on /subsite * Better handle 301 redirect ##3.3.5 (12/04/2021) * Add url from canonical if existing * Add vip code review * Increase timeout when updating setting and disable submit button * Adding message to tell user to purge cache from cache plugin after editing translation ##3.3.4 (22/03/2021) * Check if curl_exec is enable * Fix js problem on admin on preview * Optimize plugin size * Change screenshot on store ##3.3.3 (08/03/2021) * Language repo * drag and drop * bug greek url * bug parsing empty node ##3.3.2 (15/02/2021) * Update settings dropdown * Fix rare bug when root equal slug page ##3.3.1 (01/02/2021) * Small fixes following major release ##3.3.0 (18/01/2021) * Full refacto of the code * Add: custom language ##3.2.0 (15/10/2020) * Add translate slug option * Fix: auto redirect on traditional chinese and brazilian portuguese * Fix: admin-ajax bug containing language code in some case ##3.1.9 (06/08/2020) * Add flag choice for ZH and TW * Update plugin translation files * Translate Iframe SRC as external link * Fix: Custom URL links (empty base in correspondence table / trailing slash) * Fix: Remove "!important" CSS properties on AMP ##3.1.8 (02/07/2020) * Exclude URL by languages * Translate by default all Woocommerce mails with customer language * Update URLs translation, possibility to use custom URLs for hierarchical pages * Translate External URLs * Add SVG files to media translation * Exclude wp-cron.php from translation * Fix links translation with custom URLS ##3.1.7 (04/05/2020) * Add a Weglot Menu to admin bar * Add Woocommerce feature : Translate following mail * Better text escaping in Back Office (thanks to @joehoyle and @drvy for contribution) * Add attribute to HTML tag if custom code is used for current language * Optimize CSS size for AMP * Fix: Add compatibility with AMP plugin +1.5 * Fix: No load Weglot CSS in AMP if option is set to false * Fix error on JS script loading (thanks to @joehoyle for contribution) ##3.1.6 (06/02/2020) * Add: Use WP core code editor for Weglot custom CSS * Add: Add weglot_translate_email filter to control when mail are translated * Bugfix: Fixes small minor bugs ##3.1.5 (08/01/2020) * Add: weglot_language_code_replace filter to use custom language code * Bugfix: Formatter on JSON source for untranslated WooComerce fields ##3.1.4 (12/12/2019) * Update back office style for WordPress 5.3 * Fix: Flags SRC attribute with AMP * Fix: Custom URL feature - Revisions * Improve compatibility: WP Optimize * Improve compatibility: Cache Enabler * Add default exclude block for SecuPress plugin and SQLI protect * Add default exclude block for plugin query monitor > 3.3.0 * Remove the "Not allowed" mechanism. ##3.1.3 (29/10/2019) * Improve compatibility: Woocommerce with IE 11 * Improve compatibility: Contact Form 7 * Improve compatibility: MailOptin * Improve compatibility: The Event Calendar * Improve compatibility: Font Awesome * Add default exclude block: address * Bugfix: Do not cache page if API answers error ##3.1.2 (24/09/2019) * Bugfix: Custom URL with GET parameters * Bugfix: Ninja Forms JSON translate * Bugfix: Prevent errors due to call protected method ##3.1.1 (11/09/2019) * Add: IE 11 compatibility with languages switcher * Add: WP-CLI compatibility * Bugfix: admin api call * Bugfix: double language when WC + multisite with subdomains * Bugfix: do not add language on external links also in JSON ##3.1.0 (29/08/2019) * Add: Better JSON compatiblity * Bugfix: WC password reset mechanism ##3.0.6 (28/05/2019) * Add: Compatibility with WP Forms * Add: Reset postdata filter for custom URLs * Bugfix: Auto switch fallback * Bugfix: Custom url on is_front_page ##3.0.5 (22/05/2019) * Bugfix: Prevent array key exists for Gravity Form * Bugfix: Save menu Weglot Switcher * Bugfix: Check DOM on json-ld and inactive by default ##3.0.4 (10/05/2019) * Bugfix: Prevent errors due to the parser of the JSON-LD ##3.0.3 (09/05/2019) * Bugfix: Weglot switcher on menu * Add : Translate all JSON-LD ##3.0.2 (24/04/2019) * Bugfix: Fixed saving custom CSS * Bugfix: Auto detection of a bot (google, bing,...) * Bugfix: Compatibility with caldera forms ##3.0.1 (17/04/2019) * Bugfix: API key check only if it does not exist * Bugfix: prevent array_key_exists on private languages for older installations ##3.0.0 (16/04/2019) * New major version * Link between WordPress options and Weglot dashboard options * Bugfix: Fixed an error on the JSON translation ##2.7.0 (18/03/2019) * Changed : Improve Compatibility with Caldera Forms ##2.6.0 (06/03/2019) * Add : Prevent elementor ajax action on 2.5 * Add : Compatibility with Caldera Forms * Add : Prevent ajax MMP Map * Changed: Improved AJAX translation performance * Bugfix: No translate link on weglot menu item * Bugfix: meta og facebook * Bugfix: prevent undefined index on widget ##2.5.0 (07/02/2019) * Add : Compatibility with Ninja Forms * Add : DOM Checker on input type reset * Bugfix : have the same menu switcher on the same page several times * Bugfix : Remove no redirect on hreflang * Improve DOM Checker meta content image ##2.4.1 (09/01/2019) * Bugfix: undefined function if there is no antislash before the function ( \is_rest ) ##2.4.0 (09/01/2019) * Compatibility PHP 7.3 * Changed : the language selector for menus * Add : Compatibility with the REST API of Contact Form 7 * Add [BETA] : Be able to translate the keywords of a search * Bugfix : translation of the empty cart on WooCommerce * Bugfix: correction of options on a multisite ##2.3.1 (05/12/2018) * Bugfix : Button preview fail on migration for private mode ##2.3.0 (05/12/2018) * Bugfix : Custom URL on archive page * Bugfix : Prevent error on translate AJAX * Bugfix : Href lang on custom URLs * Improve code quality * Compatibility SEOPress : exclude sitemap * Improve private languages * Add two DOM checkers ##2.2.2 (05/11/2018) * Fix bug on change country flag * Change load custom css inline ##2.2.1 (01/11/2018) * Fix bug when language was not passed on navigation ##2.2.0 (31/10/2018) * Added private mode for administrators * Addition apply_filters * Bugfix : an ajax request * Improved compatibility with wpestate * Compatibility with mega max menu ##2.1.0 (25/09/2018) * New feature: Custom URL * Bugfix : Translate AJAX with return JSON on error * Bugfix : Backslash on function PHP * Bugfix : Replace links href on JSON translate * Bugfix : Compatibility with theme use ob_start ##2.0.7 (31/08/2018) * Bugfix: Ajax load media library * Improve choice original and destination language ##2.0.6 (29/08/2018) * Add DOM checker to translate button value and data-value attribute * Update Weglot Translate setting page * Bugfix : email translation * Bugfix : external link with quickpay * Prevent auto redirect on homepage translate ##2.0.5 (09/08/2018) * Bugfix : Fatal error if use weglot menu custom ##2.0.4 (09/08/2018) * Bugfix : lost password email on WooCommerce * Bugfix : translate custom login page * Bugfix : uniq id on each button selector * Bugfix : no translate image on a href html tag with wp-content/uploads src * Bugfix : admin-ajax url ##2.0.3 (27/07/2018) * Bugfix : Hide shortcode on non translatable URL * Bugfix : filter nav_menu_css_class * Bugfix : Redirect URL on checkout WooCommerce * Bugfix : CSS Flag on dropdown menu * Improve AMP compatibility ##2.0.2 (24/07/2018) * Bugfix : Hide menu on non translatable URL * Bugfix : Hide widget on non translatable URL * Improve max file size HTML ##2.0.1 (19/07/2018) * Improve flag style * Prevent cURL function * Solved nav_class warning ##2.0 (18/07/2018) * Major changes on the plugin architecture * Adding developer functions & filters * Refactoring ##1.13.1 (01/06/2018) * Bugfix: Error on the encoding of ignored nodes ##1.13 (31/05/2018) * Bugfix : Improve filter words_translate to prevent matching part of words * BugFix : Bug in parser when ignored node had an attribute * BugFix : character limit on chinese paragraphs * Add : Update message for version 2.0 ##1.12.2 (04/05/2018) * Bugfix : Limitation on the number of characters translated at the same time ##1.12.1 (03/05/2018) * Bugfix : error for users with a version lower than PHP 5.4 . []> array() ##1.12 (03/05/2018) * Bugfix : undefined index on ajax call * Bugfix : Redirection checkout payment on WooCommerce * Bugfix : Register widget * Add option for AMP compatibility * Add filter for dynamic string ##1.11 (05/04/2018) * Add new languages * Add new filters * Add Yoast Premium compatibility on redirect * Bugfix : Exclusion AMP * Bugfix : Redirection checkout order on WooCommerce ##1.10 * Add new languages + add Oman flag * Can potentially translate email sent from admin * Add tags to inline elements to ignore when parsing ##1.9.3 * Remove Freemius ##1.9.2 * Fix Freemius assets ##1.9.1 * Fix Freemius error when changing base dir * Fix wc translations when special characters. ##1.9 * Fix login redirection * Add translation for Town, cities and other dynamic fields in WC checkout * exclude URL now accepts full URL and any blank separator ##1.8.2 * Fix pb when permalinks has no ending slash * Add notif when plugin is not congigured ##1.8.1 * Fix redirection on woocommerce ##1.8 * Add new banner and icon * improve wc redirection * can now translate email ##1.7.1 * Fix redirection bug on cart ##1.7 * Add 6 languages * Translate microdata * New element translated ##1.6.1 * Fix url when non standard characters * change freemius image ##1.6 * Add Freemius * Refactor code * Replace api ur * Add several attributes to translations ##1.5 * Add data-value, data-title, title attribute support * Add links in readme ##1.4.6 * Add pretty selection of languages * Improve flags quality ##1.4.5 * Add more i18n luv. Now we speak WordPress * Add Dutch, English_UK, German, Italian, Portuguese_BR, Russian and Spanish languages ##1.4.4 * Update i18n and improve strings ##1.4.3 * Compat with WP Fastest cache, improve RTL translations ##1.4.2 * PHP 7 compat, add auto redirect feature, no more FA, no more id on switcher ##1.4.1 * compat AMP, fix url bug on same language code than URL. ##1.4.0 * compat precaching, URLs ##1.3.3 * increase compatibility with other plugins and themes. ##1.3.2 * change support email * exclude /amp, admin bar * language on starter plan ##1.3.1 * Fix invalid links * Handles multiple weglot_here ##1.3.0 * rollbackink parsing lib * fix srcset, dslash link ##1.2.8 * parsing lib changed * fix several small bugs ##1.2.7 * Adding Traditional Chinese * Fix og:url * scrybs ##1.2.6 * Fix jpeg translated version * Fix moreclass and wg-notranslate on list button in menu * Fix ajax json with html in it ##1.2.5 * Add other flags for english, spanish & portugese translations * Review style for translation button in menu * Add translation exclusion blocks by CSS selectors ##1.2.4 * Adding Hindi & Urdu translation languages. * Adding version number on scripts. ##1.2.3 * Code review and optimization ##1.2.2 * WP Compliance ##1.2.1 * Fix style on dropdown list * Fix link containing "admin" word ##1.2 * New choice of flags made by professional designers for your translation switch button. Rectangle mat, rectangle bright, square and circle. Enjoy! * Add a "Settings" link under Weglot Translate in pugin list. ##1.1 * Add naviguation menu hook to let user display button in menu. * Add possibility to show only flags * Show warnings if PHP version is under 5.2 or rewrite rules not activated * Rename simple html dom constant and handle no php-mbstring case * Fix front page show box when home dir ##1.0 * Change portugese flag to brazilian, change limit message, starting 1.0 versioning as we reach viable product. ##Older versions ##0.1 * First version ##0.2 * Fix label and languages parameters ##0.3 * SEO now completly taken into account. ##0.4 * small fix on links ##0.5 * Fix rules + add url ##0.6 * Fix rules + new button design ##0.7 * Add meta translation, + regex eclusion ##0.8 * Add input button, fix small bug on link ##0.9 * Check rewrite rules are always here ##0.10 * Quick fix for PHP 5.3 ##0.11 * Fix ajax, FB compat ##0.12 * Handle WP_HOME ##0.13 * General review ##0.14 * Prepare for localization ##0.15 * Change link to weglot ##0.16 * Place button by default ##0.17 * Fix vc_ ##0.18 * Fix cdata ##0.19 * Http api integration ##0.20 * Fix PHP 5.2 compat with anonymous function ##0.21 * Change ob order for compatibility ##0.22 * More flexibility in destination language ##0.23 * Can have multiple youtube video for different languages ##0.24 * Fix some links that had multiple lang tag ##0.25 * Fix CSS style + subdirectory WP ##0.26 * Now support images ##0.27 * Adding 40+ languages + fix homepage bug ##0.28 * Change button to customizable widget, also fix bug https+wp_home ##0.29 * Fix is_html, add US flag possibility, fix link beginning with coutry code. ##0.30 * Fix style, add on-boarding to help users, add link to dashboard translations. ##0.31 * Adding ajax support for full html, fix style, fix link with wp_home ##0.32 * Quick fix on links ##0.33 * Add ajax for json-html ##0.34 * Adding chat support to help user set up the plugin ##0.35 * Rework classes + add search support (form tag) ##0.36 * Remove trial period, replace by free plan ##0.37 * More info on errors, translation limit from api ##0.38 * Fix canonical transated link, support RTL & LTR customization, WG logo to meet Wp standard, translate alt attribute, add possibility to drop button anywhere ##0.39 * Fix LTR CSS, api v2 transmit strings type, fix regex escaping ##0.40 * Add PDF translate, fix simple dom limit, uninstall hook, no </body> case. weglot.php 0000644 00000021347 15134111570 0006563 0 ustar 00 <?php /* Plugin Name: Weglot Translate Plugin URI: http://wordpress.org/plugins/weglot/ Description: Translate your website into multiple languages in minutes without doing any coding. Fully SEO compatible. Author: Weglot Translate team Author URI: https://weglot.com/ Text Domain: weglot Domain Path: /languages/ Version: 4.1 */ /** * This file need to be compatible with PHP 5.3 * Example : Don't use short syntax for array() */ if ( ! defined( 'ABSPATH' ) ) { exit; } define( 'WEGLOT_NAME', 'Weglot' ); define( 'WEGLOT_SLUG', 'weglot-translate' ); define( 'WEGLOT_OPTION_GROUP', 'group-weglot-translate' ); define( 'WEGLOT_VERSION', '4.1' ); define( 'WEGLOT_PHP_MIN', '5.6' ); define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) ); define( 'WEGLOT_DIR', __DIR__ ); define( 'WEGLOT_DIR_LANGUAGES', WEGLOT_DIR . '/languages' ); define( 'WEGLOT_DIR_DIST', WEGLOT_DIR . '/dist' ); define( 'WEGLOT_DIRURL', plugin_dir_url( __FILE__ ) ); define( 'WEGLOT_URL_DIST', WEGLOT_DIRURL . 'dist' ); define( 'WEGLOT_LATEST_VERSION', '2.7.0' ); define( 'WEGLOT_DEBUG', false ); define( 'WEGLOT_DEV', false ); define( 'WEGLOT_TEMPLATES', WEGLOT_DIR . '/templates' ); define( 'WEGLOT_TEMPLATES_ADMIN', WEGLOT_TEMPLATES . '/admin' ); define( 'WEGLOT_TEMPLATES_ADMIN_NOTICES', WEGLOT_TEMPLATES_ADMIN . '/notices' ); define( 'WEGLOT_TEMPLATES_ADMIN_PAGES', WEGLOT_TEMPLATES_ADMIN . '/pages' ); if ( ! function_exists( 'is_plugin_active' ) ) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } // Compatibility Yoast premium Redirection $dir_yoast_premium = plugin_dir_path( __DIR__ ) . 'wordpress-seo-premium'; if ( file_exists( $dir_yoast_premium . '/wp-seo-premium.php' ) ) { if ( ! weglot_is_compatible() ) { return; } $yoast_plugin_data = get_plugin_data( $dir_yoast_premium . '/wp-seo-premium.php' ); $dir_yoast_premium_inside = $dir_yoast_premium . '/premium/'; // Override yoast redirect if ( ! is_admin() && version_compare( $yoast_plugin_data['Version'], '7.1.0', '>=' ) && is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) && file_exists( $dir_yoast_premium_inside ) && file_exists( $dir_yoast_premium_inside . 'classes/redirect/redirect-handler.php' ) && file_exists( $dir_yoast_premium_inside . 'classes/redirect/redirect-util.php' ) ) { require_once __DIR__ . '/weglot-autoload.php'; require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/bootstrap.php'; require_once __DIR__ . '/weglot-functions.php'; include_once __DIR__ . '/src/third/yoast/redirect-premium.php'; } } gtranslate_is_active(); polylang_is_active(); translatepress_is_active(); wpml_is_active(); /** * Check compatibility this Weglot with WordPress config. */ function weglot_is_compatible() { // Check php version. if ( version_compare( PHP_VERSION, WEGLOT_PHP_MIN ) < 0 ) { add_action( 'admin_notices', 'weglot_php_min_compatibility' ); return false; } return true; } /** * Check if GTranslate is active. */ function gtranslate_is_active() { // Check gtranslate is active. if ( is_plugin_active( 'gtranslate/gtranslate.php' ) ) { remove_action( 'admin_notices', 'gt_admin_notices'); add_action( 'admin_notices', 'weglot_gtranslate_activate', PHP_INT_MAX ); } } /** * Check if Polylang is active. */ function polylang_is_active() { // Check polylang is active. if ( is_plugin_active( 'polylang/polylang.php' ) ) { add_action( 'admin_notices', 'weglot_polylang_activate' ); } } /** * Check if TranslatePress is active. */ function translatepress_is_active() { // Check TranslatePress is active. if ( is_plugin_active( 'translatepress-multilingual/index.php' ) ) { add_action( 'admin_notices', 'weglot_translatepress_activate' ); } } /** * Check if TranslatePress is active. */ function wpml_is_active() { // Check WPML is active. if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { add_action( 'admin_notices', 'weglot_wpml_activate' ); } } /** * Admin notices if GTranslate is install and activate * * @return void */ function weglot_gtranslate_activate() { if ( ! file_exists( WEGLOT_TEMPLATES_ADMIN_NOTICES . '/gtranslate-activate.php' ) ) { return; } include_once WEGLOT_TEMPLATES_ADMIN_NOTICES . '/gtranslate-activate.php'; } /** * Admin notices if Polylang is install and activate * * @return void */ function weglot_polylang_activate() { if ( ! file_exists( WEGLOT_TEMPLATES_ADMIN_NOTICES . '/polylang-activate.php' ) ) { return; } include_once WEGLOT_TEMPLATES_ADMIN_NOTICES . '/polylang-activate.php'; } /** Admin notices if TranslatePress is install and activate * * @return void */ function weglot_translatepress_activate() { if ( ! file_exists( WEGLOT_TEMPLATES_ADMIN_NOTICES . '/translatepress-activate.php' ) ) { return; } include_once WEGLOT_TEMPLATES_ADMIN_NOTICES . '/translatepress-activate.php'; } /** Admin notices if WPML is install and activate * * @return void */ function weglot_wpml_activate() { if ( ! file_exists( WEGLOT_TEMPLATES_ADMIN_NOTICES . '/wpml-activate.php' ) ) { return; } include_once WEGLOT_TEMPLATES_ADMIN_NOTICES . '/wpml-activate.php'; } /** * Admin notices if weglot not compatible * * @return void */ function weglot_php_min_compatibility() { if ( ! file_exists( WEGLOT_TEMPLATES_ADMIN_NOTICES . '/php-min.php' ) ) { return; } include_once WEGLOT_TEMPLATES_ADMIN_NOTICES . '/php-min.php'; } /** * Activate Weglot. * * @since 2.0 */ function weglot_plugin_activate() { if ( ! weglot_is_compatible() ) { return; } require_once __DIR__ . '/weglot-autoload.php'; require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/weglot-compatibility.php'; require_once __DIR__ . '/weglot-functions.php'; require_once __DIR__ . '/bootstrap.php'; Context_Weglot::weglot_get_context()->activate_plugin(); $dir_wp_rocket = plugin_dir_path( __DIR__ ) . 'wp-rocket'; if ( file_exists( $dir_wp_rocket . '/wp-rocket.php' ) ) { if( weglot_get_service( 'Wprocket_Active' )->is_active()) { add_filter( 'rocket_htaccess_mod_rewrite', '__return_false' ); add_filter( 'rocket_cache_mandatory_cookies', 'weglot_mandatory_cookie' ); flush_wp_rocket(); } } } /** * Deactivate Weglot. * * @since 2.0 */ function weglot_plugin_deactivate() { require_once __DIR__ . '/weglot-autoload.php'; require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/weglot-compatibility.php'; require_once __DIR__ . '/weglot-functions.php'; require_once __DIR__ . '/bootstrap.php'; Context_Weglot::weglot_get_context()->deactivate_plugin(); $dir_wp_rocket = plugin_dir_path( __DIR__ ) . 'wp-rocket'; if ( file_exists( $dir_wp_rocket . '/wp-rocket.php' ) ) { if( weglot_get_service( 'Wprocket_Active' )->is_active()) { remove_filter( 'rocket_htaccess_mod_rewrite', '__return_true' ); remove_filter( 'rocket_cache_mandatory_cookies', 'weglot_mandatory_cookie' ); flush_wp_rocket(); } } } /** * Uninstall Weglot. * * @since 2.0 */ function weglot_plugin_uninstall() { delete_option( WEGLOT_SLUG ); } /** * Rollback v2 => v1 * * @return void */ function weglot_rollback() { if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( esc_url_raw( $_GET['_wpnonce'] ), 'weglot_rollback' ) ) { wp_nonce_ays( '' ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $plugin = 'weglot'; $title = sprintf( __( '%s Update Rollback', 'weglot' ), WEGLOT_NAME ); $nonce = 'upgrade-plugin_' . $plugin; $url = 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $plugin ); $version = WEGLOT_LATEST_VERSION; $upgrader_skin = new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin', 'version' ) ); $rollback = new \WeglotWP\Helpers\Helper_Rollback_Weglot( $upgrader_skin ); $rollback->rollback( $version ); } /** * Load Weglot. * * @since 2.0 */ function weglot_plugin_loaded() { require_once __DIR__ . '/weglot-autoload.php'; require_once __DIR__ . '/weglot-compatibility.php'; add_action( 'admin_post_weglot_rollback', 'weglot_rollback' ); if ( weglot_is_compatible() ) { require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/bootstrap.php'; require_once __DIR__ . '/weglot-functions.php'; weglot_init(); } } register_activation_hook( __FILE__, 'weglot_plugin_activate' ); register_deactivation_hook( __FILE__, 'weglot_plugin_deactivate' ); register_uninstall_hook( __FILE__, 'weglot_plugin_uninstall' ); // Change priority to 7 if amp present $priority = 10; $dir_amp = plugin_dir_path( __DIR__ ) . 'amp'; if ( file_exists( $dir_amp . '/amp.php' ) ) { $priority = 7; } add_action( 'plugins_loaded', 'weglot_plugin_loaded' , $priority); // Add registration hooks if WP Rocket present $dir_wp_rocket = plugin_dir_path( __DIR__ ) . 'wp-rocket'; if ( file_exists( $dir_wp_rocket . '/wp-rocket.php' ) ) { include_once __DIR__ . '/src/third/wprocket/wp-rocket-weglot.php'; } templates/admin/pages/settings.php 0000644 00000007210 15134111570 0013300 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { exit; } use WeglotWP\Helpers\Helper_Tabs_Admin_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">Main configuration</a></li> <li><a href="#language_button_position">Language button position</a></li> <li><a href="#translation_exclusion">Translation Exclusion</a></li> <li><a href="#other_options">Other options</a></li> </ul> </div> </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( 'https://dashboard.weglot.com/translations/', 'weglot' ); ?>" 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; case Helper_Tabs_Admin_Weglot::CUSTOM_URLS: include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/custom-urls.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> <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> templates/admin/pages/tabs/custom-urls.php 0000644 00000007763 15134111570 0014703 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { exit; } use Weglot\WeglotContext; ?> <h2><?php esc_html_e( 'Custom URLs', 'weglot' ); ?></h2> <hr> <?php if ( ! empty( $_GET['reset-all-custom-urls'] ) && 'true' === $_GET['reset-all-custom-urls'] ) { // phpcs:ignore // Reset all customs URLs $option_service_weglot = weglot_get_service( 'Option_Service_Weglot' ); $option_service_weglot->set_option_by_key( 'custom_urls', array() ); $options = array(); ?> <div class="updated notice"> <p><?php esc_html_e( 'All customs URLs was reseted.', 'weglot' ); ?></p> </div> <?php } else { $options = weglot_get_options(); } ?> <div class="wrap"> <?php if ( ! empty( $options['custom_urls'] ) ) : foreach ( $options['custom_urls'] as $lang => $weglot_urls ) : ?> <h3><?php esc_html_e( 'Lang : ', 'weglot' ); ?><?php echo esc_html( $lang ); ?></h3> <div style="display:flex;"> <div style="flex:5; margin-right:10px;"> <?php esc_html_e( 'Base URL :', 'weglot' ); ?> </div> <div style="flex:5;"> <?php esc_html_e( 'Custom URL :', 'weglot' ); ?> </div> <div style="flex:1;"></div> </div> <?php if ( ! empty( $weglot_urls ) ) : foreach ( $weglot_urls as $key => $value ) : $key_generate = sprintf( '%s-%s-%s', $lang, $key, $value ); ?> <div style="display:flex;" id="<?php echo esc_attr( $key_generate ); ?>"> <div style="margin-right:10px; flex:5;"> <input style="max-width:100%;" type="text" value="<?php echo esc_attr( $value ); ?>" class="base-url base-url-<?php echo esc_attr( $key_generate ); ?>" data-key="<?php echo esc_attr( $key_generate ); ?>" name="<?php echo esc_attr( sprintf( '%s[%s][%s][%s]', WEGLOT_SLUG, 'custom_urls', $lang, $key ) ); ?>" data-lang="<?php echo esc_attr( $lang ); ?>" /> </div> <div style="flex:5;"> <input style="max-width:100%;" type="text" value="<?php echo esc_attr( $key ); ?>" data-key="<?php echo esc_attr( $key_generate ); ?>" class="custom-url custom-<?php echo esc_attr( $key_generate ); ?>" data-lang="<?php echo esc_attr( $lang ); ?>" /> </div> <div style="align-self:flex-end; flex:1; text-align: center; height: 32px;"> <button class="js-btn-remove" data-key="<?php echo esc_attr( $key_generate ); ?>"> <span class="dashicons dashicons-minus"></span> </button> </div> </div> <?php endforeach; endif; ?> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', function(){ const $ = jQuery $('.custom-url').on('keyup', function(e){ const key = $(this).data('key') const lang = $(this).data('lang') $('.base-url-' + key).attr('name', 'weglot-translate[custom_urls][' + lang + '][' + e.target.value + ']') }) $('.js-btn-remove').on('click', function(e){ e.preventDefault(); $('#' + $(this).data('key')).remove() }) }) </script> <?php endforeach; $url_reset_all_custom_urls = add_query_arg( array( 'page' => 'weglot-settings', 'tab' => 'custom-urls', 'reset-all-custom-urls' => 'true', ), admin_url() . 'admin.php' ); ?> <br /> <hr /> <p><span class="dashicons dashicons-trash"></span> <a href="<?php echo esc_url( $url_reset_all_custom_urls ); ?>" class="reset-all-custom-urls" style="color: #dc3232;"><?php esc_html_e( 'Reset all Weglot custom URLs', 'weglot' ); ?></a></p> <hr /> <?php elseif ( empty( $_GET['reset-all-custom-urls'] ) ) : // phpcs:ignore ?> <div class="error notice"> <p><?php esc_html_e( 'No custom URL found.', 'weglot' ); ?></p> </div> <?php endif; ?> </div> <script type="text/javascript"> jQuery(document).ready(function ($) { history.replaceState(null, null, 'admin.php?page=weglot-settings&tab=custom-urls'); $(document).on("click", ".reset-all-custom-urls", function(e) { e.preventDefault(); if (confirm( "<?php esc_html_e( 'Are you sure to reset all custom URLs?', 'weglot' ); ?>")) { window.location.href = $(this).attr("href"); } }); }); </script> templates/admin/pages/tabs/support.php 0000644 00000002446 15134111570 0014113 0 ustar 00 <?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> templates/admin/pages/tabs/advanced.php 0000644 00000020120 15134111570 0014131 0 ustar 00 <?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="https://dashboard.weglot.com/settings/exclusions#excluded-urls" 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="https://dashboard.weglot.com/settings/exclusions#excluded-blocks" 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> </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="https://dashboard.weglot.com/statistics/page-views/" title="Page views tracking is activated">Page views tracking</a> is <b>activated</b></p> <?php else : ?> <p class="description"><a target="_blank" href="https://dashboard.weglot.com/statistics/page-views/" 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> templates/admin/pages/tabs/appearance.php 0000644 00000042664 15134111570 0014504 0 ustar 00 <?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 <div id="weglot_here"></div> 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="https://dashboard.weglot.com/settings/language-switcher/editor?url=<?php echo esc_url( get_home_url() ); ?>" 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> templates/admin/pages/tabs/settings.php 0000644 00000021736 15134111570 0014242 0 ustar 00 <?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; ?> templates/admin/pages/tabs/status.php 0000644 00000010575 15134111570 0013724 0 ustar 00 <?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> templates/admin/pages/nav.php 0000644 00000001017 15134111570 0012223 0 ustar 00 <?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> templates/admin/notices/rewrite-module.php 0000644 00000000763 15134111570 0014757 0 ustar 00 <?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> templates/admin/notices/wpml-activate.php 0000644 00000001536 15134111570 0014567 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { exit; } $plugin_file = "sitepress-multilingual-cms/sitepress.php"; $deactivate_link = wp_nonce_url('plugins.php?action=deactivate&plugin='.urlencode($plugin_file ).'&plugin_status=all&paged=1&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>