From 61ce97005cce5bfa7ae22e20c7319330462cb7e2 Mon Sep 17 00:00:00 2001 From: Boone B Gorges Date: Thu, 19 Oct 2023 14:49:57 -0500 Subject: [PATCH] Install plugin: bogo. Name: Bogo Version: 3.7 See #3263. --- wp-content/plugins/bogo/admin/admin.php | 528 +++++++++ .../bogo/admin/includes/css/admin-rtl.css | 50 + .../plugins/bogo/admin/includes/css/admin.css | 144 +++ .../plugins/bogo/admin/includes/js/admin.js | 114 ++ .../bogo/admin/includes/language-packs.php | 425 +++++++ .../plugins/bogo/admin/includes/nav-menu.php | 117 ++ .../plugins/bogo/admin/includes/post.php | 314 +++++ .../bogo/admin/includes/terms-translation.php | 221 ++++ .../plugins/bogo/admin/includes/upgrade.php | 3 + .../plugins/bogo/admin/includes/user.php | 83 ++ .../plugins/bogo/admin/includes/widgets.php | 46 + wp-content/plugins/bogo/bogo.php | 156 +++ .../includes/block-editor/block-editor.php | 62 + .../language-panel/index.asset.php | 15 + .../block-editor/language-panel/index.js | 3 + .../block-editor/language-switcher/block.json | 19 + .../language-switcher/index.asset.php | 13 + .../block-editor/language-switcher/index.js | 1 + .../plugins/bogo/includes/capabilities.php | 51 + .../plugins/bogo/includes/css/style-rtl.css | 0 .../plugins/bogo/includes/css/style.css | 1015 +++++++++++++++++ wp-content/plugins/bogo/includes/flags.php | 71 ++ .../plugins/bogo/includes/formatting.php | 47 + .../plugins/bogo/includes/functions.php | 47 + .../bogo/includes/language-functions.php | 947 +++++++++++++++ .../bogo/includes/language-switcher.php | 223 ++++ .../plugins/bogo/includes/link-template.php | 244 ++++ wp-content/plugins/bogo/includes/nav-menu.php | 42 + wp-content/plugins/bogo/includes/pomo.php | 162 +++ wp-content/plugins/bogo/includes/post.php | 660 +++++++++++ wp-content/plugins/bogo/includes/query.php | 269 +++++ wp-content/plugins/bogo/includes/rest-api.php | 249 ++++ wp-content/plugins/bogo/includes/rewrite.php | 524 +++++++++ .../plugins/bogo/includes/shortcodes.php | 17 + wp-content/plugins/bogo/includes/user.php | 169 +++ wp-content/plugins/bogo/includes/widgets.php | 81 ++ wp-content/plugins/bogo/languages/readme.txt | 7 + wp-content/plugins/bogo/license.txt | 358 ++++++ wp-content/plugins/bogo/readme.txt | 88 ++ 39 files changed, 7585 insertions(+) create mode 100644 wp-content/plugins/bogo/admin/admin.php create mode 100644 wp-content/plugins/bogo/admin/includes/css/admin-rtl.css create mode 100644 wp-content/plugins/bogo/admin/includes/css/admin.css create mode 100644 wp-content/plugins/bogo/admin/includes/js/admin.js create mode 100644 wp-content/plugins/bogo/admin/includes/language-packs.php create mode 100644 wp-content/plugins/bogo/admin/includes/nav-menu.php create mode 100644 wp-content/plugins/bogo/admin/includes/post.php create mode 100644 wp-content/plugins/bogo/admin/includes/terms-translation.php create mode 100644 wp-content/plugins/bogo/admin/includes/upgrade.php create mode 100644 wp-content/plugins/bogo/admin/includes/user.php create mode 100644 wp-content/plugins/bogo/admin/includes/widgets.php create mode 100644 wp-content/plugins/bogo/bogo.php create mode 100644 wp-content/plugins/bogo/includes/block-editor/block-editor.php create mode 100644 wp-content/plugins/bogo/includes/block-editor/language-panel/index.asset.php create mode 100644 wp-content/plugins/bogo/includes/block-editor/language-panel/index.js create mode 100644 wp-content/plugins/bogo/includes/block-editor/language-switcher/block.json create mode 100644 wp-content/plugins/bogo/includes/block-editor/language-switcher/index.asset.php create mode 100644 wp-content/plugins/bogo/includes/block-editor/language-switcher/index.js create mode 100644 wp-content/plugins/bogo/includes/capabilities.php create mode 100644 wp-content/plugins/bogo/includes/css/style-rtl.css create mode 100644 wp-content/plugins/bogo/includes/css/style.css create mode 100644 wp-content/plugins/bogo/includes/flags.php create mode 100644 wp-content/plugins/bogo/includes/formatting.php create mode 100644 wp-content/plugins/bogo/includes/functions.php create mode 100644 wp-content/plugins/bogo/includes/language-functions.php create mode 100644 wp-content/plugins/bogo/includes/language-switcher.php create mode 100644 wp-content/plugins/bogo/includes/link-template.php create mode 100644 wp-content/plugins/bogo/includes/nav-menu.php create mode 100644 wp-content/plugins/bogo/includes/pomo.php create mode 100644 wp-content/plugins/bogo/includes/post.php create mode 100644 wp-content/plugins/bogo/includes/query.php create mode 100644 wp-content/plugins/bogo/includes/rest-api.php create mode 100644 wp-content/plugins/bogo/includes/rewrite.php create mode 100644 wp-content/plugins/bogo/includes/shortcodes.php create mode 100644 wp-content/plugins/bogo/includes/user.php create mode 100644 wp-content/plugins/bogo/includes/widgets.php create mode 100644 wp-content/plugins/bogo/languages/readme.txt create mode 100644 wp-content/plugins/bogo/license.txt create mode 100644 wp-content/plugins/bogo/readme.txt diff --git a/wp-content/plugins/bogo/admin/admin.php b/wp-content/plugins/bogo/admin/admin.php new file mode 100644 index 0000000000..1274fad3b1 --- /dev/null +++ b/wp-content/plugins/bogo/admin/admin.php @@ -0,0 +1,528 @@ + $language ) { + $native_name = bogo_get_language_native_name( $locale ); + + if ( bogo_locale_is_alone( $locale ) ) { + $native_name = bogo_get_short_name( $native_name ); + } + + $available_languages[$locale] = array( + 'name' => $language, + 'nativename' => trim( $native_name ), + 'country' => bogo_get_country_code( $locale ), + 'tags' => array_unique( array_filter( + array( + bogo_language_tag( $locale ), + bogo_lang_slug( $locale ), + ) + ) ), + ); + } + + $local_args = array( + 'l10n' => array( + /* translators: accessibility text */ + 'targetBlank' => __( '(opens in a new window)', 'bogo' ), + 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", 'bogo' ), + ), + 'apiSettings' => array( + 'root' => esc_url_raw( rest_url( 'bogo/v1' ) ), + 'namespace' => 'bogo/v1', + 'nonce' => ( wp_installing() && ! is_multisite() ) + ? '' : wp_create_nonce( 'wp_rest' ), + ), + 'availableLanguages' => $available_languages, + 'defaultLocale' => bogo_get_default_locale(), + 'pagenow' => isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '', + 'currentPost' => array(), + 'localizablePostTypes' => bogo_localizable_post_types(), + 'showFlags' => apply_filters( 'bogo_use_flags', true ), + ); + + if ( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) { + if ( $screen = get_current_screen() and $screen->is_block_editor() ) { + wp_enqueue_script( 'bogo-block-editor' ); + } + + $user_locale = bogo_get_user_locale(); + + $current_post = array( + 'locale' => $user_locale, + 'lang' => bogo_lang_slug( $user_locale ), + 'translations' => array(), + ); + + if ( $post = get_post() ) { + $current_post['postId'] = $post->ID; + $post_type_object = get_post_type_object( $post->post_type ); + $edit_post_cap = $post_type_object->cap->edit_post; + + if ( $locale = get_post_meta( $post->ID, '_locale', true ) ) { + $current_post['locale'] = $locale; + $current_post['lang'] = bogo_lang_slug( $locale ); + } + + $available_locales = bogo_available_locales( array( + 'exclude' => array( $current_post['locale'] ), + ) ); + + foreach ( $available_locales as $locale ) { + $current_post['translations'][$locale] = array(); + + $translation = bogo_get_post_translation( $post->ID, $locale ); + + if ( $translation ) { + $current_post['translations'][$locale] = array( + 'postId' => $translation->ID, + 'postTitle' => $translation->post_title, + 'editLink' => current_user_can( $edit_post_cap, $translation->ID ) + ? get_edit_post_link( $translation, 'raw' ) + : '', + ); + } + } + } + + $local_args['currentPost'] = $current_post; + } + + wp_localize_script( 'bogo-admin', 'bogo', $local_args ); +} + +add_action( 'admin_menu', 'bogo_admin_menu', 10, 0 ); + +function bogo_admin_menu() { + add_menu_page( + __( 'Languages', 'bogo' ), + __( 'Languages', 'bogo' ), + 'bogo_manage_language_packs', + 'bogo', + 'bogo_tools_page', + 'dashicons-translation', + 73 // between Users (70) and Tools (75) + ); + + $tools = add_submenu_page( + 'bogo', + __( 'Language Packs', 'bogo' ), + __( 'Language Packs', 'bogo' ), + 'bogo_manage_language_packs', + 'bogo', + 'bogo_tools_page' + ); + + add_action( 'load-' . $tools, 'bogo_load_tools_page', 10, 0 ); + + $available_locales = bogo_available_locales( array( + 'current_user_can_access' => true, + 'exclude' => array( bogo_get_default_locale() ), + ) ); + + if ( 0 < count( $available_locales ) ) { + $texts = add_submenu_page( + 'bogo', + __( 'Terms Translation', 'bogo' ), + __( 'Terms Translation', 'bogo' ), + 'bogo_edit_terms_translation', + 'bogo-texts', + 'bogo_texts_page' + ); + + add_action( 'load-' . $texts, 'bogo_load_texts_page', 10, 0 ); + } +} + +add_filter( + 'set_screen_option_bogo_texts_per_page', + 'bogo_set_screen_options', + 10, 3 +); + +function bogo_set_screen_options( $result, $option, $value ) { + $bogo_screens = array( + 'bogo_texts_per_page', + ); + + if ( in_array( $option, $bogo_screens ) ) { + $result = $value; + } + + return $result; +} + +function bogo_load_tools_page() { + require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); + + $action = isset( $_GET['action'] ) ? $_GET['action'] : ''; + $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null; + + if ( 'activate' == $action ) { + check_admin_referer( 'bogo-tools' ); + + if ( ! current_user_can( 'bogo_manage_language_packs' ) ) { + wp_die( __( "You are not allowed to manage translations.", 'bogo' ) ); + } + + if ( 'en_US' == $locale ) { + bogo_set_prop( 'enus_deactivated', false ); + + $redirect_to = add_query_arg( + array( 'message' => 'enus_activated' ), + menu_page_url( 'bogo', false ) + ); + } else { + if ( wp_download_language_pack( $locale ) ) { + $redirect_to = add_query_arg( + array( 'locale' => $locale, 'message' => 'install_success' ), + menu_page_url( 'bogo', false ) + ); + } else { + $redirect_to = add_query_arg( + array( 'locale' => $locale, 'message' => 'install_failed' ), + menu_page_url( 'bogo', false ) + ); + } + } + + wp_safe_redirect( $redirect_to ); + exit(); + } + + if ( 'deactivate' == $action ) { + check_admin_referer( 'bogo-tools' ); + + if ( ! current_user_can( 'bogo_manage_language_packs' ) ) { + wp_die( __( "You are not allowed to manage translations.", 'bogo' ) ); + } + + if ( 'en_US' == $locale ) { + bogo_set_prop( 'enus_deactivated', true ); + + $redirect_to = add_query_arg( + array( 'message' => 'enus_deactivated' ), + menu_page_url( 'bogo', false ) + ); + } else { + if ( bogo_delete_language_pack( $locale ) ) { + $redirect_to = add_query_arg( + array( 'locale' => $locale, 'message' => 'delete_success' ), + menu_page_url( 'bogo', false ) + ); + } else { + $redirect_to = add_query_arg( + array( 'locale' => $locale, 'message' => 'delete_failed' ), + menu_page_url( 'bogo', false ) + ); + } + } + + wp_safe_redirect( $redirect_to ); + exit(); + } + + if ( 'promote' == $action ) { + check_admin_referer( 'bogo-tools' ); + + if ( ! current_user_can( 'bogo_manage_language_packs' ) ) { + wp_die( __( "You are not allowed to manage translations.", 'bogo' ) ); + } + + if ( 'en_US' == $locale + or ! bogo_is_available_locale( $locale ) ) { + $locale = ''; + } + + if ( update_option( 'WPLANG', $locale ) ) { + $redirect_to = add_query_arg( + array( 'locale' => $locale, 'message' => 'promote_success' ), + menu_page_url( 'bogo', false ) + ); + } else { + $redirect_to = add_query_arg( + array( 'locale' => $locale, 'message' => 'promote_failed' ), + menu_page_url( 'bogo', false ) + ); + } + + wp_safe_redirect( $redirect_to ); + exit(); + } + + if ( 'translate' == $action ) { + check_admin_referer( 'bogo-tools' ); + + if ( ! current_user_can( 'bogo_edit_terms_translation', $locale ) ) { + wp_die( __( "You are not allowed to edit translations.", 'bogo' ) ); + } + + $is_active = ( 'en_US' == $locale ) + ? ! bogo_is_enus_deactivated() + : bogo_is_available_locale( $locale ); + + if ( ! bogo_is_default_locale( $locale ) + and $is_active ) { + $redirect_to = add_query_arg( + array( 'locale' => $locale ), + menu_page_url( 'bogo-texts', false ) ); + + wp_safe_redirect( $redirect_to ); + exit(); + } + } + + $current_screen = get_current_screen(); + + add_filter( 'manage_' . $current_screen->id . '_columns', + array( 'Bogo_Language_Packs_List_Table', 'define_columns' ), + 10, 1 + ); +} + +function bogo_tools_page() { + $list_table = new Bogo_Language_Packs_List_Table(); + $list_table->prepare_items(); + +?> +
+ +

+ +%s', + sprintf( + /* translators: %s: search query */ + __( 'Search results for “%s”', 'bogo' ), + esc_html( $_REQUEST['s'] ) + ) + ); + } +?> + +
+ + + +views(); ?> + +
+ + search_box( __( 'Search Language', 'bogo' ), 'bogo-language-packs' ); ?> + display(); ?> +
+ +
+ $item['name'], + 'translations' => array( $translation ), + 'context' => preg_replace( '/:.*$/', '', $item['name'] ), + ); + } + + if ( Bogo_POMO::export( $locale, $entries ) ) { + $message = 'translation_saved'; + } else { + $message = 'translation_failed'; + } + + $redirect_to = add_query_arg( + array( + 'locale' => $locale, + 'message' => $message, + 'paged' => isset( $_POST['paged'] ) ? absint( $_POST['paged'] ) : 1, + ), + menu_page_url( 'bogo-texts', false ) + ); + + wp_safe_redirect( $redirect_to ); + exit(); + + } else { + $current_screen = get_current_screen(); + + add_filter( 'manage_' . $current_screen->id . '_columns', + array( 'Bogo_Terms_Translation_List_Table', 'define_columns' ), + 10, 1 + ); + + add_screen_option( 'per_page', array( + 'default' => 20, + 'option' => 'bogo_texts_per_page', + ) ); + } +} + +function bogo_texts_page() { + $list_table = new Bogo_Terms_Translation_List_Table(); + $list_table->prepare_items(); + +?> +
+ +

+ +%s', + sprintf( + /* translators: %s: search query */ + __( 'Search results for “%s”', 'bogo' ), + esc_html( $_REQUEST['s'] ) + ) + ); + } +?> + +
+ + + +
+ + +search_box( + __( 'Search Translation', 'bogo' ), 'bogo-terms-translation' + ); +?> +
+ +
+ + +display(); +?> +
+
+

%s

', + esc_html( $message ) + ); + } else { + echo sprintf( + '

%s

', + esc_html( $message ) + ); + } +} diff --git a/wp-content/plugins/bogo/admin/includes/css/admin-rtl.css b/wp-content/plugins/bogo/admin/includes/css/admin-rtl.css new file mode 100644 index 0000000000..58df66dccd --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/css/admin-rtl.css @@ -0,0 +1,50 @@ +/* Language Packs */ + +#bogo-language-packs td:first-child { + border-right: 0; + padding-right: 16px; +} + +#bogo-language-packs tr.active td:first-child { + border-right: 4px solid #00a0d2; + padding-right: 12px; +} + +#bogo-language-packs td.status li.post-count, +#bogo-language-packs td.status li.page-count { + float: right; + margin: 6px 0 0 16px; +} + +#bogo-language-packs td.status li.post-count a::before, +#bogo-language-packs td.status li.page-count a::before { + padding-left: 4px; +} + +/* Terms Translation */ + +#bogo-terms-translation .large-text { + padding-right: 0; + margin-right: 0; +} + +#bogo-terms-translation .large-text:hover { + padding-right: 5px; + margin-right: 1px; +} + +#bogo-terms-translation .large-text:focus { + padding-right: 5px; + margin-right: 1px; +} + +/* Post */ + +ul#bogo-translations li { + margin-right: 1.4em; +} + +#bogo-add-translation-actions span.spinner, +#bogo-add-translation-actions button { + float: right; +} diff --git a/wp-content/plugins/bogo/admin/includes/css/admin.css b/wp-content/plugins/bogo/admin/includes/css/admin.css new file mode 100644 index 0000000000..4bffaddd51 --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/css/admin.css @@ -0,0 +1,144 @@ +fieldset.bogo-locale-options { + margin: 0px 12px 10px 0; + padding: 4px 4px 8px 8px; + border: 1px solid #dfdfdf; +} + +#your-profile fieldset.bogo-locale-options { + margin: 0; + padding: 4px 0 0; + border: none; +} + +.widget-content fieldset.bogo-locale-options { + margin-right: 0; +} + +fieldset.bogo-locale-options legend { + font-style: italic; + color: #666666; +} + +fieldset.bogo-locale-options label.bogo-locale-option { + display: inline-block; + white-space: nowrap; + margin: 6px 0.4em 0 0; + border: 1px solid #a7a7a7; + border-radius: 4px; + padding: 1px 4px 1px 2px; + background: #f1f1f1; +} + +fieldset.bogo-locale-options label.bogo-locale-option.checked { + border: 1px solid #0074a2; + background: #d4eefe; +} + +fieldset.bogo-locale-options label.bogo-locale-option input[type="checkbox"] { + width: 16px; +} + +/* Language Packs */ + +#bogo-language-packs td { + box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset; + padding: 10px; +} + +#bogo-language-packs td:first-child { + border-left: 0; + padding-left: 16px; +} + +#bogo-language-packs tr.active td { + background-color: #f7fcfe; +} + +#bogo-language-packs tr.active td:first-child { + border-left: 4px solid #00a0d2; + padding-left: 12px; +} + +#bogo-language-packs td.status ul { + margin: 0; +} + +#bogo-language-packs td.status li.post-count, +#bogo-language-packs td.status li.page-count { + float: left; + margin: 6px 16px 0 0; +} + +#bogo-language-packs td.status li.post-count a::before, +#bogo-language-packs td.status li.page-count a::before { + font: normal 20px/1 dashicons; + color: #82878c; + content: '\f159'; + display: inline-block; + vertical-align: top; + padding-right: 4px; + text-decoration: none; +} + +#bogo-language-packs td.status li.post-count a::before { + content: '\f109'; +} + +#bogo-language-packs td.status li.page-count a::before { + content: '\f105'; +} + +/* Terms Translation */ + +#bogo-terms-translation .large-text { + background: transparent; + color: #555; + font-size: 13px; + border: none; + box-shadow: none; + padding-left: 0; + margin-left: 0; +} + +#bogo-terms-translation .large-text:hover { + background: #fff; + color: #32373c; + font-size: 14px; + border: 1px solid #ddd; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07) inset; + padding-left: 5px; + margin-left: 1px; +} + +#bogo-terms-translation .large-text:focus { + background: #fff; + color: #32373c; + font-size: 14px; + border: 1px solid #5b9dd9; + box-shadow: 0 0 2px rgba(30, 140, 190, 0.8); + padding-left: 5px; + margin-left: 1px; +} + +/* Post */ + +ul#bogo-translations li { + list-style-type: disc; + margin-left: 1.4em; +} + +#bogo-translations-to-add { + width: 100%; +} + +#bogo-add-translation-actions span.spinner, +#bogo-add-translation-actions button { + float: left; +} + +/* Admin Bar */ + +#wpadminbar #wp-admin-bar-bogo-user-locale .ab-icon::before { + content: "\f326"; + top: 2px; +} diff --git a/wp-content/plugins/bogo/admin/includes/js/admin.js b/wp-content/plugins/bogo/admin/includes/js/admin.js new file mode 100644 index 0000000000..06abdbd526 --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/js/admin.js @@ -0,0 +1,114 @@ +( function( $ ) { + + 'use strict'; + + if ( typeof bogo === 'undefined' || bogo === null ) { + return; + } + + bogo.langName = function( locale ) { + if ( bogo.availableLanguages[ locale ] ) { + return bogo.availableLanguages[ locale ].name; + } else { + return ''; + } + }; + + $( function() { + $( 'body.options-general-php select#WPLANG' ).each( function() { + $( this ).find( 'option[selected="selected"]' ).removeAttr( 'selected' ).prop( 'selected', false ); + var val = bogo.defaultLocale || 'en_US'; + val = ( 'en_US' == val ? '' : val ); + $( this ).find( 'option[value="' + val + '"]' ).first().attr( 'selected', 'selected' ).prop( 'selected', true ); + } ); + } ); + + $( function() { + $( '#bogo-add-translation' ).click( function() { + if ( ! bogo.currentPost.postId ) { + return; + } + + var locale = $( '#bogo-translations-to-add' ).val(); + var rest_url = bogo.apiSettings.getRoute( + '/posts/' + bogo.currentPost.postId + '/translations/' + locale ); + $( '#bogo-add-translation' ).next( '.spinner' ) + .css( 'visibility', 'visible' ); + + $.ajax( { + type: 'POST', + url: rest_url, + beforeSend: function( xhr ) { + xhr.setRequestHeader( 'X-WP-Nonce', bogo.apiSettings.nonce ); + } + } ).done( function( response ) { + var post = response[ locale ]; + + if ( ! post ) { + return; + } + + var $added = $( '' ).attr( { + href: post.edit_link, + target: '_blank', + rel: 'noopener noreferrer' + } ).html( function() { + var output = post.title.rendered; + output += ' ' + + bogo.l10n.targetBlank + ''; + return output; + } ); + + $added = $( '
  • ' ).append( $added ).append( + ' [' + bogo.langName( locale ) + ']' ); + $( '#bogo-translations' ).append( $added ); + + $( '#bogo-translations-to-add option[value="' + locale + '"]' ).detach(); + + if ( $( '#bogo-translations-to-add option' ).length < 1 ) { + $( '#bogo-add-translation-actions' ).detach(); + } + } ).always( function() { + $( '#bogo-add-translation' ).next( '.spinner' ).css( 'visibility', 'hidden' ); + } ); + } ); + } ); + + $( function() { + if ( 'bogo-texts' == bogo.pagenow ) { + $( window ).on( 'beforeunload', function( event ) { + var changed = false; + + $( '#bogo-terms-translation :text' ).each( function() { + if ( this.defaultValue != $( this ).val() ) { + changed = true; + } + } ); + + if ( changed ) { + event.returnValue = bogo.l10n.saveAlert; + return bogo.l10n.saveAlert; + } + } ); + + $( '#bogo-terms-translation' ).submit( function() { + $( window ).off( 'beforeunload' ); + } ); + + $( '#select-locale' ).change( function() { + location = 'admin.php?page=bogo-texts&locale=' + $( this ).val(); + } ); + } + } ); + + bogo.apiSettings.getRoute = function( path ) { + var url = bogo.apiSettings.root; + + url = url.replace( + bogo.apiSettings.namespace, + bogo.apiSettings.namespace + path ); + + return url; + }; + +} )( jQuery ); diff --git a/wp-content/plugins/bogo/admin/includes/language-packs.php b/wp-content/plugins/bogo/admin/includes/language-packs.php new file mode 100644 index 0000000000..f8eab6b878 --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/language-packs.php @@ -0,0 +1,425 @@ + __( 'Language', 'bogo' ), + 'status' => __( 'Status', 'bogo' ), + ); + + return $columns; + } + + public function get_columns() { + return get_column_headers( get_current_screen() ); + } + + public function prepare_items() { + $this->items = array(); + + $search_keys = empty( $_REQUEST['s'] ) + ? array() + : preg_split( '/[\s]+/', $_REQUEST['s'] ); + + $status = isset( $_REQUEST['status'] ) + ? trim( $_REQUEST['status'] ) + : ''; + + $locales = array_keys( bogo_languages() ); + + sort( $locales ); + + $locales = array_unique( array_merge( + array( bogo_get_default_locale() ), + bogo_available_locales(), + array( 'en_US' ), + $locales + ) ); + + foreach ( $locales as $locale ) { + $language = bogo_get_language( $locale ); + + $is_active = ( 'en_US' == $locale ) + ? ! bogo_is_enus_deactivated() + : bogo_is_available_locale( $locale ); + + if ( $is_active ) { + $this->count_active += 1; + } else { + $this->count_inactive += 1; + } + + if ( $search_keys ) { + $haystack = $locale . ' ' . $language; + $needle_found = true; + + foreach ( $search_keys as $needle ) { + if ( false === stripos( $haystack, $needle ) ) { + $needle_found = false; + break; + } + } + + if ( ! $needle_found ) { + continue; + } + } + + if ( 'active' == $status and ! $is_active + or 'inactive' == $status and $is_active ) { + continue; + } + + $this->items[] = (object) array( + 'locale' => $locale, + 'language' => $language, + 'active' => $is_active, + ); + } + + $this->set_pagination_args( array( + 'total_items' => count( $this->items ), + 'total_pages' => 1, + ) ); + } + + protected function get_views() { + $links = array(); + $menu_page_url = menu_page_url( 'bogo', false ); + + $status = isset( $_REQUEST['status'] ) + ? trim( $_REQUEST['status'] ) + : ''; + + // All + $count_all = $this->count_active + $this->count_inactive; + + $all = sprintf( + /* translators: %s: number of language packs */ + _nx( + 'All (%s)', + 'All (%s)', + $count_all, 'language status', 'bogo' ), + number_format_i18n( $count_all ) + ); + + $links['all'] = sprintf( + '%3$s', + esc_url( $menu_page_url ), + '' === $status ? ' class="current"' : '', + $all + ); + + // Active + $active = sprintf( + /* translators: %s: number of language packs */ + _nx( + 'Active (%s)', + 'Active (%s)', + $this->count_active, 'language status', 'bogo' ), + number_format_i18n( $this->count_active ) + ); + + $links['active'] = sprintf( + '%3$s', + esc_url( add_query_arg( 'status', 'active', $menu_page_url ) ), + 'active' == $status ? ' class="current"' : '', + $active + ); + + // Inactive + $inactive = sprintf( + /* translators: %s: number of language packs */ + _nx( + 'Inactive (%s)', + 'Inactive (%s)', + $this->count_inactive, 'language status', 'bogo' ), + number_format_i18n( $this->count_inactive ) + ); + + $links['inactive'] = sprintf( + '%3$s', + esc_url( add_query_arg( 'status', 'inactive', $menu_page_url ) ), + 'inactive' == $status ? ' class="current"' : '', + $inactive + ); + + return $links; + } + + public function column_name( $item ) { + echo sprintf( + '%1$s [%2$s]', + esc_html( $item->language ), + esc_html( $item->locale ) + ); + } + + public function column_status( $item ) { + $status = ''; + + if ( $item->active ) { + if ( bogo_is_default_locale( $item->locale ) ) { + $status = __( 'Site Language', 'bogo' ); + } else { + $status = __( 'Active', 'bogo' ); + } + + } else { + $status = __( 'Inactive', 'bogo' ); + } + + if ( $status ) { + echo sprintf( + '
    %s
    ', + esc_html( $status ) + ); + } + + if ( $item->active ) { + $this->render_post_count( $item ); + } + } + + private function render_post_count( $item ) { + $count_posts = bogo_count_posts( $item->locale, 'post' ); + $count_pages = bogo_count_posts( $item->locale, 'page' ); + + if ( $count_posts ) { + $count_posts = sprintf( + /* translators: %s: number of posts */ + _n( '%s Post', '%s Posts', $count_posts, 'bogo' ), + number_format_i18n( $count_posts ) + ); + } + + if ( $count_pages ) { + $count_pages = sprintf( + /* translators: %s: number of pages */ + _n( '%s Page', '%s Pages', $count_pages, 'bogo' ), + number_format_i18n( $count_pages ) + ); + } + + $edit_url = add_query_arg( + array( + 'post_status' => 'publish', + 'lang' => $item->locale, + ), + admin_url( 'edit.php' ) + ); + + echo ''; + } + + public function single_row( $item ) { + echo $item->active + ? '' + : ''; + + $this->single_row_columns( $item ); + echo ''; + } + + protected function handle_row_actions( $item, $column_name, $primary ) { + if ( $column_name !== $primary ) { + return ''; + } + + $actions = array(); + + if ( 'en_US' == $item->locale + or $this->can_install_language_pack() ) { + if ( bogo_is_default_locale( $item->locale ) ) { + // nothing + } elseif ( $item->active ) { + $actions = array( + 'promote' => $this->action_link( $item, 'promote' ), + 'deactivate' => $this->action_link( $item, 'deactivate' ), + ); + } else { + $actions = array( + 'activate' => $this->action_link( $item, 'activate' ), + ); + } + } + + if ( $item->active + and ! bogo_is_default_locale( $item->locale ) ) { + $actions['translate'] = $this->action_link( $item, 'translate' ); + } + + if ( 'en_US' != $item->locale ) { + $actions['meet'] = $this->meet_the_team_link( $item ); + } + + return $this->row_actions( $actions ); + } + + private function action_link( $item, $action ) { + $labels = array( + 'activate' => array( + __( 'Activate', 'bogo' ), + sprintf( + /* translators: %s: language name */ + __( 'Activate %s language pack', 'bogo' ), + $item->language + ), + ), + 'deactivate' => array( + __( 'Deactivate', 'bogo' ), + sprintf( + /* translators: %s: language name */ + __( 'Deactivate %s language pack', 'bogo' ), + $item->language + ), + ), + 'promote' => array( + __( 'Set as Site Language', 'bogo' ), + sprintf( + /* translators: %s: language name */ + __( 'Set %s as Site Language', 'bogo' ), + $item->language + ), + ), + 'translate' => array( + __( 'Translate Terms', 'bogo' ), + sprintf( + /* translators: %s: language name */ + __( 'Translate terms into %s', 'bogo' ), + $item->language + ), + ), + ); + + $link = menu_page_url( 'bogo', false ); + + $link = add_query_arg( array( + 'action' => $action, + 'locale' => $item->locale, + ), $link ); + + $link = wp_nonce_url( $link, 'bogo-tools' ); + + $link = sprintf( + '%2$s', + esc_url( $link ), + esc_html( $labels[$action][0] ), + esc_attr( $labels[$action][1] ), + esc_attr( $action ) + ); + + return $link; + } + + private function meet_the_team_link( $item ) { + $link = 'https://make.wordpress.org/polyglots/teams/'; + + $locale = $item->locale; + $locale = explode( '_', $locale, 3 ); + $locale = implode( '_', array_slice( $locale, 0, 2 ) ); + + $link = add_query_arg( array( + 'locale' => $locale, + ), $link ); + + $link .= '#main'; + + $labels = array( + __( 'Meet the Translation Team', 'bogo' ), + sprintf( + /* translators: %s: language name */ + __( 'Meet the Translation Team for %s', 'bogo' ), + $item->language + ) + ); + + $link = sprintf( + '%2$s %4$s', + esc_url( $link ), + esc_html( $labels[0] ), + esc_attr( $labels[1] ), + /* translators: accessibility text */ + esc_html( __( '(opens in a new window)', 'bogo' ) ) + ); + + return $link; + } + + private function can_install_language_pack() { + static $can_install = null; + + if ( ! isset( $can_install ) ) { + $can_install = wp_can_install_language_pack(); + } + + return $can_install; + } +} + +function bogo_delete_language_pack( $locale ) { + if ( 'en_US' == $locale + or ! bogo_is_available_locale( $locale ) + or bogo_is_default_locale( $locale ) ) { + return false; + } + + if ( ! is_dir( WP_LANG_DIR ) + or ! $files = scandir( WP_LANG_DIR ) ) { + return false; + } + + $target_files = array( + sprintf( '%s.mo', $locale ), + sprintf( '%s.po', $locale ), + sprintf( 'admin-%s.mo', $locale ), + sprintf( 'admin-%s.po', $locale ), + sprintf( 'admin-network-%s.mo', $locale ), + sprintf( 'admin-network-%s.po', $locale ), + sprintf( 'continents-cities-%s.mo', $locale ), + sprintf( 'continents-cities-%s.po', $locale ), + ); + + foreach ( $files as $file ) { + if ( '.' === $file[0] + or is_dir( $file ) ) { + continue; + } + + if ( in_array( $file, $target_files ) ) { + $result = @unlink( path_join( WP_LANG_DIR, $file ) ); + + if ( ! $result ) { + return false; + } + } + } + + return true; +} diff --git a/wp-content/plugins/bogo/admin/includes/nav-menu.php b/wp-content/plugins/bogo/admin/includes/nav-menu.php new file mode 100644 index 0000000000..f87568fca4 --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/nav-menu.php @@ -0,0 +1,117 @@ +/', + ''; + + if ( $initial or empty( $available_languages ) ) { + return; + } + + echo '
    '; + echo sprintf( '

    %s:

    ', + esc_html( __( 'Add Translation', 'bogo' ) ) + ); + echo ''; + echo '

    '; + echo sprintf( + '', + 'bogo-add-translation', + esc_html( __( 'Add Translation', 'bogo' ) ) + ); + echo ''; + echo '

    '; + echo '
    '; + echo '
    '; +} diff --git a/wp-content/plugins/bogo/admin/includes/terms-translation.php b/wp-content/plugins/bogo/admin/includes/terms-translation.php new file mode 100644 index 0000000000..4768cb11d7 --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/terms-translation.php @@ -0,0 +1,221 @@ + __( 'Original', 'bogo' ), + 'translation' => __( 'Translation', 'bogo' ), + 'context' => __( 'Context', 'bogo' ), + ); + + return $columns; + } + + public function prepare_items() { + $this->locale_to_edit = isset( $_GET['locale'] ) ? $_GET['locale'] : ''; + + if ( ! bogo_is_available_locale( $this->locale_to_edit ) ) { + return; + } + + $items = bogo_terms_translation( $this->locale_to_edit ); + + foreach ( $items as $key => $item ) { + $cap = isset( $item['cap'] ) + ? $item['cap'] + : 'bogo_edit_terms_translation'; + + if ( ! current_user_can( $cap ) ) { + unset( $items[$key] ); + } + } + + if ( ! empty( $_REQUEST['s'] ) ) { + $keywords = preg_split( '/[\s]+/', $_REQUEST['s'] ); + + foreach ( $items as $key => $item ) { + $haystack = $item['original'] . ' ' . $item['translated']; + + foreach ( $keywords as $needle ) { + if ( false === stripos( $haystack, $needle ) ) { + unset( $items[$key] ); + break; + } + } + } + } + + $items = array_filter( $items ); + $items = array_values( $items ); + + $per_page = $this->get_items_per_page( 'bogo_texts_per_page' ); + $offset = ( $this->get_pagenum() - 1 ) * $per_page; + + $this->items = array_slice( $items, $offset, $per_page ); + + $total_items = count( $items ); + $total_pages = ceil( $total_items / $per_page ); + + $this->set_pagination_args( array( + 'total_items' => $total_items, + 'total_pages' => $total_pages, + 'per_page' => $per_page, + ) ); + } + + public function get_columns() { + return get_column_headers( get_current_screen() ); + } + + public function column_original( $item ) { + return esc_html( $item['original'] ); + } + + public function column_translation( $item ) { + return sprintf( + '', + bogo_format_atts( array( + 'type' => 'text', + 'name' => $item['name'], + 'id' => $item['name'], + 'value' => $item['translated'], + 'class' => 'large-text', + ) ) + ); + } + + public function column_context( $item ) { + return esc_html( $item['context'] ); + } + + protected function display_tablenav( $which ) { + echo sprintf( '
    ', esc_attr( $which ) ); + $this->extra_tablenav( $which ); + $this->pagination( $which ); + echo '
    '; + echo '
    '; + } + + protected function extra_tablenav( $which ) { + if ( 'top' == $which ) { + echo '
    '; + echo ''; + echo '
    '; + } + + if ( 'bottom' == $which ) { + echo '
    '; + submit_button(); + echo '
    '; + } + } +} + +function bogo_terms_translation( $locale_to_edit ) { + static $items = array(); + static $locale = null; + + if ( ! empty( $items ) + and $locale === $locale_to_edit ) { + return $items; + } + + $locale = $locale_to_edit; + + if ( ! Bogo_POMO::import( $locale ) ) { + Bogo_POMO::reset(); + } + + if ( ! bogo_is_available_locale( $locale ) ) { + return $items; + } + + $blogname = get_option( 'blogname' ); + + if ( $blogname ) { + $items[] = array( + 'name' => 'blogname', + 'original' => $blogname, + 'translated' => bogo_translate( + 'blogname', 'blogname', $blogname + ), + 'context' => __( 'Site Title', 'bogo' ), + 'cap' => 'manage_options', + ); + } + + $blogdescription = get_option( 'blogdescription' ); + + if ( $blogdescription ) { + $items[] = array( + 'name' => 'blogdescription', + 'original' => $blogdescription, + 'translated' => bogo_translate( + 'blogdescription', 'blogdescription', $blogdescription + ), + 'context' => __( 'Tagline', 'bogo' ), + 'cap' => 'manage_options', + ); + } + + remove_filter( 'get_term', 'bogo_get_term_filter' ); + + foreach ( (array) get_taxonomies( array(), 'objects' ) as $taxonomy ) { + $tax_labels = get_taxonomy_labels( $taxonomy ); + $terms = get_terms( array( + 'taxonomy' => $taxonomy->name, + 'orderby' => 'slug', + 'hide_empty' => false, + ) ); + + foreach ( (array) $terms as $term ) { + $name = sprintf( '%s:%d', $taxonomy->name, $term->term_id ); + $items[] = array( + 'name' => $name, + 'original' => $term->name, + 'translated' => bogo_translate( + $name, $taxonomy->name, $term->name + ), + 'context' => $tax_labels->name, + 'cap' => $taxonomy->cap->edit_terms, + ); + } + } + + add_filter( 'get_term', 'bogo_get_term_filter', 10, 2 ); + + $items = apply_filters( 'bogo_terms_translation', $items, $locale ); + + return $items; +} diff --git a/wp-content/plugins/bogo/admin/includes/upgrade.php b/wp-content/plugins/bogo/admin/includes/upgrade.php new file mode 100644 index 0000000000..3e143e23be --- /dev/null +++ b/wp-content/plugins/bogo/admin/includes/upgrade.php @@ -0,0 +1,3 @@ +get_blog_prefix() . 'accessible_locale'; + + if ( ! empty( $_POST['setting_bogo_accessible_locales'] ) ) { + delete_user_meta( $user_id, $meta_key ); + + if ( isset( $_POST['bogo_accessible_locales'] ) ) { + $locales = (array) $_POST['bogo_accessible_locales']; + $locales = bogo_filter_locales( $locales ); + + foreach ( $locales as $locale ) { + add_user_meta( $user_id, $meta_key, $locale ); + } + } + + if ( ! metadata_exists( 'user', $user_id, $meta_key ) ) { + add_user_meta( $user_id, $meta_key, 'zxx' ); + // zxx is a special code in ISO 639-2 + } + } + + if ( isset( $_POST['bogo_own_locale'] ) ) { + $locale = trim( $_POST['bogo_own_locale'] ); + + if ( bogo_is_available_locale( $locale ) ) { + update_user_option( $user_id, 'locale', $locale, true ); + } + } +} + +add_action( 'personal_options', 'bogo_set_locale_options', 10, 1 ); + +function bogo_set_locale_options( $profileuser ) { + if ( is_network_admin() or IS_PROFILE_PAGE ) { + return; + } + + if ( ! user_can( $profileuser, 'bogo_access_all_locales' ) ) { + bogo_set_accessible_locales( $profileuser ); + } +} + +function bogo_set_accessible_locales( $profileuser ) { + $available_languages = bogo_available_languages( array( + 'orderby' => 'value', + ) ); + + $accessible_locales = bogo_get_user_accessible_locales( $profileuser->ID ); + +?> + + + + + + +
    +
    + + $language ) : + $checked = in_array( $locale, $accessible_locales ); + $id_attr = 'bogo_accessible_locale-' . $locale; +?> + + +
    + + + + 'value', + ) ); + + if ( empty( $available_languages ) ) { + return; + } + + $return = null; + + $selected_languages = isset( $instance['bogo_locales'] ) + ? (array) $instance['bogo_locales'] + : array_keys( $available_languages ); + +?> +
    + + $language ) : + $checked = in_array( $locale, $selected_languages ); + $id_attr = $widget->get_field_id( 'bogo_locales' ) . '-' . $locale; +?> + + +
    +query_vars ) ) { + if ( $lang = get_query_var( 'lang' ) + and $closest = bogo_get_closest_locale( $lang ) ) { + return $bogo_locale = $closest; + } else { + return $bogo_locale = $default_locale; + } + } + + if ( isset( $wp_rewrite ) + and $wp_rewrite->using_permalinks() ) { + $url = is_ssl() ? 'https://' : 'http://'; + $url .= $_SERVER['HTTP_HOST']; + $url .= $_SERVER['REQUEST_URI']; + + $home = set_url_scheme( get_option( 'home' ) ); + $home = trailingslashit( $home ); + + $pattern = '#^' + . preg_quote( $home ) + . '(?:' . preg_quote( trailingslashit( $wp_rewrite->index ) ) . ')?' + . bogo_get_lang_regex() + . '(/|$)#'; + + if ( preg_match( $pattern, $url, $matches ) + and $closest = bogo_get_closest_locale( $matches[1] ) ) { + return $bogo_locale = $closest; + } + } + + $lang = bogo_get_lang_from_url(); + + if ( $lang + and $closest = bogo_get_closest_locale( $lang ) ) { + return $bogo_locale = $closest; + } + + return $bogo_locale = $default_locale; +} + +add_filter( 'query_vars', 'bogo_query_vars', 10, 1 ); + +function bogo_query_vars( $query_vars ) { + $query_vars[] = 'lang'; + + return $query_vars; +} + +add_action( 'wp_enqueue_scripts', 'bogo_enqueue_scripts', 10, 0 ); + +function bogo_enqueue_scripts() { + wp_enqueue_style( 'bogo', + plugins_url( 'includes/css/style.css', BOGO_PLUGIN_BASENAME ), + array(), BOGO_VERSION, 'all' + ); + + if ( is_rtl() ) { + wp_enqueue_style( 'bogo-rtl', + plugins_url( 'includes/css/style-rtl.css', BOGO_PLUGIN_BASENAME ), + array(), BOGO_VERSION, 'all' + ); + } +} + +add_action( 'deactivate_' . BOGO_PLUGIN_BASENAME, 'bogo_deactivate', 10, 0 ); + +function bogo_deactivate() { + bogo_delete_prop( 'lang_rewrite_regex' ); +} diff --git a/wp-content/plugins/bogo/includes/block-editor/block-editor.php b/wp-content/plugins/bogo/includes/block-editor/block-editor.php new file mode 100644 index 0000000000..dc434040c5 --- /dev/null +++ b/wp-content/plugins/bogo/includes/block-editor/block-editor.php @@ -0,0 +1,62 @@ + array( + 'wp-api-fetch', + 'wp-components', + 'wp-data', + 'wp-edit-post', + 'wp-element', + 'wp-i18n', + 'wp-plugins', + 'wp-url', + ), + 'version' => BOGO_VERSION, + ) ); + + wp_register_script( + 'bogo-block-editor', + plugins_url( + 'includes/block-editor/language-panel/index.js', + BOGO_PLUGIN_BASENAME + ), + $assets['dependencies'], + $assets['version'] + ); + + wp_set_script_translations( + 'bogo-block-editor', + 'bogo' + ); +} diff --git a/wp-content/plugins/bogo/includes/block-editor/language-panel/index.asset.php b/wp-content/plugins/bogo/includes/block-editor/language-panel/index.asset.php new file mode 100644 index 0000000000..1ec8112df0 --- /dev/null +++ b/wp-content/plugins/bogo/includes/block-editor/language-panel/index.asset.php @@ -0,0 +1,15 @@ + array( + 'wp-api-fetch', + 'wp-components', + 'wp-data', + 'wp-edit-post', + 'wp-element', + 'wp-i18n', + 'wp-plugins', + 'wp-url', + ), + 'version' => BOGO_VERSION, +); diff --git a/wp-content/plugins/bogo/includes/block-editor/language-panel/index.js b/wp-content/plugins/bogo/includes/block-editor/language-panel/index.js new file mode 100644 index 0000000000..be39eb1fb1 --- /dev/null +++ b/wp-content/plugins/bogo/includes/block-editor/language-panel/index.js @@ -0,0 +1,3 @@ +!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.plugins,n=window.wp.url,l=window.wp.apiFetch,a=e.n(l),o=window.wp.element,r=window.wp.editPost,i=window.wp.components,s=window.wp.data,u=window.wp.i18n;const c=e=>bogo.availableLanguages[e]?bogo.availableLanguages[e].name:e;(0,t.registerPlugin)("bogo-language-panel",{render:function(){const e=(0,s.useSelect)((e=>Object.assign({},e("core/editor").getCurrentPost(),bogo.currentPost)));if(-1==bogo.localizablePostTypes.indexOf(e.type))return(0,o.createElement)(o.Fragment,null);const[t,n]=(0,o.useState)(e.translations);return(0,o.createElement)(r.PluginDocumentSettingPanel,{name:"bogo-language-panel",title:(0,u.__)("Language","bogo"),className:"bogo-language-panel"},(0,o.createElement)((()=>(0,o.createElement)(i.PanelRow,null,(0,o.createElement)("span",null,(0,u.__)("Language","bogo")),(0,o.createElement)("div",null,c(e.locale)))),null),(0,o.createElement)((()=>{const e=[];return Object.entries(t).forEach((t=>{let[n,l]=t;l.editLink&&l.postTitle?e.push((0,o.createElement)("li",{key:n},(0,o.createElement)(i.ExternalLink,{href:l.editLink},l.postTitle),(0,o.createElement)("br",null),(0,o.createElement)("em",null,c(n)))):l.postTitle&&e.push((0,o.createElement)("li",{key:n},l.postTitle,(0,o.createElement)("br",null),(0,o.createElement)("em",null,c(n))))})),(0,o.createElement)(i.PanelRow,null,(0,o.createElement)("span",null,(0,u.__)("Translations","bogo")),(0,o.createElement)((e=>e.listItems.length?(0,o.createElement)("ul",null,e.listItems):(0,o.createElement)("em",null,(0,u.__)("None","bogo"))),{listItems:e}))}),null),(0,o.createElement)((()=>{const l=[];return Object.entries(t).forEach((r=>{let[g,p]=r;p.postId||l.push((0,o.createElement)("li",{key:g},(0,o.createElement)(i.Button,{isDefault:!0,onClick:()=>{(l=>{const o={...t};o[l]={creating:!0},n(o),a()({path:`/bogo/v1/posts/${e.id}/translations/${l}`,method:"POST"}).then((e=>{const a={...t};a[l]={postId:e[l].id,postTitle:e[l].title.raw,editLink:e[l].edit_link,creating:!1},n(a),(0,s.dispatch)("core/notices").createInfoNotice((0,u.__)("Translation post created.","bogo"),{isDismissible:!0,type:"snackbar",speak:!0,actions:[{url:a[l].editLink,label:(0,u.__)("Edit Post","bogo")}]})}))})(g)}},(0,u.sprintf)( +/* translators: %s: Language name. */ +(0,u.__)("Add %s translation","bogo"),c(g))),p.creating&&(0,o.createElement)(i.Spinner,null)))})),l.length<1||"auto-draft"==e.status?(0,o.createElement)(o.Fragment,null):(0,o.createElement)(i.PanelRow,null,(0,o.createElement)("ul",null,l))}),null))},icon:"translation"}),a().use(((e,t)=>{const l=bogo.currentPost.lang;return l&&("string"!=typeof e.url||(0,n.hasQueryArg)(e.url,"lang")||(e.url=(0,n.addQueryArgs)(e.url,{lang:l})),"string"!=typeof e.path||(0,n.hasQueryArg)(e.path,"lang")||(e.path=(0,n.addQueryArgs)(e.path,{lang:l}))),t(e,t)}))}(); \ No newline at end of file diff --git a/wp-content/plugins/bogo/includes/block-editor/language-switcher/block.json b/wp-content/plugins/bogo/includes/block-editor/language-switcher/block.json new file mode 100644 index 0000000000..2e7e373ab1 --- /dev/null +++ b/wp-content/plugins/bogo/includes/block-editor/language-switcher/block.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "name": "bogo/language-switcher", + "title": "Language Switcher", + "category": "widgets", + "icon": "translation", + "description": "Language switcher widget by Bogo.", + "keywords": [ "Bogo", "locale" ], + "textdomain": "bogo", + "attributes": { + "view": { + "enum": [ "list", "suggestion" ], + "default": "list" + } + }, + "editorScript": "file:./index.js", + "editorStyle": "file:../../css/style.css" +} diff --git a/wp-content/plugins/bogo/includes/block-editor/language-switcher/index.asset.php b/wp-content/plugins/bogo/includes/block-editor/language-switcher/index.asset.php new file mode 100644 index 0000000000..f50e124914 --- /dev/null +++ b/wp-content/plugins/bogo/includes/block-editor/language-switcher/index.asset.php @@ -0,0 +1,13 @@ + array( + 'wp-block-editor', + 'wp-blocks', + 'wp-components', + 'wp-element', + 'wp-i18n', + 'wp-primitives', + ), + 'version' => BOGO_VERSION, +); diff --git a/wp-content/plugins/bogo/includes/block-editor/language-switcher/index.js b/wp-content/plugins/bogo/includes/block-editor/language-switcher/index.js new file mode 100644 index 0000000000..9df3ee58cd --- /dev/null +++ b/wp-content/plugins/bogo/includes/block-editor/language-switcher/index.js @@ -0,0 +1 @@ +!function(){"use strict";var e=window.wp.element,t=window.wp.blocks,o=window.wp.blockEditor,n=window.wp.i18n,l=window.wp.components,a=window.wp.primitives,s=(0,e.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(a.Path,{d:"M12 15.8c-3.7 0-6.8-3-6.8-6.8s3-6.8 6.8-6.8c3.7 0 6.8 3 6.8 6.8s-3.1 6.8-6.8 6.8zm0-12C9.1 3.8 6.8 6.1 6.8 9s2.4 5.2 5.2 5.2c2.9 0 5.2-2.4 5.2-5.2S14.9 3.8 12 3.8zM8 17.5h8V19H8zM10 20.5h4V22h-4z"})),i=(0,e.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(a.Path,{d:"M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}));(0,t.registerBlockType)("bogo/language-switcher",{edit:function(t){let{attributes:a,setAttributes:c}=t;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.BlockControls,{group:"block"},(0,e.createElement)(l.ToolbarDropdownMenu,{label:(0,n.__)("Switch view","bogo"),icon:"suggestion"===a.view?s:i,controls:[{title:(0,n.__)("List view","bogo"),icon:i,onClick:()=>c({view:"list"})},{title:(0,n.__)("Suggestion view","bogo"),icon:s,onClick:()=>c({view:"suggestion"})}]})),(0,e.createElement)("div",(0,o.useBlockProps)({className:"components-placeholder",style:{minHeight:"100px",marginTop:"28px",marginBottom:"28px",paddingLeft:"28px"}}),(0,e.createElement)("label",{className:"components-placeholder__label"},(0,e.createElement)(l.Dashicon,{icon:"translation"}),(0,n.__)("Language Switcher","bogo")),"suggestion"===a.view?(0,e.createElement)((()=>(0,n.__)("This page is also available in XXX.","bogo")),null):(0,e.createElement)((()=>{var t,o;const n=Object.entries(null!==(t=null===(o=bogo)||void 0===o?void 0:o.availableLanguages)&&void 0!==t?t:{}).map((t=>{var o;let[n,l]=t;const a=(t=>{const o=["bogoflags",`bogoflags-${t=t?t.toLowerCase():"zz"}`];return(0,e.createElement)("span",{className:o.join(" ")})})(l.country);return(0,e.createElement)("li",{key:n,className:l.tags.join(" ")},bogo.showFlags&&a,(0,e.createElement)("span",{className:"bogo-language-name"},null!==(o=l.nativename)&&void 0!==o?o:n))}));return(0,e.createElement)("ul",{className:"bogo-language-switcher"},n)}),null)))},save:t=>{let{attributes:n}=t;const l=(e=>{let t="[bogo]";return"suggestion"===e.view&&(t=t.replace(/\]$/,` view="${e.view}"]`)),t})(n);return(0,e.createElement)("div",o.useBlockProps.save(),l)}})}(); \ No newline at end of file diff --git a/wp-content/plugins/bogo/includes/capabilities.php b/wp-content/plugins/bogo/includes/capabilities.php new file mode 100644 index 0000000000..26dc9c72a0 --- /dev/null +++ b/wp-content/plugins/bogo/includes/capabilities.php @@ -0,0 +1,51 @@ + 'install_languages', + 'bogo_edit_terms_translation' => 'manage_categories', + 'bogo_access_all_locales' => 'manage_options', + 'bogo_access_locale' => 'read', + ); + + $meta_caps = apply_filters( 'bogo_map_meta_cap', $meta_caps ); + + $caps = array_diff( $caps, array_keys( $meta_caps ) ); + + if ( isset( $meta_caps[$cap] ) ) { + $caps[] = $meta_caps[$cap]; + } + + static $accessible_locales = array(); + + if ( 'bogo_access_all_locales' !== $cap + and ! isset( $accessible_locales[$user_id] ) ) { + $accessible_locales[$user_id] = bogo_get_user_accessible_locales( + $user_id + ); + } + + if ( 'bogo_access_locale' === $cap + and ! user_can( $user_id, 'bogo_access_all_locales' ) ) { + $locale = $args[0]; + + if ( ! in_array( $locale, $accessible_locales[$user_id] ) ) { + $caps[] = 'do_not_allow'; + } + } + + if ( in_array( $cap, array( 'edit_post', 'delete_post' ), true ) + and $post = get_post( $args[0] ) + and $user_id !== $post->post_author + and ! user_can( $user_id, 'bogo_access_all_locales' ) ) { + $locale = bogo_get_post_locale( $post->ID ); + + if ( ! in_array( $locale, $accessible_locales[$user_id] ) ) { + $caps[] = 'do_not_allow'; + } + } + + return $caps; +} diff --git a/wp-content/plugins/bogo/includes/css/style-rtl.css b/wp-content/plugins/bogo/includes/css/style-rtl.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/wp-content/plugins/bogo/includes/css/style.css b/wp-content/plugins/bogo/includes/css/style.css new file mode 100644 index 0000000000..fb25ad1b3d --- /dev/null +++ b/wp-content/plugins/bogo/includes/css/style.css @@ -0,0 +1,1015 @@ +ul.bogo-language-switcher li { + list-style: none outside none; + padding: 0; +} + +#wpadminbar #wp-admin-bar-bogo-user-locale .ab-icon::before { + content: "\f326"; + top: 2px; +} + +/* National Flags */ + +.bogoflags, +.bogoflags-before:before { + display: inline-block; + width: 20px; + height: auto; + background-image: none; + background-color: transparent; + border: none; + padding: 0; + margin: 0 4px; + vertical-align: top; +} + +/* + * The following content properties use Unicode regional indicator symbols + * for national flags. + * + * https://en.wikipedia.org/wiki/Regional_indicator_symbol + */ + +.bogoflags-ad:before { + content: "\1F1E6\1F1E9"; +} + +.bogoflags-ae:before { + content: "\1F1E6\1F1EA"; +} + +.bogoflags-af:before { + content: "\1F1E6\1F1EB"; +} + +.bogoflags-ag:before { + content: "\1F1E6\1F1EC"; +} + +.bogoflags-ai:before { + content: "\1F1E6\1F1EE"; +} + +.bogoflags-al:before { + content: "\1F1E6\1F1F1"; +} + +.bogoflags-am:before { + content: "\1F1E6\1F1F2"; +} + +.bogoflags-an:before { + content: "\1F1E6\1F1F3"; +} + +.bogoflags-ao:before { + content: "\1F1E6\1F1F4"; +} + +.bogoflags-aq:before { + content: "\1F1E6\1F1F6"; +} + +.bogoflags-ar:before { + content: "\1F1E6\1F1F7"; +} + +.bogoflags-as:before { + content: "\1F1E6\1F1F8"; +} + +.bogoflags-at:before { + content: "\1F1E6\1F1F9"; +} + +.bogoflags-au:before { + content: "\1F1E6\1F1FA"; +} + +.bogoflags-aw:before { + content: "\1F1E6\1F1FC"; +} + +.bogoflags-ax:before { + content: "\1F1E6\1F1FD"; +} + +.bogoflags-az:before { + content: "\1F1E6\1F1FF"; +} + +.bogoflags-ba:before { + content: "\1F1E7\1F1E6"; +} + +.bogoflags-bb:before { + content: "\1F1E7\1F1E7"; +} + +.bogoflags-bd:before { + content: "\1F1E7\1F1E9"; +} + +.bogoflags-be:before { + content: "\1F1E7\1F1EA"; +} + +.bogoflags-bf:before { + content: "\1F1E7\1F1EB"; +} + +.bogoflags-bg:before { + content: "\1F1E7\1F1EC"; +} + +.bogoflags-bh:before { + content: "\1F1E7\1F1ED"; +} + +.bogoflags-bi:before { + content: "\1F1E7\1F1EE"; +} + +.bogoflags-bj:before { + content: "\1F1E7\1F1EF"; +} + +.bogoflags-bl:before { + content: "\1F1E7\1F1F1"; +} + +.bogoflags-bm:before { + content: "\1F1E7\1F1F2"; +} + +.bogoflags-bn:before { + content: "\1F1E7\1F1F3"; +} + +.bogoflags-bo:before { + content: "\1F1E7\1F1F4"; +} + +.bogoflags-br:before { + content: "\1F1E7\1F1F7"; +} + +.bogoflags-bs:before { + content: "\1F1E7\1F1F8"; +} + +.bogoflags-bt:before { + content: "\1F1E7\1F1F9"; +} + +.bogoflags-bv:before { + content: "\1F1E7\1F1FB"; +} + +.bogoflags-bw:before { + content: "\1F1E7\1F1FC"; +} + +.bogoflags-by:before { + content: "\1F1E7\1F1FE"; +} + +.bogoflags-bz:before { + content: "\1F1E7\1F1FF"; +} + +.bogoflags-ca:before { + content: "\1F1E8\1F1E6"; +} + +.bogoflags-cc:before { + content: "\1F1E8\1F1E8"; +} + +.bogoflags-cd:before { + content: "\1F1E8\1F1E9"; +} + +.bogoflags-cf:before { + content: "\1F1E8\1F1EB"; +} + +.bogoflags-cg:before { + content: "\1F1E8\1F1EC"; +} + +.bogoflags-ch:before { + content: "\1F1E8\1F1ED"; +} + +.bogoflags-ci:before { + content: "\1F1E8\1F1EE"; +} + +.bogoflags-ck:before { + content: "\1F1E8\1F1F0"; +} + +.bogoflags-cl:before { + content: "\1F1E8\1F1F1"; +} + +.bogoflags-cm:before { + content: "\1F1E8\1F1F2"; +} + +.bogoflags-cn:before { + content: "\1F1E8\1F1F3"; +} + +.bogoflags-co:before { + content: "\1F1E8\1F1F4"; +} + +.bogoflags-cr:before { + content: "\1F1E8\1F1F7"; +} + +.bogoflags-cu:before { + content: "\1F1E8\1F1FA"; +} + +.bogoflags-cv:before { + content: "\1F1E8\1F1FB"; +} + +.bogoflags-cx:before { + content: "\1F1E8\1F1FD"; +} + +.bogoflags-cy:before { + content: "\1F1E8\1F1FE"; +} + +.bogoflags-cz:before { + content: "\1F1E8\1F1FF"; +} + +.bogoflags-de:before { + content: "\1F1E9\1F1EA"; +} + +.bogoflags-dj:before { + content: "\1F1E9\1F1EF"; +} + +.bogoflags-dk:before { + content: "\1F1E9\1F1F0"; +} + +.bogoflags-dm:before { + content: "\1F1E9\1F1F2"; +} + +.bogoflags-do:before { + content: "\1F1E9\1F1F4"; +} + +.bogoflags-dz:before { + content: "\1F1E9\1F1FF"; +} + +.bogoflags-ec:before { + content: "\1F1EA\1F1E8"; +} + +.bogoflags-ee:before { + content: "\1F1EA\1F1EA"; +} + +.bogoflags-eg:before { + content: "\1F1EA\1F1EC"; +} + +.bogoflags-eh:before { + content: "\1F1EA\1F1ED"; +} + +.bogoflags-er:before { + content: "\1F1EA\1F1F7"; +} + +.bogoflags-es:before { + content: "\1F1EA\1F1F8"; +} + +.bogoflags-et:before { + content: "\1F1EA\1F1F9"; +} + +.bogoflags-fi:before { + content: "\1F1EB\1F1EE"; +} + +.bogoflags-fj:before { + content: "\1F1EB\1F1EF"; +} + +.bogoflags-fk:before { + content: "\1F1EB\1F1F0"; +} + +.bogoflags-fm:before { + content: "\1F1EB\1F1F2"; +} + +.bogoflags-fo:before { + content: "\1F1EB\1F1F4"; +} + +.bogoflags-fr:before { + content: "\1F1EB\1F1F7"; +} + +.bogoflags-ga:before { + content: "\1F1EC\1F1E6"; +} + +.bogoflags-gb:before { + content: "\1F1EC\1F1E7"; +} + +.bogoflags-gd:before { + content: "\1F1EC\1F1E9"; +} + +.bogoflags-ge:before { + content: "\1F1EC\1F1EA"; +} + +.bogoflags-gf:before { + content: "\1F1EC\1F1EB"; +} + +.bogoflags-gg:before { + content: "\1F1EC\1F1EC"; +} + +.bogoflags-gh:before { + content: "\1F1EC\1F1ED"; +} + +.bogoflags-gi:before { + content: "\1F1EC\1F1EE"; +} + +.bogoflags-gl:before { + content: "\1F1EC\1F1F1"; +} + +.bogoflags-gm:before { + content: "\1F1EC\1F1F2"; +} + +.bogoflags-gn:before { + content: "\1F1EC\1F1F3"; +} + +.bogoflags-gp:before { + content: "\1F1EC\1F1F5"; +} + +.bogoflags-gq:before { + content: "\1F1EC\1F1F6"; +} + +.bogoflags-gr:before { + content: "\1F1EC\1F1F7"; +} + +.bogoflags-gs:before { + content: "\1F1EC\1F1F8"; +} + +.bogoflags-gt:before { + content: "\1F1EC\1F1F9"; +} + +.bogoflags-gu:before { + content: "\1F1EC\1F1FA"; +} + +.bogoflags-gw:before { + content: "\1F1EC\1F1FC"; +} + +.bogoflags-gy:before { + content: "\1F1EC\1F1FE"; +} + +.bogoflags-hk:before { + content: "\1F1ED\1F1F0"; +} + +.bogoflags-hm:before { + content: "\1F1ED\1F1F2"; +} + +.bogoflags-hn:before { + content: "\1F1ED\1F1F3"; +} + +.bogoflags-hr:before { + content: "\1F1ED\1F1F7"; +} + +.bogoflags-ht:before { + content: "\1F1ED\1F1F9"; +} + +.bogoflags-hu:before { + content: "\1F1ED\1F1FA"; +} + +.bogoflags-id:before { + content: "\1F1EE\1F1E9"; +} + +.bogoflags-ie:before { + content: "\1F1EE\1F1EA"; +} + +.bogoflags-il:before { + content: "\1F1EE\1F1F1"; +} + +.bogoflags-im:before { + content: "\1F1EE\1F1F2"; +} + +.bogoflags-in:before { + content: "\1F1EE\1F1F3"; +} + +.bogoflags-io:before { + content: "\1F1EE\1F1F4"; +} + +.bogoflags-iq:before { + content: "\1F1EE\1F1F6"; +} + +.bogoflags-ir:before { + content: "\1F1EE\1F1F7"; +} + +.bogoflags-is:before { + content: "\1F1EE\1F1F8"; +} + +.bogoflags-it:before { + content: "\1F1EE\1F1F9"; +} + +.bogoflags-je:before { + content: "\1F1EF\1F1EA"; +} + +.bogoflags-jm:before { + content: "\1F1EF\1F1F2"; +} + +.bogoflags-jo:before { + content: "\1F1EF\1F1F4"; +} + +.bogoflags-jp:before { + content: "\1F1EF\1F1F5"; +} + +.bogoflags-ke:before { + content: "\1F1F0\1F1EA"; +} + +.bogoflags-kg:before { + content: "\1F1F0\1F1EC"; +} + +.bogoflags-kh:before { + content: "\1F1F0\1F1ED"; +} + +.bogoflags-ki:before { + content: "\1F1F0\1F1EE"; +} + +.bogoflags-km:before { + content: "\1F1F0\1F1F2"; +} + +.bogoflags-kn:before { + content: "\1F1F0\1F1F3"; +} + +.bogoflags-kp:before { + content: "\1F1F0\1F1F5"; +} + +.bogoflags-kr:before { + content: "\1F1F0\1F1F7"; +} + +.bogoflags-kw:before { + content: "\1F1F0\1F1FC"; +} + +.bogoflags-ky:before { + content: "\1F1F0\1F1FE"; +} + +.bogoflags-kz:before { + content: "\1F1F0\1F1FF"; +} + +.bogoflags-la:before { + content: "\1F1F1\1F1E6"; +} + +.bogoflags-lb:before { + content: "\1F1F1\1F1E7"; +} + +.bogoflags-lc:before { + content: "\1F1F1\1F1E8"; +} + +.bogoflags-li:before { + content: "\1F1F1\1F1EE"; +} + +.bogoflags-lk:before { + content: "\1F1F1\1F1F0"; +} + +.bogoflags-lr:before { + content: "\1F1F1\1F1F7"; +} + +.bogoflags-ls:before { + content: "\1F1F1\1F1F8"; +} + +.bogoflags-lt:before { + content: "\1F1F1\1F1F9"; +} + +.bogoflags-lu:before { + content: "\1F1F1\1F1FA"; +} + +.bogoflags-lv:before { + content: "\1F1F1\1F1FB"; +} + +.bogoflags-ly:before { + content: "\1F1F1\1F1FE"; +} + +.bogoflags-ma:before { + content: "\1F1F2\1F1E6"; +} + +.bogoflags-mc:before { + content: "\1F1F2\1F1E8"; +} + +.bogoflags-md:before { + content: "\1F1F2\1F1E9"; +} + +.bogoflags-me:before { + content: "\1F1F2\1F1EA"; +} + +.bogoflags-mf:before { + content: "\1F1F2\1F1EB"; +} + +.bogoflags-mg:before { + content: "\1F1F2\1F1EC"; +} + +.bogoflags-mh:before { + content: "\1F1F2\1F1ED"; +} + +.bogoflags-mk:before { + content: "\1F1F2\1F1F0"; +} + +.bogoflags-ml:before { + content: "\1F1F2\1F1F1"; +} + +.bogoflags-mm:before { + content: "\1F1F2\1F1F2"; +} + +.bogoflags-mn:before { + content: "\1F1F2\1F1F3"; +} + +.bogoflags-mo:before { + content: "\1F1F2\1F1F4"; +} + +.bogoflags-mp:before { + content: "\1F1F2\1F1F5"; +} + +.bogoflags-mq:before { + content: "\1F1F2\1F1F6"; +} + +.bogoflags-mr:before { + content: "\1F1F2\1F1F7"; +} + +.bogoflags-ms:before { + content: "\1F1F2\1F1F8"; +} + +.bogoflags-mt:before { + content: "\1F1F2\1F1F9"; +} + +.bogoflags-mu:before { + content: "\1F1F2\1F1FA"; +} + +.bogoflags-mv:before { + content: "\1F1F2\1F1FB"; +} + +.bogoflags-mw:before { + content: "\1F1F2\1F1FC"; +} + +.bogoflags-mx:before { + content: "\1F1F2\1F1FD"; +} + +.bogoflags-my:before { + content: "\1F1F2\1F1FE"; +} + +.bogoflags-mz:before { + content: "\1F1F2\1F1FF"; +} + +.bogoflags-na:before { + content: "\1F1F3\1F1E6"; +} + +.bogoflags-nc:before { + content: "\1F1F3\1F1E8"; +} + +.bogoflags-ne:before { + content: "\1F1F3\1F1EA"; +} + +.bogoflags-nf:before { + content: "\1F1F3\1F1EB"; +} + +.bogoflags-ng:before { + content: "\1F1F3\1F1EC"; +} + +.bogoflags-ni:before { + content: "\1F1F3\1F1EE"; +} + +.bogoflags-nl:before { + content: "\1F1F3\1F1F1"; +} + +.bogoflags-no:before { + content: "\1F1F3\1F1F4"; +} + +.bogoflags-np:before { + content: "\1F1F3\1F1F5"; +} + +.bogoflags-nr:before { + content: "\1F1F3\1F1F7"; +} + +.bogoflags-nu:before { + content: "\1F1F3\1F1FA"; +} + +.bogoflags-nz:before { + content: "\1F1F3\1F1FF"; +} + +.bogoflags-om:before { + content: "\1F1F4\1F1F2"; +} + +.bogoflags-pa:before { + content: "\1F1F5\1F1E6"; +} + +.bogoflags-pe:before { + content: "\1F1F5\1F1EA"; +} + +.bogoflags-pf:before { + content: "\1F1F5\1F1EB"; +} + +.bogoflags-pg:before { + content: "\1F1F5\1F1EC"; +} + +.bogoflags-ph:before { + content: "\1F1F5\1F1ED"; +} + +.bogoflags-pk:before { + content: "\1F1F5\1F1F0"; +} + +.bogoflags-pl:before { + content: "\1F1F5\1F1F1"; +} + +.bogoflags-pm:before { + content: "\1F1F5\1F1F2"; +} + +.bogoflags-pn:before { + content: "\1F1F5\1F1F3"; +} + +.bogoflags-pr:before { + content: "\1F1F5\1F1F7"; +} + +.bogoflags-ps:before { + content: "\1F1F5\1F1F8"; +} + +.bogoflags-pt:before { + content: "\1F1F5\1F1F9"; +} + +.bogoflags-pw:before { + content: "\1F1F5\1F1FC"; +} + +.bogoflags-py:before { + content: "\1F1F5\1F1FE"; +} + +.bogoflags-qa:before { + content: "\1F1F6\1F1E6"; +} + +.bogoflags-re:before { + content: "\1F1F7\1F1EA"; +} + +.bogoflags-ro:before { + content: "\1F1F7\1F1F4"; +} + +.bogoflags-rs:before { + content: "\1F1F7\1F1F8"; +} + +.bogoflags-ru:before { + content: "\1F1F7\1F1FA"; +} + +.bogoflags-rw:before { + content: "\1F1F7\1F1FC"; +} + +.bogoflags-sa:before { + content: "\1F1F8\1F1E6"; +} + +.bogoflags-sb:before { + content: "\1F1F8\1F1E7"; +} + +.bogoflags-sc:before { + content: "\1F1F8\1F1E8"; +} + +.bogoflags-sd:before { + content: "\1F1F8\1F1E9"; +} + +.bogoflags-se:before { + content: "\1F1F8\1F1EA"; +} + +.bogoflags-sg:before { + content: "\1F1F8\1F1EC"; +} + +.bogoflags-sh:before { + content: "\1F1F8\1F1ED"; +} + +.bogoflags-si:before { + content: "\1F1F8\1F1EE"; +} + +.bogoflags-sj:before { + content: "\1F1F8\1F1EF"; +} + +.bogoflags-sk:before { + content: "\1F1F8\1F1F0"; +} + +.bogoflags-sl:before { + content: "\1F1F8\1F1F1"; +} + +.bogoflags-sm:before { + content: "\1F1F8\1F1F2"; +} + +.bogoflags-sn:before { + content: "\1F1F8\1F1F3"; +} + +.bogoflags-so:before { + content: "\1F1F8\1F1F4"; +} + +.bogoflags-sr:before { + content: "\1F1F8\1F1F7"; +} + +.bogoflags-st:before { + content: "\1F1F8\1F1F9"; +} + +.bogoflags-sv:before { + content: "\1F1F8\1F1FB"; +} + +.bogoflags-sy:before { + content: "\1F1F8\1F1FE"; +} + +.bogoflags-sz:before { + content: "\1F1F8\1F1FF"; +} + +.bogoflags-tc:before { + content: "\1F1F9\1F1E8"; +} + +.bogoflags-td:before { + content: "\1F1F9\1F1E9"; +} + +.bogoflags-tf:before { + content: "\1F1F9\1F1EB"; +} + +.bogoflags-tg:before { + content: "\1F1F9\1F1EC"; +} + +.bogoflags-th:before { + content: "\1F1F9\1F1ED"; +} + +.bogoflags-tj:before { + content: "\1F1F9\1F1EF"; +} + +.bogoflags-tk:before { + content: "\1F1F9\1F1F0"; +} + +.bogoflags-tl:before { + content: "\1F1F9\1F1F1"; +} + +.bogoflags-tm:before { + content: "\1F1F9\1F1F2"; +} + +.bogoflags-tn:before { + content: "\1F1F9\1F1F3"; +} + +.bogoflags-to:before { + content: "\1F1F9\1F1F4"; +} + +.bogoflags-tr:before { + content: "\1F1F9\1F1F7"; +} + +.bogoflags-tt:before { + content: "\1F1F9\1F1F9"; +} + +.bogoflags-tv:before { + content: "\1F1F9\1F1FB"; +} + +.bogoflags-tw:before { + content: "\1F1F9\1F1FC"; +} + +.bogoflags-tz:before { + content: "\1F1F9\1F1FF"; +} + +.bogoflags-ua:before { + content: "\1F1FA\1F1E6"; +} + +.bogoflags-ug:before { + content: "\1F1FA\1F1EC"; +} + +.bogoflags-um:before { + content: "\1F1FA\1F1F2"; +} + +.bogoflags-us:before { + content: "\1F1FA\1F1F8"; +} + +.bogoflags-uy:before { + content: "\1F1FA\1F1FE"; +} + +.bogoflags-uz:before { + content: "\1F1FA\1F1FF"; +} + +.bogoflags-va:before { + content: "\1F1FB\1F1E6"; +} + +.bogoflags-vc:before { + content: "\1F1FB\1F1E8"; +} + +.bogoflags-ve:before { + content: "\1F1FB\1F1EA"; +} + +.bogoflags-vg:before { + content: "\1F1FB\1F1EC"; +} + +.bogoflags-vi:before { + content: "\1F1FB\1F1EE"; +} + +.bogoflags-vn:before { + content: "\1F1FB\1F1F3"; +} + +.bogoflags-vu:before { + content: "\1F1FB\1F1FA"; +} + +.bogoflags-wf:before { + content: "\1F1FC\1F1EB"; +} + +.bogoflags-ws:before { + content: "\1F1FC\1F1F8"; +} + +.bogoflags-ye:before { + content: "\1F1FE\1F1EA"; +} + +.bogoflags-yt:before { + content: "\1F1FE\1F1F9"; +} + +.bogoflags-za:before { + content: "\1F1FF\1F1E6"; +} + +.bogoflags-zm:before { + content: "\1F1FF\1F1F2"; +} + +.bogoflags-zw:before { + content: "\1F1FF\1F1FC"; +} diff --git a/wp-content/plugins/bogo/includes/flags.php b/wp-content/plugins/bogo/includes/flags.php new file mode 100644 index 0000000000..4c724aed8c --- /dev/null +++ b/wp-content/plugins/bogo/includes/flags.php @@ -0,0 +1,71 @@ +deprecated since Bogo version %2$s with no alternative available.', 'bogo' ), + __FUNCTION__, + '3.7' + ), + E_USER_DEPRECATED + ); + } + + $locale = explode( '_', $locale ); + $locale = array_slice( $locale, 0, 2 ); // de_DE_formal => de_DE + $locale = implode( '_', $locale ); + + $special_cases = array( + 'ca' => 'catalonia', + 'gd' => 'scotland', + 'cy' => 'wales', + 'am' => 'et', + 'az' => 'az', + 'bel' => 'by', + 'bs' => 'ba', + 'dzo' => 'bt', + 'el' => 'gr', + 'et' => 'ee', + 'fi' => 'fi', + 'ga' => 'ie', + 'hr' => 'hr', + 'ht' => 'ht', + 'hy' => 'am', + 'ja' => 'jp', + 'kk' => 'kz', + 'km' => 'kh', + 'lo' => 'la', + 'lv' => 'lv', + 'mn' => 'mn', + 'sq' => 'al', + 'tg' => 'tj', + 'th' => 'th', + 'tl' => 'ph', + 'uk' => 'ua', + 'vi' => 'vn', + ); + + if ( isset( $special_cases[$locale] ) ) { + $file = $special_cases[$locale] . '.png'; + } elseif ( preg_match( '/_([A-Z]{2})$/', $locale, $matches ) ) { + $file = strtolower( $matches[1] ) . '.png'; + } else { + $file = 'zz.png'; // 'zz.png' doesn't exist, just a dummy. + } + + $file = path_join( 'images/flag-icons', $file ); + $url = ''; + + if ( file_exists( path_join( BOGO_PLUGIN_DIR, $file ) ) ) { + $url = bogo_plugin_url( $file ); + } + + return apply_filters( 'bogo_get_flag', $url, $locale ); +} diff --git a/wp-content/plugins/bogo/includes/formatting.php b/wp-content/plugins/bogo/includes/formatting.php new file mode 100644 index 0000000000..7ee62fb07a --- /dev/null +++ b/wp-content/plugins/bogo/includes/formatting.php @@ -0,0 +1,47 @@ + $value ) { + $name = strtolower( trim( $name ) ); + + if ( ! preg_match( '/^[a-z_:][a-z_:.0-9-]*$/', $name ) ) { + continue; + } + + static $boolean_attributes = array( + 'checked', 'disabled', 'multiple', 'readonly', 'required', 'selected', + ); + + if ( in_array( $name, $boolean_attributes ) and '' === $value ) { + $value = false; + } + + if ( is_numeric( $value ) ) { + $value = (string) $value; + } + + if ( null === $value or false === $value ) { + unset( $atts_filtered[$name] ); + } elseif ( true === $value ) { + $atts_filtered[$name] = $name; // boolean attribute + } elseif ( is_string( $value ) ) { + $atts_filtered[$name] = trim( $value ); + } + } + + $output = ''; + + foreach ( $atts_filtered as $name => $value ) { + $output .= sprintf( ' %1$s="%2$s"', $name, esc_attr( $value ) ); + } + + return trim( $output ); +} diff --git a/wp-content/plugins/bogo/includes/functions.php b/wp-content/plugins/bogo/includes/functions.php new file mode 100644 index 0000000000..f5190f165e --- /dev/null +++ b/wp-content/plugins/bogo/includes/functions.php @@ -0,0 +1,47 @@ + __( 'Afrikaans', 'bogo' ), + 'am' => __( 'Amharic', 'bogo' ), + 'ar' => __( 'Arabic', 'bogo' ), + 'arg' => __( 'Aragonese', 'bogo' ), + 'ary' => __( 'Moroccan Arabic', 'bogo' ), + 'as' => __( 'Assamese', 'bogo' ), + 'az' => __( 'Azerbaijani', 'bogo' ), + 'azb' => __( 'South Azerbaijani', 'bogo' ), + 'bel' => __( 'Belarusian', 'bogo' ), + 'bg_BG' => __( 'Bulgarian', 'bogo' ), + 'bn_BD' => __( 'Bengali (Bangladesh)', 'bogo' ), + 'bo' => __( 'Tibetan', 'bogo' ), + 'bs_BA' => __( 'Bosnian', 'bogo' ), + 'ca' => __( 'Catalan', 'bogo' ), + 'ceb' => __( 'Cebuano', 'bogo' ), + 'ckb' => __( 'Kurdish (Sorani)', 'bogo' ), + 'cs_CZ' => __( 'Czech', 'bogo' ), + 'cy' => __( 'Welsh', 'bogo' ), + 'da_DK' => __( 'Danish', 'bogo' ), + 'de_AT' => __( 'German (Austria)', 'bogo' ), + 'de_CH' => __( 'German (Switzerland)', 'bogo' ), + 'de_CH_informal' => __( 'German (Switzerland, Informal)', 'bogo' ), + 'de_DE' => __( 'German', 'bogo' ), + 'de_DE_formal' => __( 'German (Formal)', 'bogo' ), + 'dsb' => __( 'Lower Sorbian', 'bogo' ), + 'dzo' => __( 'Dzongkha', 'bogo' ), + 'el' => __( 'Greek', 'bogo' ), + 'en_AU' => __( 'English (Australia)', 'bogo' ), + 'en_CA' => __( 'English (Canada)', 'bogo' ), + 'en_GB' => __( 'English (UK)', 'bogo' ), + 'en_NZ' => __( 'English (New Zealand)', 'bogo' ), + 'en_US' => __( 'English (United States)', 'bogo' ), + 'en_ZA' => __( 'English (South Africa)', 'bogo' ), + 'eo' => __( 'Esperanto', 'bogo' ), + 'es_AR' => __( 'Spanish (Argentina)', 'bogo' ), + 'es_CL' => __( 'Spanish (Chile)', 'bogo' ), + 'es_CO' => __( 'Spanish (Colombia)', 'bogo' ), + 'es_CR' => __( 'Spanish (Costa Rica)', 'bogo' ), + 'es_DO' => __( 'Spanish (Dominican Republic)', 'bogo' ), + 'es_EC' => __( 'Spanish (Ecuador)', 'bogo' ), + 'es_ES' => __( 'Spanish (Spain)', 'bogo' ), + 'es_GT' => __( 'Spanish (Guatemala)', 'bogo' ), + 'es_MX' => __( 'Spanish (Mexico)', 'bogo' ), + 'es_PE' => __( 'Spanish (Peru)', 'bogo' ), + 'es_PR' => __( 'Spanish (Puerto Rico)', 'bogo' ), + 'es_UY' => __( 'Spanish (Uruguay)', 'bogo' ), + 'es_VE' => __( 'Spanish (Venezuela)', 'bogo' ), + 'et' => __( 'Estonian', 'bogo' ), + 'eu' => __( 'Basque', 'bogo' ), + 'fa_AF' => __( 'Persian (Afghanistan)', 'bogo' ), + 'fa_IR' => __( 'Persian', 'bogo' ), + 'fi' => __( 'Finnish', 'bogo' ), + 'fr_BE' => __( 'French (Belgium)', 'bogo' ), + 'fr_CA' => __( 'French (Canada)', 'bogo' ), + 'fr_FR' => __( 'French (France)', 'bogo' ), + 'fur' => __( 'Friulian', 'bogo' ), + 'fy' => __( 'Frisian', 'bogo' ), + 'gd' => __( 'Scottish Gaelic', 'bogo' ), + 'gl_ES' => __( 'Galician', 'bogo' ), + 'gu' => __( 'Gujarati', 'bogo' ), + 'haz' => __( 'Hazaragi', 'bogo' ), + 'he_IL' => __( 'Hebrew', 'bogo' ), + 'hi_IN' => __( 'Hindi', 'bogo' ), + 'hr' => __( 'Croatian', 'bogo' ), + 'hsb' => __( 'Upper Sorbian', 'bogo' ), + 'hu_HU' => __( 'Hungarian', 'bogo' ), + 'hy' => __( 'Armenian', 'bogo' ), + 'id_ID' => __( 'Indonesian', 'bogo' ), + 'is_IS' => __( 'Icelandic', 'bogo' ), + 'it_IT' => __( 'Italian', 'bogo' ), + 'ja' => __( 'Japanese', 'bogo' ), + 'jv_ID' => __( 'Javanese', 'bogo' ), + 'ka_GE' => __( 'Georgian', 'bogo' ), + 'kab' => __( 'Kabyle', 'bogo' ), + 'kk' => __( 'Kazakh', 'bogo' ), + 'km' => __( 'Khmer', 'bogo' ), + 'kn' => __( 'Kannada', 'bogo' ), + 'ko_KR' => __( 'Korean', 'bogo' ), + 'lo' => __( 'Lao', 'bogo' ), + 'lt_LT' => __( 'Lithuanian', 'bogo' ), + 'lv' => __( 'Latvian', 'bogo' ), + 'mk_MK' => __( 'Macedonian', 'bogo' ), + 'ml_IN' => __( 'Malayalam', 'bogo' ), + 'mn' => __( 'Mongolian', 'bogo' ), + 'mr' => __( 'Marathi', 'bogo' ), + 'ms_MY' => __( 'Malay', 'bogo' ), + 'my_MM' => __( 'Myanmar (Burmese)', 'bogo' ), + 'nb_NO' => __( 'Norwegian (Bokmål)', 'bogo' ), + 'ne_NP' => __( 'Nepali', 'bogo' ), + 'nl_BE' => __( 'Dutch (Belgium)', 'bogo' ), + 'nl_NL' => __( 'Dutch', 'bogo' ), + 'nl_NL_formal' => __( 'Dutch (Formal)', 'bogo' ), + 'nn_NO' => __( 'Norwegian (Nynorsk)', 'bogo' ), + 'oci' => __( 'Occitan', 'bogo' ), + 'pa_IN' => __( 'Panjabi (India)', 'bogo' ), + 'pl_PL' => __( 'Polish', 'bogo' ), + 'ps' => __( 'Pashto', 'bogo' ), + 'pt_AO' => __( 'Portuguese (Angola)', 'bogo' ), + 'pt_BR' => __( 'Portuguese (Brazil)', 'bogo' ), + 'pt_PT' => __( 'Portuguese (Portugal)', 'bogo' ), + 'pt_PT_ao90' => __( 'Portuguese (Portugal, AO90)', 'bogo' ), + 'rhg' => __( 'Rohingya', 'bogo' ), + 'ro_RO' => __( 'Romanian', 'bogo' ), + 'ru_RU' => __( 'Russian', 'bogo' ), + 'sah' => __( 'Sakha', 'bogo' ), + 'si_LK' => __( 'Sinhala', 'bogo' ), + 'sk_SK' => __( 'Slovak', 'bogo' ), + 'skr' => __( 'Saraiki', 'bogo' ), + 'sl_SI' => __( 'Slovenian', 'bogo' ), + 'snd' => __( 'Sindhi', 'bogo' ), + 'sq' => __( 'Albanian', 'bogo' ), + 'sr_RS' => __( 'Serbian', 'bogo' ), + 'sv_SE' => __( 'Swedish', 'bogo' ), + 'sw' => __( 'Swahili', 'bogo' ), + 'szl' => __( 'Silesian', 'bogo' ), + 'ta_IN' => __( 'Tamil', 'bogo' ), + 'ta_LK' => __( 'Tamil (Sri Lanka)', 'bogo' ), + 'tah' => __( 'Tahitian', 'bogo' ), + 'te' => __( 'Telugu', 'bogo' ), + 'th' => __( 'Thai', 'bogo' ), + 'tl' => __( 'Tagalog', 'bogo' ), + 'tr_TR' => __( 'Turkish', 'bogo' ), + 'tt_RU' => __( 'Tatar', 'bogo' ), + 'ug_CN' => __( 'Uighur', 'bogo' ), + 'uk' => __( 'Ukrainian', 'bogo' ), + 'ur' => __( 'Urdu', 'bogo' ), + 'uz_UZ' => __( 'Uzbek', 'bogo' ), + 'vi' => __( 'Vietnamese', 'bogo' ), + 'zh_CN' => __( 'Chinese (China)', 'bogo' ), + 'zh_HK' => __( 'Chinese (Hong Kong)', 'bogo' ), + 'zh_TW' => __( 'Chinese (Taiwan)', 'bogo' ), + ); + + $textdomain_loaded = is_textdomain_loaded( 'bogo' ) && ! is_locale_switched(); + + asort( $languages, SORT_STRING ); + + return apply_filters( 'bogo_languages', $languages ); +} + + +/** + * Returns the language name corresponding to the specified locale code. + * + * @param string $locale Locale code. + */ +function bogo_get_language( $locale ) { + $languages = bogo_languages(); + + if ( isset( $languages[$locale] ) ) { + $language = $languages[$locale]; + } else { + $language = false; + } + + return apply_filters( 'bogo_get_language', $language, $locale ); +} + + +/** + * Returns the language native name corresponding to the specified locale code. + * + * @link http://api.wordpress.org/translations/core/1.0/ + * + * @param string $locale Locale code. + */ +function bogo_get_language_native_name( $locale ) { + $native_names = array( + 'af' => 'Afrikaans', + 'am' => 'አማርኛ', + 'ar' => 'العربية', + 'arg' => 'Aragonés', + 'ary' => 'العربية المغربية', + 'as' => 'অসমীয়া', + 'az' => 'Azərbaycan dili', + 'azb' => 'گؤنئی آذربایجان', + 'bel' => 'Беларуская мова', + 'bg_BG' => 'Български', + 'bn_BD' => 'বাংলা', + 'bo' => 'བོད་ཡིག', + 'bs_BA' => 'Bosanski', + 'ca' => 'Català', + 'ceb' => 'Cebuano', + 'ckb' => 'كوردی‎', + 'cs_CZ' => 'Čeština', + 'cy' => 'Cymraeg', + 'da_DK' => 'Dansk', + 'de_AT' => 'Deutsch (Österreich)', + 'de_CH' => 'Deutsch (Schweiz)', + 'de_CH_informal' => 'Deutsch (Schweiz, Du)', + 'de_DE' => 'Deutsch', + 'de_DE_formal' => 'Deutsch (Sie)', + 'dsb' => 'Dolnoserbšćina', + 'dzo' => 'རྫོང་ཁ', + 'el' => 'Ελληνικά', + 'en_AU' => 'English (Australia)', + 'en_CA' => 'English (Canada)', + 'en_GB' => 'English (UK)', + 'en_NZ' => 'English (New Zealand)', + 'en_US' => 'English (United States)', + 'en_ZA' => 'English (South Africa)', + 'eo' => 'Esperanto', + 'es_AR' => 'Español de Argentina', + 'es_CL' => 'Español de Chile', + 'es_CO' => 'Español de Colombia', + 'es_CR' => 'Español de Costa Rica', + 'es_DO' => 'Español de República Dominicana', + 'es_EC' => 'Español de Ecuador', + 'es_ES' => 'Español', + 'es_GT' => 'Español de Guatemala', + 'es_MX' => 'Español de México', + 'es_PE' => 'Español de Perú', + 'es_PR' => 'Español de Puerto Rico', + 'es_UY' => 'Español de Uruguay', + 'es_VE' => 'Español de Venezuela', + 'et' => 'Eesti', + 'eu' => 'Euskara', + 'fa_AF' => '(فارسی (افغانستان', + 'fa_IR' => 'فارسی', + 'fi' => 'Suomi', + 'fr_BE' => 'Français de Belgique', + 'fr_CA' => 'Français du Canada', + 'fr_FR' => 'Français', + 'fur' => 'Friulian', + 'fy' => 'Frysk', + 'gd' => 'Gàidhlig', + 'gl_ES' => 'Galego', + 'gu' => 'ગુજરાતી', + 'haz' => 'هزاره گی', + 'he_IL' => 'עִבְרִית', + 'hi_IN' => 'हिन्दी', + 'hr' => 'Hrvatski', + 'hsb' => 'Hornjoserbšćina', + 'hu_HU' => 'Magyar', + 'hy' => 'Հայերեն', + 'id_ID' => 'Bahasa Indonesia', + 'is_IS' => 'Íslenska', + 'it_IT' => 'Italiano', + 'ja' => '日本語', + 'jv_ID' => 'Basa Jawa', + 'ka_GE' => 'ქართული', + 'kab' => 'Taqbaylit', + 'kk' => 'Қазақ тілі', + 'km' => 'ភាសាខ្មែរ', + 'kn' => 'ಕನ್ನಡ', + 'ko_KR' => '한국어', + 'lo' => 'ພາສາລາວ', + 'lt_LT' => 'Lietuvių kalba', + 'lv' => 'Latviešu valoda', + 'mk_MK' => 'Македонски јазик', + 'ml_IN' => 'മലയാളം', + 'mn' => 'Монгол', + 'mr' => 'मराठी', + 'ms_MY' => 'Bahasa Melayu', + 'my_MM' => 'ဗမာစာ', + 'nb_NO' => 'Norsk bokmål', + 'ne_NP' => 'नेपाली', + 'nl_BE' => 'Nederlands (België)', + 'nl_NL' => 'Nederlands', + 'nl_NL_formal' => 'Nederlands (Formeel)', + 'nn_NO' => 'Norsk nynorsk', + 'oci' => 'Occitan', + 'pa_IN' => 'ਪੰਜਾਬੀ', + 'pl_PL' => 'Polski', + 'ps' => 'پښتو', + 'pt_AO' => 'Português de Angola', + 'pt_BR' => 'Português do Brasil', + 'pt_PT' => 'Português', + 'pt_PT_ao90' => 'Português (AO90)', + 'rhg' => 'Ruáinga', + 'ro_RO' => 'Română', + 'ru_RU' => 'Русский', + 'sah' => 'Сахалыы', + 'si_LK' => 'සිංහල', + 'sk_SK' => 'Slovenčina', + 'skr' => 'سرائیکی', + 'sl_SI' => 'Slovenščina', + 'snd' => 'سنڌي', + 'sq' => 'Shqip', + 'sr_RS' => 'Српски језик', + 'sv_SE' => 'Svenska', + 'sw' => 'Kiswahili', + 'szl' => 'Ślōnskŏ gŏdka', + 'ta_IN' => 'தமிழ்', + 'ta_LK' => 'தமிழ்', + 'tah' => 'Reo Tahiti', + 'te' => 'తెలుగు', + 'th' => 'ไทย', + 'tl' => 'Tagalog', + 'tr_TR' => 'Türkçe', + 'tt_RU' => 'Татар теле', + 'ug_CN' => 'ئۇيغۇرچە', + 'uk' => 'Українська', + 'ur' => 'اردو', + 'uz_UZ' => 'O‘zbekcha', + 'vi' => 'Tiếng Việt', + 'zh_CN' => '简体中文', + 'zh_HK' => '香港中文', + 'zh_TW' => '繁體中文', + ); + + if ( isset( $native_names[$locale] ) ) { + $native_name = $native_names[$locale]; + } else { + $native_name = false; + } + + return apply_filters( 'bogo_get_language_native_name', + $native_name, $locale + ); +} + + +/** + * Returns the ISO 3166-1 alpha-2 country code corresponding to + * the specified locale code. + * + * @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + * + * @param string $locale Locale code. + */ +function bogo_get_country_code( $locale ) { + $special_cases = array( + 'am' => 'ET', // Amharic => Ethiopia + 'ary' => 'MA', // Moroccan Arabic => Morocco + 'az' => 'AZ', // Azerbaijani => Azerbaijan + 'bel' => 'BY', // Belarusian => Belarus + 'dzo' => 'BT', // Dzongkha => Bhutan + 'el' => 'GR', // Greek => Greece + 'et' => 'EE', // Estonian => Estonia + 'fi' => 'FI', // Finnish => Finland + 'hr' => 'HR', // Croatian => Croatia + 'hy' => 'AM', // Armenian => Armenia + 'ja' => 'JP', // Japanese => Japan + 'kk' => 'KZ', // Kazakh => Kazakhstan + 'km' => 'KH', // Khmer => Cambodia + 'lo' => 'LA', // Lao => Laos + 'lv' => 'LV', // Latvian => Latvia + 'mn' => 'MN', // Mongolian => Mongolia + 'ps' => 'AF', // Pashto => Afghanistan + 'sq' => 'AL', // Albanian => Albania + 'th' => 'TH', // Thai => Thailand + 'tl' => 'PH', // Tagalog => Philippines + 'uk' => 'UA', // Ukrainian => Ukraine + 'ur' => 'PK', // Urdu => Pakistan + 'vi' => 'VN', // Vietnamese => Vietnam + ); + + if ( preg_match( '/^[a-z]+_([A-Z]{2})/', $locale, $matches ) ) { + $country_code = $matches[1]; + } elseif ( isset( $special_cases[$locale] ) ) { + $country_code = $special_cases[$locale]; + } else { + $country_code = false; + } + + return apply_filters( 'bogo_get_country_code', $country_code, $locale ); +} + + +/** + * Retrieves the default locale for the site. + */ +function bogo_get_default_locale() { + static $locale = ''; + + if ( ! empty( $locale ) ) { + return $locale; + } + + if ( defined( 'WPLANG' ) ) { + $locale = WPLANG; + } + + if ( is_multisite() ) { + if ( wp_installing() + or false === $ms_locale = get_option( 'WPLANG' ) ) { + $ms_locale = get_site_option( 'WPLANG' ); + } + + if ( $ms_locale !== false ) { + $locale = $ms_locale; + } + } else { + $db_locale = get_option( 'WPLANG' ); + + if ( $db_locale !== false ) { + $locale = $db_locale; + } + } + + if ( ! empty( $locale ) ) { + return $locale; + } + + return 'en_US'; +} + + +/** + * Returns true if the specified locale is the default locale. + * + * @param string $locale Locale code. + */ +function bogo_is_default_locale( $locale ) { + $default_locale = bogo_get_default_locale(); + + return ! empty( $locale ) && $locale == bogo_get_default_locale(); +} + + +/** + * Returns true if the en_US locale is deactivated on this site. + */ +function bogo_is_enus_deactivated() { + if ( bogo_is_default_locale( 'en_US' ) ) { + return false; + } + + return (bool) bogo_get_prop( 'enus_deactivated' ); +} + + +/** + * Retrieves locale codes active on this site. + */ +function bogo_available_locales( $args = '' ) { + $defaults = array( + 'exclude' => array(), + 'exclude_enus_if_inactive' => true, + 'current_user_can_access' => false, + ); + + $args = wp_parse_args( $args, $defaults ); + + static $installed_locales = array(); + + if ( empty( $installed_locales ) ) { + $installed_locales = get_available_languages(); + $installed_locales[] = bogo_get_default_locale(); + $installed_locales[] = 'en_US'; + } + + $available_locales = $installed_locales; + + if ( $args['current_user_can_access'] + and ! current_user_can( 'bogo_access_all_locales' ) ) { + $user_accessible_locales = bogo_get_user_accessible_locales( + get_current_user_id() + ); + + $available_locales = array_intersect( + $available_locales, + $user_accessible_locales + ); + } + + if ( ! empty( $args['exclude'] ) ) { + $available_locales = array_diff( + $available_locales, + (array) $args['exclude'] + ); + } + + if ( $args['exclude_enus_if_inactive'] + and bogo_is_enus_deactivated() ) { + $available_locales = array_diff( + $available_locales, + array( 'en_US' ) + ); + } + + return array_unique( array_filter( $available_locales ) ); +} + + +/** + * Retrieves languages active on this site. + */ +function bogo_available_languages( $args = '' ) { + $defaults = array( + 'exclude' => array(), + 'orderby' => 'key', + 'order' => 'ASC', + 'exclude_enus_if_inactive' => true, + 'current_user_can_access' => false, + 'short_name' => true, + ); + + $args = wp_parse_args( $args, $defaults ); + + $langs = array(); + + $available_locales = bogo_available_locales( $args ); + + foreach ( $available_locales as $locale ) { + $lang = (string) bogo_get_language( $locale ); + + if ( $args['short_name'] and bogo_locale_is_alone( $locale ) ) { + $lang = bogo_get_short_name( $lang ); + } + + $lang = trim( $lang ); + $langs[$locale] = empty( $lang ) ? "[$locale]" : $lang; + } + + if ( 'value' == $args['orderby'] ) { + natcasesort( $langs ); + + if ( 'DESC' == $args['order'] ) { + $langs = array_reverse( $langs ); + } + } else { + if ( 'DESC' == $args['order'] ) { + krsort( $langs ); + } else { + ksort( $langs ); + } + } + + $langs = apply_filters( 'bogo_available_languages', $langs, $args ); + + return $langs; +} + + +/** + * Returns true if the specified locale is active on this site. + * + * @param string $locale Locale code. + */ +function bogo_is_available_locale( $locale ) { + if ( empty( $locale ) ) { + return false; + } + + static $available_locales = array(); + + if ( empty( $available_locales ) ) { + $available_locales = bogo_available_locales(); + } + + return in_array( $locale, $available_locales ); +} + + +/** + * Filters locales list. + */ +function bogo_filter_locales( $locales, $filter = 'available' ) { + return array_intersect( (array) $locales, bogo_available_locales() ); +} + + +/** + * Retrieves the language tag for the specified locale. + * + * @link https://www.ietf.org/rfc/bcp/bcp47.txt + * + * @param string $locale Locale code. + */ +function bogo_language_tag( $locale ) { + $tag = preg_replace( '/[^0-9a-zA-Z]+/', '-', $locale ); + $tag = trim( $tag, '-' ); + + $tag = explode( '-', $tag ); + $tag = array_slice( $tag, 0, 2 ); // de-DE-formal => de-DE + $tag = implode( '-', $tag ); + + return apply_filters( 'bogo_language_tag', $tag, $locale ); +} + + +/** + * Retrieves the language slug for the specified locale. + * + * @param string $locale Locale code. + */ +function bogo_lang_slug( $locale ) { + $tag = bogo_language_tag( $locale ); + $slug = $tag; + + if ( false !== $pos = strpos( $tag, '-' ) ) { + $slug = substr( $tag, 0, $pos ); + } + + $variations = preg_grep( '/^' . $slug . '/', + bogo_available_locales() + ); + + if ( 1 < count( $variations ) ) { + $slug = $tag; + } + + return apply_filters( 'bogo_lang_slug', $slug, $locale ); +} + + +/** + * Returns true if the specified locale has no sibling active on this site. + * + * @param string $locale Locale code. + */ +function bogo_locale_is_alone( $locale ) { + $tag = bogo_language_tag( $locale ); + + if ( false === strpos( $tag, '-' ) ) { + return true; + } + + $slug = bogo_lang_slug( $locale ); + + return strlen( $slug ) < strlen( $tag ); +} + + +/** + * Retrieves the short version of the specified language name. + */ +function bogo_get_short_name( $orig_name ) { + $short_name = $orig_name = (string) $orig_name; + + $langs_with_variants = array( + '中文', + 'Français', + 'Português', + 'Español', + ); + + foreach ( $langs_with_variants as $lang ) { + if ( false !== strpos( $orig_name, $lang ) ) { + $short_name = $lang; + break; + } + } + + if ( preg_match( '/^([^()]+)/', $short_name, $matches ) ) { + $short_name = $matches[1]; + } + + $short_name = apply_filters( 'bogo_get_short_name', $short_name, $orig_name ); + + return trim( $short_name ); +} + + +/** + * Retrieves the regular expression pattern that matches + * all available language slugs on this site. + */ +function bogo_get_lang_regex() { + $langs = array_map( 'bogo_lang_slug', bogo_available_locales() ); + $langs = array_filter( $langs ); + + if ( empty( $langs ) ) { + return ''; + } + + return '(' . implode( '|', $langs ) . ')'; +} + + +/** + * Retrieves the locale that is active on this site and + * closest to the specified locale. + * + * @param string $locale_orig Locale code. + * @return string|bool Locale code. False if there is no close locale. + */ +function bogo_get_closest_locale( $locale_orig ) { + $locale_orig = strtolower( $locale_orig ); + $locale_pattern = '/^([a-z]{2,3})(?:[_-]([a-z]{2})(?:[_-]([a-z0-9]+))?)?$/'; + + if ( ! preg_match( $locale_pattern, $locale_orig, $matches ) ) { + return false; + } + + $language_code = $matches[1]; + $region_code = isset( $matches[2] ) ? $matches[2] : ''; + $variant_code = isset( $matches[3] ) ? $matches[3] : ''; + + $locales = bogo_available_locales(); + + if ( $variant_code and $region_code ) { + $locale = $language_code + . '_' . strtoupper( $region_code ) + . '_' . $variant_code; + + if ( false !== array_search( $locale, $locales ) ) { + return $locale; + } + } + + if ( $region_code ) { + $locale = $language_code + . '_' . strtoupper( $region_code ); + + if ( false !== array_search( $locale, $locales ) ) { + return $locale; + } + } + + $locale = $language_code; + + if ( false !== array_search( $locale, $locales ) ) { + return $locale; + } + + if ( $matches = preg_grep( "/^{$locale}_/", $locales ) ) { + return array_shift( $matches ); + } + + return false; +} + + +/** + * Returns an ordered list of language tags based on the client + * language preference. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language + */ +function bogo_http_accept_languages() { + if ( ! isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { + return false; + } + + $languages = array(); + + foreach ( explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) as $lang ) { + $lang = trim( strtolower( $lang ) ); + + if ( preg_match( '/^([a-z-]+)(?:;q=([0-9.]+))?$/', $lang, $matches ) ) { + $language_tag = $matches[1]; + $qvalue = isset( $matches[2] ) ? 0 + $matches[2] : 1; + + if ( preg_match( '/^([a-z]{2})(?:-([a-z]{2}))?$/', $language_tag, $matches ) ) { + $language_tag = $matches[1]; + + if ( isset( $matches[2] ) ) { + $language_tag .= '_' . strtoupper( $matches[2] ); + } + + $languages[$language_tag] = $qvalue; + } + } + } + + natsort( $languages ); + + return array_reverse( array_keys( $languages ) ); +} + + +/** + * A wrapper function of bogo_get_url_with_lang(). + */ +function bogo_url( $url = '', $locale = '' ) { + if ( ! $locale ) { + $locale = determine_locale(); + } + + $args = array( + 'using_permalinks' => (bool) get_option( 'permalink_structure' ), + ); + + return bogo_get_url_with_lang( $url, $locale, $args ); +} + + +/** + * Returns a URL that is a different language version of the original URL. + * + * @param string $url The original URL. + * @param string $locale Locale code. + * @param string|array $args Options. + * @return string The result URL. + */ +function bogo_get_url_with_lang( $url = '', $locale = '', $args = '' ) { + global $wp_rewrite; + + $defaults = array( + 'using_permalinks' => true, + ); + + $args = wp_parse_args( $args, $defaults ); + + if ( ! $url ) { + if ( ! $url = redirect_canonical( $url, false ) ) { + $url = is_ssl() ? 'https://' : 'http://'; + $url .= $_SERVER['HTTP_HOST']; + $url .= $_SERVER['REQUEST_URI']; + } + + if ( $frag = strstr( $url, '#' ) ) { + $url = substr( $url, 0, - strlen( $frag ) ); + } + + if ( $query = wp_parse_url( $url, PHP_URL_QUERY ) ) { + parse_str( $query, $query_vars ); + + foreach ( array_keys( $query_vars ) as $qv ) { + if ( ! get_query_var( $qv ) ) { + $url = remove_query_arg( $qv, $url ); + } + } + } + } + + $default_locale = bogo_get_default_locale(); + + if ( ! $locale ) { + $locale = $default_locale; + } + + $use_implicit_lang = apply_filters( 'bogo_use_implicit_lang', true ); + + $lang_slug = ( $use_implicit_lang && $locale === $default_locale ) + ? '' + : bogo_lang_slug( $locale ); + + $url = remove_query_arg( 'lang', $url ); + + if ( ! $args['using_permalinks'] ) { + if ( $lang_slug ) { + $url = add_query_arg( array( 'lang' => $lang_slug ), $url ); + } + + return $url; + } + + $tail_slashed = ( '/' === substr( $url, -1 ) ); + + $home = set_url_scheme( get_option( 'home' ) ); + $home = untrailingslashit( $home ); + + if ( $wp_rewrite->using_index_permalinks() ) { + $pattern = '#^' + . preg_quote( $home ) + . '(?:/' . preg_quote( $wp_rewrite->index ) . ')?' + . '(?:/' . bogo_get_lang_regex() . '(?![0-9A-Za-z%_-]))?' + . '#'; + + $replacement = $home . '/' . $wp_rewrite->index; + + if ( $lang_slug ) { + $replacement .= '/' . $lang_slug; + } + + $url = preg_replace( + $pattern, + $replacement, + $url + ); + + $url = preg_replace( + '#' . preg_quote( $wp_rewrite->index ) . '/?$#', + '', + $url + ); + + } else { + $pattern = '#^' + . preg_quote( $home ) + . '(?:/' . bogo_get_lang_regex() . '(?![0-9A-Za-z%_-]))?' + . '#'; + + $replacement = $home; + + if ( $lang_slug ) { + $replacement .= '/' . $lang_slug; + } + + $url = preg_replace( + $pattern, + $replacement, + $url + ); + } + + if ( ! $tail_slashed ) { + $url = untrailingslashit( $url ); + } + + return $url; +} + + +/** + * Determines the language from the specified URL. + * + * @param string $url URL. + */ +function bogo_get_lang_from_url( $url = '' ) { + if ( ! $url ) { + $url = is_ssl() ? 'https://' : 'http://'; + $url .= $_SERVER['HTTP_HOST']; + $url .= $_SERVER['REQUEST_URI']; + } + + if ( $frag = strstr( $url, '#' ) ) { + $url = substr( $url, 0, - strlen( $frag ) ); + } + + $home = set_url_scheme( get_option( 'home' ) ); + $home = trailingslashit( $home ); + + $available_languages = array_map( 'bogo_lang_slug', + bogo_available_locales() + ); + + $regex = '#^' + . preg_quote( $home ) + . '(' . implode( '|', $available_languages ) . ')' + . '/#'; + + if ( preg_match( $regex, trailingslashit( $url ), $matches ) ) { + return $matches[1]; + } + + if ( $query = wp_parse_url( $url, PHP_URL_QUERY ) ) { + parse_str( $query, $query_vars ); + + if ( isset( $query_vars['lang'] ) + and in_array( $query_vars['lang'], $available_languages ) ) { + return $query_vars['lang']; + } + } + + return false; +} diff --git a/wp-content/plugins/bogo/includes/language-switcher.php b/wp-content/plugins/bogo/includes/language-switcher.php new file mode 100644 index 0000000000..6cc2df6924 --- /dev/null +++ b/wp-content/plugins/bogo/includes/language-switcher.php @@ -0,0 +1,223 @@ + false, + ) ); + + $links = bogo_language_switcher_links( $args ); + $total = count( $links ); + $count = 0; + + $output = ''; + + foreach ( $links as $link ) { + $count += 1; + $class = array(); + $class[] = bogo_language_tag( $link['locale'] ); + $class[] = bogo_lang_slug( $link['locale'] ); + + if ( get_locale() === $link['locale'] ) { + $class[] = 'current'; + } + + if ( 1 == $count ) { + $class[] = 'first'; + } + + if ( $total == $count ) { + $class[] = 'last'; + } + + $class = implode( ' ', array_unique( $class ) ); + + $label = $link['native_name'] ? $link['native_name'] : $link['title']; + $title = $link['title']; + + if ( empty( $link['href'] ) ) { + $li = esc_html( $label ); + } else { + $atts = array( + 'rel' => 'alternate', + 'hreflang' => $link['lang'], + 'href' => esc_url( $link['href'] ), + 'title' => $title, + ); + + if ( get_locale() === $link['locale'] ) { + $atts += array( + 'class' => 'current', + 'aria-current' => 'page', + ); + } + + $li = sprintf( + '%2$s', + bogo_format_atts( $atts ), + esc_html( $label ) + ); + } + + $li = sprintf( + '%s', + $li + ); + + if ( apply_filters( 'bogo_use_flags', true ) ) { + $country_code = bogo_get_country_code( $link['locale'] ); + + $flag = sprintf( + '', + $country_code ? strtolower( $country_code ) : 'zz' + ); + + $li = sprintf( '
  • %3$s %2$s
  • ', $class, $li, $flag ); + } else { + $li = sprintf( '
  • %2$s
  • ', $class, $li ); + } + + $output .= $li . "\n"; + } + + $output = sprintf( + '', + $output + ); + + $output = apply_filters( 'bogo_language_switcher', $output, $args ); + + if ( $args['echo'] ) { + echo $output; + } else { + return $output; + } +} + + +function bogo_language_suggestion( $args = '' ) { + $args = wp_parse_args( $args, array( + 'echo' => false, + ) ); + + $locale_to_suggest = false; + + foreach ( bogo_http_accept_languages() as $locale ) { + $locale = bogo_get_closest_locale( $locale ); + + // A locale is available and it is not the current locale. + if ( $locale and $locale !== determine_locale() ) { + $locale_to_suggest = $locale; + break; + } + } + + $translations = array(); + + if ( $locale_to_suggest ) { + $translations = array_filter( + bogo_language_switcher_links( $args ), + function ( $link ) use ( $locale_to_suggest ) { + return $link['locale'] === $locale_to_suggest && '' !== $link['href']; + } + ); + } + + $output = ''; + + if ( $translations and $translation = reset( $translations ) ) { + switch_to_locale( $locale_to_suggest ); + + $lang_name = bogo_get_language( $locale_to_suggest ); + + if ( $lang_name ) { + $lang_name = bogo_get_short_name( $lang_name ); + } else { + $lang_name = sprintf( '[%s]', $locale_to_suggest ); + } + + $link = sprintf( + '%2$s', + bogo_format_atts( array( + 'rel' => 'alternate', + 'hreflang' => $translation['lang'], + 'href' => $translation['href'], + 'title' => $translation['title'], + ) ), + esc_html( $lang_name ) + ); + + $output = sprintf( + /* translators: %s: Language name */ + esc_html( __( "This page is also available in %s.", 'bogo' ) ), + $link + ); + + $output = sprintf( + '

    %s

    ', + $output + ); + + restore_previous_locale(); + } + + $output = apply_filters( 'bogo_language_suggestion', $output, $args ); + + if ( $args['echo'] ) { + echo $output; + } else { + return $output; + } +} + + +function bogo_language_switcher_links( $args = '' ) { + global $wp_query; + + $args = wp_parse_args( $args, array() ); + + $locale = get_locale(); + + $available_languages = bogo_available_languages(); + + $translations = array(); + $is_singular = false; + + if ( is_singular() + or ! empty( $wp_query->is_posts_page ) ) { + $translations = bogo_get_post_translations( get_queried_object_id() ); + $is_singular = true; + } + + $links = array(); + + foreach ( $available_languages as $code => $name ) { + $native_name = bogo_get_language_native_name( $code ); + + if ( bogo_locale_is_alone( $code ) ) { + $native_name = bogo_get_short_name( $native_name ); + } + + $link = array( + 'locale' => $code, + 'lang' => bogo_language_tag( $code ), + 'title' => $name, + 'native_name' => trim( $native_name ), + 'href' => '', + ); + + if ( $is_singular ) { + if ( $locale === $code ) { + $link['href'] = get_permalink( get_queried_object_id() ); + } elseif ( ! empty( $translations[$code] ) + and 'publish' == get_post_status( $translations[$code] ) ) { + $link['href'] = get_permalink( $translations[$code] ); + } + } else { + $link['href'] = bogo_url( null, $code ); + } + + $links[] = $link; + } + + return apply_filters( 'bogo_language_switcher_links', $links, $args ); +} diff --git a/wp-content/plugins/bogo/includes/link-template.php b/wp-content/plugins/bogo/includes/link-template.php new file mode 100644 index 0000000000..4053cf7f38 --- /dev/null +++ b/wp-content/plugins/bogo/includes/link-template.php @@ -0,0 +1,244 @@ +post_type ) ) { + return $permalink; + } + + $locale = bogo_get_post_locale( $post->ID ); + $sample = ( isset( $post->filter ) && 'sample' == $post->filter ); + $permalink_structure = get_option( 'permalink_structure' ); + + $using_permalinks = $permalink_structure && + ( $sample || ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ); + + $permalink = bogo_get_url_with_lang( $permalink, $locale, + array( 'using_permalinks' => $using_permalinks ) + ); + + return $permalink; +} + +add_filter( 'page_link', 'bogo_page_link', 10, 3 ); + +function bogo_page_link( $permalink, $post_id, $sample ) { + if ( ! bogo_is_localizable_post_type( 'page' ) ) { + return $permalink; + } + + $locale = bogo_get_post_locale( $post_id ); + $post = get_post( $post_id ); + + if ( 'page' == get_option( 'show_on_front' ) ) { + $front_page_id = get_option( 'page_on_front' ); + + if ( $post_id == $front_page_id ) { + return $permalink; + } + + $translation = bogo_get_post_translation( $front_page_id, $locale ); + + if ( $translation and $translation->ID === $post_id ) { + $home = set_url_scheme( get_option( 'home' ) ); + $home = trailingslashit( $home ); + return bogo_url( $home, $locale ); + } + } + + $permalink_structure = get_option( 'permalink_structure' ); + + $using_permalinks = $permalink_structure && + ( $sample || ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ); + + $permalink = bogo_get_url_with_lang( $permalink, $locale, + array( 'using_permalinks' => $using_permalinks ) + ); + + return $permalink; +} + +add_filter( 'post_type_link', 'bogo_post_type_link', 10, 4 ); + +function bogo_post_type_link( $permalink, $post, $leavename, $sample ) { + if ( ! bogo_is_localizable_post_type( $post->post_type ) ) { + return $permalink; + } + + $locale = bogo_get_post_locale( $post->ID ); + $permalink_structure = get_option( 'permalink_structure' ); + + $using_permalinks = $permalink_structure && + ( $sample || ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ); + + $permalink = bogo_get_url_with_lang( $permalink, $locale, + array( 'using_permalinks' => $using_permalinks ) + ); + + return $permalink; +} + +add_filter( 'year_link', 'bogo_year_link', 10, 2 ); + +function bogo_year_link( $link, $year ) { + return bogo_url( $link ); +} + +add_filter( 'month_link', 'bogo_month_link', 10, 3 ); + +function bogo_month_link( $link, $year, $month ) { + return bogo_url( $link ); +} + +add_filter( 'day_link', 'bogo_day_link', 10, 4 ); + +function bogo_day_link( $link, $year, $month, $day ) { + return bogo_url( $link ); +} + +add_filter( 'feed_link', 'bogo_feed_link', 10, 2 ); + +function bogo_feed_link( $link, $feed ) { + return bogo_url( $link ); +} + +add_filter( 'author_feed_link', 'bogo_author_feed_link', 10, 2 ); + +function bogo_author_feed_link( $link, $feed ) { + return bogo_url( $link ); +} + +add_filter( 'category_feed_link', 'bogo_category_feed_link', 10, 2 ); + +function bogo_category_feed_link( $link, $feed ) { + return bogo_url( $link ); +} + +add_filter( 'taxonomy_feed_link', 'bogo_taxonomy_feed_link', 10, 3 ); + +function bogo_taxonomy_feed_link( $link, $feed, $taxonomy ) { + return bogo_url( $link ); +} + +add_filter( 'post_type_archive_link', 'bogo_post_type_archive_link', 10, 2 ); + +function bogo_post_type_archive_link( $link, $post_type ) { + return bogo_url( $link ); +} + +add_filter( 'post_type_archive_feed_link', + 'bogo_post_type_archive_feed_link', + 10, 2 +); + +function bogo_post_type_archive_feed_link( $link, $feed ) { + return bogo_url( $link ); +} + +add_filter( 'term_link', 'bogo_term_link', 10, 3 ); + +function bogo_term_link( $link, $term, $taxonomy ) { + return bogo_url( $link ); +} + +add_filter( 'home_url', 'bogo_home_url', 10, 1 ); + +function bogo_home_url( $url ) { + if ( is_admin() + or ! did_action( 'template_redirect' ) ) { + return $url; + } + + return bogo_url( $url ); +} + +add_action( 'wp_head', 'bogo_m17n_headers', 10, 0 ); + +function bogo_m17n_headers() { + $languages = array(); + + if ( is_singular() ) { + $post_id = get_queried_object_id(); + + if ( $post_id + and $translations = bogo_get_post_translations( $post_id ) ) { + $locale = get_locale(); + $translations[$locale] = get_post( $post_id ); + + foreach ( $translations as $lang => $translation ) { + $languages[] = array( + 'hreflang' => bogo_language_tag( $lang ), + 'href' => get_permalink( $translation ), + ); + } + } + } else { + $available_locales = bogo_available_locales(); + + foreach ( $available_locales as $locale ) { + $languages[] = array( + 'hreflang' => bogo_language_tag( $locale ), + 'href' => bogo_url( null, $locale ), + ); + } + } + + $languages = apply_filters( 'bogo_rel_alternate_hreflang', $languages ); + + foreach ( (array) $languages as $language ) { + $hreflang = isset( $language['hreflang'] ) ? $language['hreflang'] : ''; + $href = isset( $language['href'] ) ? $language['href'] : ''; + + if ( $hreflang and $href ) { + $link = sprintf( + '', + esc_attr( $hreflang ), + esc_url( $href ) + ); + + echo $link . "\n"; + } + } +} + +add_filter( 'get_previous_post_join', 'bogo_adjacent_post_join', 10, 3 ); +add_filter( 'get_next_post_join', 'bogo_adjacent_post_join', 10, 3 ); + +function bogo_adjacent_post_join( $join, $in_same_term, $excluded_terms ) { + global $wpdb; + + $post = get_post(); + + if ( $post + and bogo_is_localizable_post_type( get_post_type( $post ) ) ) { + $join .= " LEFT JOIN $wpdb->postmeta AS postmeta_bogo ON (p.ID = postmeta_bogo.post_id AND postmeta_bogo.meta_key = '_locale')"; + } + + return $join; +} + +add_filter( 'get_previous_post_where', 'bogo_adjacent_post_where', 10, 3 ); +add_filter( 'get_next_post_where', 'bogo_adjacent_post_where', 10, 3 ); + +function bogo_adjacent_post_where( $where, $in_same_term, $excluded_terms ) { + global $wpdb; + + $post = get_post(); + + if ( $post + and bogo_is_localizable_post_type( get_post_type( $post ) ) ) { + $locale = bogo_get_post_locale( $post->ID ); + + $where .= " AND (1=0"; + $where .= $wpdb->prepare( " OR postmeta_bogo.meta_value LIKE %s", $locale ); + + if ( bogo_is_default_locale( $locale ) ) { + $where .= " OR postmeta_bogo.meta_id IS NULL"; + } + + $where .= ")"; + } + + return $where; +} diff --git a/wp-content/plugins/bogo/includes/nav-menu.php b/wp-content/plugins/bogo/includes/nav-menu.php new file mode 100644 index 0000000000..a2fb66bb8f --- /dev/null +++ b/wp-content/plugins/bogo/includes/nav-menu.php @@ -0,0 +1,42 @@ + $item ) { + if ( ! in_array( $locale, $item->bogo_locales ) ) { + unset( $items[$key] ); + } + } + + return $items; +} + +add_filter( 'wp_setup_nav_menu_item', 'bogo_setup_nav_menu_item', 10, 1 ); + +function bogo_setup_nav_menu_item( $menu_item ) { + if ( isset( $menu_item->bogo_locales ) ) { + return $menu_item; + } + + $menu_item->bogo_locales = array(); + + if ( isset( $menu_item->post_type ) + and 'nav_menu_item' == $menu_item->post_type ) { + $menu_item->bogo_locales = get_post_meta( $menu_item->ID, '_locale' ); + } + + if ( $menu_item->bogo_locales ) { + $menu_item->bogo_locales = bogo_filter_locales( $menu_item->bogo_locales ); + } else { + $menu_item->bogo_locales = bogo_available_locales(); + } + + return $menu_item; +} diff --git a/wp-content/plugins/bogo/includes/pomo.php b/wp-content/plugins/bogo/includes/pomo.php new file mode 100644 index 0000000000..690c98f391 --- /dev/null +++ b/wp-content/plugins/bogo/includes/pomo.php @@ -0,0 +1,162 @@ +name = bogo_translate( + sprintf( '%s:%d', $term->taxonomy, $term->term_id ), + $term->taxonomy, + $term->name + ); + + return $term; +} + +function bogo_translate( $singular, $context = '', $default = '' ) { + return Bogo_POMO::translate( $singular, $context, $default ); +} + +class Bogo_POMO { + + private static $mo; + + public static function translate( $singular, $context = '', $default = '' ) { + if ( ! self::$mo ) { + return '' !== $default ? $default : $singular; + } + + $translated = self::$mo->translate( $singular, $context ); + + if ( $translated == $singular + and '' !== $default ) { + return $default; + } else { + return $translated; + } + } + + public static function export( $locale, $entries = array() ) { + if ( ! bogo_is_available_locale( $locale ) ) { + return false; + } + + $dir = self::dir(); + + $revision_date = new DateTimeImmutable(); + + $headers = array( + 'PO-Revision-Date' => $revision_date->format( 'Y-m-d H:i:s' ) . '+0000', + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8', + 'Content-Transfer-Encoding' => '8bit', + 'X-Generator' => sprintf( 'Bogo %s', BOGO_VERSION ), + 'Language' => $locale, + 'Project-Id-Version' => + sprintf( 'WordPress %s', get_bloginfo( 'version' ) ), + ); + + require_once ABSPATH . WPINC . '/pomo/po.php'; + $po = new PO(); + $po->set_headers( $headers ); + + foreach ( (array) $entries as $entry ) { + $entry = new Translation_Entry( $entry ); + $po->add_entry( $entry ); + } + + $po_file = is_multisite() + ? sprintf( '%d-%s.po', get_current_blog_id(), $locale ) + : sprintf( '%s.po', $locale ); + $po_file = path_join( $dir, $po_file ); + $po->export_to_file( $po_file ); + + $mo = new MO(); + $mo->set_headers( $headers ); + + foreach ( (array) $entries as $entry ) { + $entry = new Translation_Entry( $entry ); + $mo->add_entry( $entry ); + } + + $mo_file = is_multisite() + ? sprintf( '%d-%s.mo', get_current_blog_id(), $locale ) + : sprintf( '%s.mo', $locale ); + $mo_file = path_join( $dir, $mo_file ); + return $mo->export_to_file( $mo_file ); + } + + public static function import( $locale ) { + if ( ! bogo_is_available_locale( $locale ) ) { + return false; + } + + $dir = self::dir(); + + $mo_file = is_multisite() + ? sprintf( '%d-%s.mo', get_current_blog_id(), $locale ) + : sprintf( '%s.mo', $locale ); + $mo_file = path_join( $dir, $mo_file ); + + if ( ! is_readable( $mo_file ) ) { + return false; + } + + $mo = new MO(); + + if ( ! $mo->import_from_file( $mo_file ) ) { + return false; + } + + self::$mo = $mo; + return true; + } + + public static function reset() { + self::$mo = null; + } + + public static function is_ready() { + return (bool) self::$mo; + } + + private static function dir() { + $dir = path_join( WP_LANG_DIR, 'bogo' ); + $dir = apply_filters( 'bogo_pomo_dir', $dir ); + wp_mkdir_p( $dir ); + return $dir; + } +} diff --git a/wp-content/plugins/bogo/includes/post.php b/wp-content/plugins/bogo/includes/post.php new file mode 100644 index 0000000000..89f79eaa1f --- /dev/null +++ b/wp-content/plugins/bogo/includes/post.php @@ -0,0 +1,660 @@ + 'string', + 'single' => true, + 'auth_callback' => $auth_callback, + 'show_in_rest' => true, + ) + ); + + register_post_meta( $post_type, + '_original_post', + array( + 'type' => 'string', + 'single' => true, + 'auth_callback' => $auth_callback, + 'show_in_rest' => true, + ) + ); + } + }, + + 10, 0 +); + +/* Post Template */ + +add_filter( 'body_class', 'bogo_body_class', 10, 2 ); + +function bogo_body_class( $classes, $classes_to_add ) { + $locale = bogo_language_tag( get_locale() ); + $locale = esc_attr( $locale ); + + if ( $locale and ! in_array( $locale, $classes ) ) { + $classes[] = $locale; + } + + return $classes; +} + +add_filter( 'post_class', 'bogo_post_class', 10, 3 ); + +function bogo_post_class( $classes, $classes_to_add, $post_id ) { + $locale = bogo_get_post_locale( $post_id ); + $locale = bogo_language_tag( $locale ); + $locale = esc_attr( $locale ); + + if ( $locale and ! in_array( $locale, $classes ) ) { + $classes[] = $locale; + } + + return $classes; +} + +function bogo_get_post_locale( $post_id ) { + $locale = get_post_meta( $post_id, '_locale', true ); + + if ( empty( $locale ) ) { + $locale = bogo_get_default_locale(); + } + + return $locale; +} + +function bogo_localizable_post_types() { + $localizable = apply_filters( 'bogo_localizable_post_types', + array( 'post', 'page' ) + ); + + $localizable = array_diff( + $localizable, + array( 'attachment', 'revision', 'nav_menu_item' ) + ); + + return $localizable; +} + +function bogo_is_localizable_post_type( $post_type ) { + return ! empty( $post_type ) && in_array( $post_type, bogo_localizable_post_types() ); +} + +function bogo_count_posts( $locale, $post_type = 'post' ) { + global $wpdb; + + if ( ! bogo_is_available_locale( $locale ) + or ! bogo_is_localizable_post_type( $post_type ) ) { + return false; + } + + $q = "SELECT COUNT(1) FROM $wpdb->posts"; + $q .= " LEFT JOIN $wpdb->postmeta ON ID = $wpdb->postmeta.post_id AND meta_key = '_locale'"; + $q .= " WHERE 1=1"; + $q .= $wpdb->prepare( " AND post_type = %s", $post_type ); + $q .= " AND post_status = 'publish'"; + $q .= " AND (1=0"; + $q .= $wpdb->prepare( " OR meta_value LIKE %s", $locale ); + $q .= bogo_is_default_locale( $locale ) ? " OR meta_id IS NULL" : ""; + $q .= ")"; + + return (int) $wpdb->get_var( $q ); +} + +function bogo_get_post_translations( $post_id = 0 ) { + $post = get_post( $post_id ); + + if ( ! $post ) { + return false; + } + + static $translations = array(); + + if ( isset( $translations[$post->ID] ) ) { + return $translations[$post->ID]; + } + + $original_post = get_post_meta( $post->ID, '_original_post', true ); + + // For back-compat + if ( empty( $original_post ) ) { + $original_post = $post->ID; + } + + $args = array( + 'bogo_suppress_locale_query' => true, + 'posts_per_page' => -1, + 'post_status' => 'any', + 'post_type' => $post->post_type, + 'meta_key' => '_original_post', + 'meta_value' => $original_post, + ); + + $q = new WP_Query(); + $posts = $q->query( $args ); + + // For back-compat + if ( is_int( $original_post ) + and $p = get_post( $original_post ) + and 'trash' !== get_post_status( $p ) ) { + array_unshift( $posts, $p ); + } + + $translations[$post->ID] = array(); + + foreach ( $posts as $p ) { + if ( $p->ID === $post->ID ) { + continue; + } + + $locale = bogo_get_post_locale( $p->ID ); + + if ( ! bogo_is_available_locale( $locale ) ) { + continue; + } + + if ( ! isset( $translations[$post->ID][$locale] ) ) { + $translations[$post->ID][$locale] = $p; + } + } + + $translations[$post->ID] = array_filter( $translations[$post->ID] ); + + return $translations[$post->ID]; +} + +function bogo_get_post_translation( $post_id, $locale ) { + $translations = bogo_get_post_translations( $post_id ); + + if ( isset( $translations[$locale] ) ) { + return $translations[$locale]; + } + + return false; +} + +function bogo_get_page_by_path( $page_path, $locale = null, $post_type = 'page' ) { + global $wpdb; + + if ( ! bogo_is_available_locale( $locale ) ) { + $locale = bogo_get_default_locale(); + } + + $page_path = rawurlencode( urldecode( $page_path ) ); + $page_path = str_replace( '%2F', '/', $page_path ); + $page_path = str_replace( '%20', ' ', $page_path ); + + $parts = explode( '/', trim( $page_path, '/' ) ); + $parts = array_map( 'esc_sql', $parts ); + $parts = array_map( 'sanitize_title_for_query', $parts ); + + $in_string = "'" . implode( "','", $parts ) . "'"; + $post_type_sql = $post_type; + $wpdb->escape_by_ref( $post_type_sql ); + + $q = "SELECT ID, post_name, post_parent FROM $wpdb->posts"; + $q .= " LEFT JOIN $wpdb->postmeta ON ID = $wpdb->postmeta.post_id AND meta_key = '_locale'"; + $q .= " WHERE 1=1"; + $q .= " AND post_name IN ($in_string)"; + $q .= " AND (post_type = '$post_type_sql' OR post_type = 'attachment')"; + $q .= " AND (1=0"; + $q .= $wpdb->prepare( " OR meta_value LIKE %s", $locale ); + $q .= bogo_is_default_locale( $locale ) ? " OR meta_id IS NULL" : ""; + $q .= ")"; + + $pages = $wpdb->get_results( $q, OBJECT_K ); + + $revparts = array_reverse( $parts ); + + $foundid = 0; + + foreach ( (array) $pages as $page ) { + if ( $page->post_name !== $revparts[0] ) { + continue; + } + + $count = 0; + $p = $page; + + while ( $p->post_parent != 0 + and isset( $pages[$p->post_parent] ) ) { + $count++; + $parent = $pages[$p->post_parent]; + + if ( ! isset( $revparts[$count] ) + or $parent->post_name !== $revparts[$count] ) { + break; + } + + $p = $parent; + } + + if ( $p->post_parent == 0 + and $count + 1 == count( $revparts ) + and $p->post_name === $revparts[$count] ) { + $foundid = $page->ID; + break; + } + } + + if ( $foundid ) { + return get_page( $foundid ); + } + + return null; +} + +function bogo_duplicate_post( $original_post, $locale ) { + $original_post = get_post( $original_post ); + + if ( ! $original_post + or ! bogo_is_localizable_post_type( get_post_type( $original_post ) ) + or 'auto-draft' == get_post_status( $original_post ) ) { + return false; + } + + if ( ! bogo_is_available_locale( $locale ) + or bogo_get_post_locale( $original_post->ID ) == $locale ) { + return false; + } + + if ( bogo_get_post_translation( $original_post->ID, $locale ) ) { + return false; + } + + $postarr = array( + 'post_content' => $original_post->post_content, + 'post_title' => $original_post->post_title, + 'post_name' => $original_post->post_name, + 'post_excerpt' => $original_post->post_excerpt, + 'post_status' => 'draft', + 'post_type' => $original_post->post_type, + 'comment_status' => $original_post->comment_status, + 'ping_status' => $original_post->ping_status, + 'post_password' => $original_post->post_password, + 'post_content_filtered' => $original_post->post_content_filtered, + 'post_parent' => $original_post->post_parent, + 'menu_order' => $original_post->menu_order, + 'post_mime_type' => $original_post->post_mime_type, + 'tax_input' => array(), + 'meta_input' => array(), + ); + + if ( ! empty( $original_post->post_parent ) ) { + $parent_translation = bogo_get_post_translation( + $original_post->post_parent, $locale + ); + + if ( $parent_translation ) { + $postarr['post_parent'] = $parent_translation->ID; + } + } + + if ( $taxonomies = get_object_taxonomies( $original_post ) ) { + foreach ( $taxonomies as $taxonomy ) { + $terms = wp_get_post_terms( $original_post->ID, + $taxonomy, array( 'fields' => 'ids' ) + ); + + if ( $terms and ! is_wp_error( $terms ) ) { + $postarr['tax_input'][$taxonomy] = $terms; + } + } + } + + if ( $post_metas = get_post_meta( $original_post->ID ) ) { + + $post_metas = array_map( function ( $post_meta ) { + return array_map( 'maybe_unserialize', (array) $post_meta ); + }, $post_metas ); + + $postarr['meta_input'] = $post_metas; + } + + $postarr = apply_filters( 'bogo_duplicate_post', $postarr, + $original_post, $locale + ); + + if ( $taxonomies = $postarr['tax_input'] ) { + $postarr['tax_input'] = array(); + } + + if ( $post_metas = $postarr['meta_input'] ) { + $postarr['meta_input'] = array(); + } + + $new_post_id = wp_insert_post( $postarr ); + + if ( $new_post_id ) { + if ( $taxonomies ) { + foreach ( $taxonomies as $taxonomy => $terms ) { + wp_set_post_terms( $new_post_id, $terms, $taxonomy ); + } + } + + if ( $post_metas ) { + foreach ( $post_metas as $meta_key => $meta_values ) { + if ( in_array( $meta_key, array( '_locale', '_original_post' ) ) ) { + continue; + } + + foreach ( (array) $meta_values as $meta_value ) { + add_post_meta( $new_post_id, $meta_key, $meta_value ); + } + } + } + + update_post_meta( $new_post_id, '_locale', $locale ); + + $meta_original_post = get_post_meta( $original_post->ID, + '_original_post', true + ); + + if ( $meta_original_post ) { + update_post_meta( $new_post_id, + '_original_post', $meta_original_post + ); + } else { + $original_post_guid = get_the_guid( $original_post ); + + if ( empty( $original_post_guid ) ) { + $original_post_guid = $original_post->ID; + } + + $translations = bogo_get_post_translations( $original_post ); + + update_post_meta( $original_post->ID, + '_original_post', $original_post_guid + ); + + if ( $translations ) { + foreach ( $translations as $tr_locale => $tr_post ) { + update_post_meta( $tr_post->ID, + '_original_post', $original_post_guid + ); + } + } + + update_post_meta( $new_post_id, + '_original_post', $original_post_guid + ); + } + } + + return $new_post_id; +} + +add_filter( 'get_pages', 'bogo_get_pages', 10, 2 ); + +function bogo_get_pages( $pages, $args ) { + if ( is_admin() + or ! bogo_is_localizable_post_type( $args['post_type'] ) + or ! empty( $args['bogo_suppress_locale_query'] ) ) { + return $pages; + } + + $locale = isset( $args['lang'] ) ? $args['lang'] : get_locale(); + + if ( ! bogo_is_available_locale( $locale ) ) { + return $pages; + } + + $new_pages = array(); + + foreach ( (array) $pages as $page ) { + $post_locale = bogo_get_post_locale( $page->ID ); + + if ( $post_locale == $locale ) { + $new_pages[] = $page; + } + } + + return $new_pages; +} + +add_action( 'save_post', 'bogo_save_post', 10, 2 ); + +function bogo_save_post( $post_id, $post ) { + if ( did_action( 'import_start' ) + and ! did_action( 'import_end' ) ) { + // Importing + return; + } + + if ( ! bogo_is_localizable_post_type( $post->post_type ) ) { + return; + } + + $current_locales = get_post_meta( $post_id, '_locale' ); + $locale = null; + + if ( ! empty( $current_locales ) ) { + foreach ( $current_locales as $current_locale ) { + if ( bogo_is_available_locale( $current_locale ) ) { + $locale = $current_locale; + break; + } + } + + if ( empty( $locale ) + or 1 < count( $current_locales ) ) { + delete_post_meta( $post_id, '_locale' ); + $current_locales = array(); + } + } + + if ( empty( $current_locales ) ) { + if ( bogo_is_available_locale( $locale ) ) { + // $locale = $locale; + } elseif ( ! empty( $_REQUEST['locale'] ) + and bogo_is_available_locale( $_REQUEST['locale'] ) ) { + $locale = $_REQUEST['locale']; + } elseif ( 'auto-draft' == get_post_status( $post_id ) ) { + $locale = bogo_get_user_locale(); + } else { + $locale = bogo_get_default_locale(); + } + + add_post_meta( $post_id, '_locale', $locale, true ); + } + + $original_post = get_post_meta( $post_id, '_original_post', true ); + + if ( empty( $original_post ) ) { + $post_guid = get_the_guid( $post_id ); + + if ( empty( $post_guid ) ) { + $post_guid = $post_id; + } + + $translations = bogo_get_post_translations( $post_id ); + + update_post_meta( $post_id, '_original_post', $post_guid ); + + if ( $translations ) { + foreach ( $translations as $tr_locale => $tr_post ) { + update_post_meta( $tr_post->ID, '_original_post', $post_guid ); + } + } + } +} + +add_filter( 'pre_wp_unique_post_slug', 'bogo_unique_post_slug', 10, 6 ); + +function bogo_unique_post_slug( $override_slug, $slug, $post_id, $post_status, $post_type, $post_parent ) { + + if ( ! bogo_is_localizable_post_type( $post_type ) ) { + return $override_slug; + } + + $locale = bogo_get_post_locale( $post_id ); + + if ( ! bogo_is_available_locale( $locale ) ) { + return $override_slug; + } + + $override_slug = $slug; + + $q = new WP_Query(); + + global $wp_rewrite; + + $feeds = is_array( $wp_rewrite->feeds ) ? $wp_rewrite->feeds : array(); + + if ( is_post_type_hierarchical( $post_type ) ) { + $q_args = array( + 'name' => $slug, + 'lang' => $locale, + 'post_type' => array( $post_type, 'attachment' ), + 'post_parent' => $post_parent, + 'post__not_in' => array( $post_id ), + 'posts_per_page' => 1, + ); + + $is_bad_slug = in_array( $slug, $feeds ) + || 'embed' === $slug + || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) + || apply_filters( + 'wp_unique_post_slug_is_bad_hierarchical_slug', false, + $slug, $post_type, $post_parent + ); + + if ( ! $is_bad_slug ) { + $q_results = $q->query( $q_args ); + $is_bad_slug = ! empty( $q_results ); + } + + if ( $is_bad_slug ) { + $suffix = 1; + + while ( $is_bad_slug ) { + $suffix += 1; + $alt_slug = sprintf( '%s-%s', + bogo_truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ), + $suffix + ); + + $q_results = $q->query( array_merge( + $q_args, + array( 'name' => $alt_slug ) + ) ); + + $is_bad_slug = ! empty( $q_results ); + } + + $override_slug = $alt_slug; + } + + } else { + $q_args = array( + 'name' => $slug, + 'lang' => $locale, + 'post_type' => $post_type, + 'post__not_in' => array( $post_id ), + 'posts_per_page' => 1, + ); + + $is_bad_slug = in_array( $slug, $feeds ) + || 'embed' === $slug + || apply_filters( + 'wp_unique_post_slug_is_bad_flat_slug', false, + $slug, $post_type + ); + + if ( ! $is_bad_slug ) { + $post = get_post( $post_id ); + + if ( 'post' === $post_type + and ( ! $post or $post->post_name !== $slug ) + and preg_match( '/^[0-9]+$/', $slug ) ) { + $slug_num = intval( $slug ); + + if ( $slug_num ) { + $permastructs = array_values( array_filter( + explode( '/', get_option( 'permalink_structure' ) ) + ) ); + $postname_index = array_search( '%postname%', $permastructs ); + + $is_bad_slug = false + || 0 === $postname_index + || ( $postname_index + && '%year%' === $permastructs[$postname_index - 1] + && 13 > $slug_num ) + || ( $postname_index + && '%monthnum%' === $permastructs[$postname_index - 1] + && 32 > $slug_num ); + } + } + } + + if ( ! $is_bad_slug ) { + $q_results = $q->query( $q_args ); + $is_bad_slug = ! empty( $q_results ); + } + + if ( $is_bad_slug ) { + $suffix = 1; + + while ( $is_bad_slug ) { + $suffix += 1; + $alt_slug = sprintf( '%s-%s', + bogo_truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ), + $suffix + ); + + $q_results = $q->query( array_merge( + $q_args, + array( 'name' => $alt_slug ) + ) ); + + $is_bad_slug = ! empty( $q_results ); + } + + $override_slug = $alt_slug; + } + } + + return $override_slug; +} + +function bogo_truncate_post_slug( $slug, $length = 200 ) { + if ( strlen( $slug ) > $length ) { + $decoded_slug = urldecode( $slug ); + + if ( $decoded_slug === $slug ) { + $slug = substr( $slug, 0, $length ); + } else { + $slug = utf8_uri_encode( $decoded_slug, $length ); + } + } + + return rtrim( $slug, '-' ); +} + + +add_filter( + 'wp_sitemaps_posts_query_args', + 'bogo_sitemaps_posts_query_args', + 10, 2 +); + +function bogo_sitemaps_posts_query_args( $args, $post_type ) { + if ( bogo_is_localizable_post_type( $post_type ) ) { + $args['bogo_suppress_locale_query'] = true; + } + + return $args; +} diff --git a/wp-content/plugins/bogo/includes/query.php b/wp-content/plugins/bogo/includes/query.php new file mode 100644 index 0000000000..7aaec73ee7 --- /dev/null +++ b/wp-content/plugins/bogo/includes/query.php @@ -0,0 +1,269 @@ +query_vars; + + if ( ! empty( $qv['bogo_suppress_locale_query'] ) ) { + return; + } + + if ( $query->is_preview() + and ( $qv['page_id'] or $qv['p'] ) ) { + $qv['bogo_suppress_locale_query'] = true; + return; + } + + if ( isset( $qv['post_type'] ) + and 'any' != $qv['post_type'] ) { + $localizable = array_filter( + (array) $qv['post_type'], + 'bogo_is_localizable_post_type' + ); + + if ( empty( $localizable ) ) { + $qv['bogo_suppress_locale_query'] = true; + return; + } + } + + $lang = isset( $qv['lang'] ) ? $qv['lang'] : ''; + + if ( is_admin() ) { + $locale = $lang; + } else { + if ( $lang ) { + $locale = bogo_get_closest_locale( $lang ); + } else { + $locale = get_locale(); + } + + if ( empty( $locale ) ) { + $locale = bogo_get_default_locale(); + } + } + + if ( empty( $locale ) + or ! bogo_is_available_locale( $locale ) ) { + $qv['bogo_suppress_locale_query'] = true; + return; + } + + $qv['lang'] = $locale; + + if ( is_admin() ) { + return; + } + + if ( $query->is_home + and 'page' == get_option( 'show_on_front' ) + and get_option( 'page_on_front' ) ) { + $query_keys = array_keys( wp_parse_args( $query->query ) ); + $query_keys = array_diff( + $query_keys, + array( 'preview', 'page', 'paged', 'cpage', 'lang' ) + ); + + if ( empty( $query_keys ) ) { + $query->is_page = true; + $query->is_home = false; + $qv['page_id'] = get_option( 'page_on_front' ); + + if ( ! empty( $qv['paged'] ) ) { + $qv['page'] = $qv['paged']; + unset( $qv['paged'] ); + } + } + } + + if ( '' != $qv['pagename'] ) { + $query->queried_object = bogo_get_page_by_path( $qv['pagename'], $locale ); + + if ( ! empty( $query->queried_object ) ) { + $query->queried_object_id = (int) $query->queried_object->ID; + } else { + unset( $query->queried_object ); + unset( $query->queried_object_id ); + } + + if ( 'page' == get_option( 'show_on_front' ) + and isset( $query->queried_object_id ) + and $query->queried_object_id == get_option( 'page_for_posts' ) ) { + $query->is_page = false; + $query->is_home = true; + $query->is_posts_page = true; + } + } + + if ( isset( $qv['post_type'] ) + and 'any' != $qv['post_type'] + and ! is_array( $qv['post_type'] ) + and '' != $qv['name'] ) { + $query->queried_object = bogo_get_page_by_path( + $qv['name'], $locale, $qv['post_type'] + ); + + if ( ! empty( $query->queried_object ) ) { + $query->queried_object_id = (int) $query->queried_object->ID; + } else { + unset( $query->queried_object ); + unset( $query->queried_object_id ); + } + } + + if ( $query->is_posts_page + and ( ! isset( $qv['withcomments'] ) or ! $qv['withcomments'] ) ) { + $query->is_comment_feed = false; + } + + $query->is_singular = + ( $query->is_single || $query->is_page || $query->is_attachment ); + + $query->is_embed = + $query->is_embed && ( $query->is_singular || $query->is_404 ); +} + +add_filter( 'posts_join', 'bogo_posts_join', 10, 2 ); + +function bogo_posts_join( $join, $query ) { + global $wpdb; + + $qv = &$query->query_vars; + + if ( ! empty( $qv['bogo_suppress_locale_query'] ) ) { + return $join; + } + + $locale = empty( $qv['lang'] ) ? '' : $qv['lang']; + + if ( ! bogo_is_available_locale( $locale ) ) { + return $join; + } + + if ( ! $meta_table = _get_meta_table( 'post' ) ) { + return $join; + } + + $join .= " LEFT JOIN $meta_table AS postmeta_bogo ON ($wpdb->posts.ID = postmeta_bogo.post_id AND postmeta_bogo.meta_key = '_locale')"; + + return $join; +} + +add_filter( 'posts_where', 'bogo_posts_where', 10, 2 ); + +function bogo_posts_where( $where, $query ) { + global $wpdb; + + $qv = &$query->query_vars; + + if ( ! empty( $qv['bogo_suppress_locale_query'] ) ) { + return $where; + } + + $locale = empty( $qv['lang'] ) ? '' : $qv['lang']; + + if ( ! bogo_is_available_locale( $locale ) ) { + return $where; + } + + if ( ! $meta_table = _get_meta_table( 'post' ) ) { + return $where; + } + + $where .= " AND (1=0"; + + $where .= $wpdb->prepare( " OR postmeta_bogo.meta_value LIKE %s", $locale ); + + if ( bogo_is_default_locale( $locale ) ) { + $where .= " OR postmeta_bogo.meta_id IS NULL"; + } + + $where .= ")"; + + return $where; +} + +add_filter( 'option_sticky_posts', 'bogo_option_sticky_posts', 10, 1 ); + +function bogo_option_sticky_posts( $posts ) { + if ( is_admin() ) { + return $posts; + } + + $locale = get_locale(); + + foreach ( $posts as $key => $post_id ) { + if ( $locale != bogo_get_post_locale( $post_id ) ) { + unset( $posts[$key] ); + } + } + + return $posts; +} + +add_filter( 'option_page_on_front', 'bogo_get_local_post', 10, 1 ); +add_filter( 'option_page_for_posts', 'bogo_get_local_post', 10, 1 ); + +function bogo_get_local_post( $post_id ) { + global $wpdb; + + if ( is_admin() + or empty( $post_id ) ) { + return $post_id; + } + + $post_type = get_post_type( $post_id ); + + if ( ! post_type_exists( $post_type ) + or ! bogo_is_localizable_post_type( $post_type ) ) { + return $post_id; + } + + $locale = get_locale(); + + if ( bogo_get_post_locale( $post_id ) == $locale ) { + return $post_id; + } + + $original_post = get_post_meta( $post_id, '_original_post', true ); + + // For back-compat + if ( empty( $original_post ) ) { + $original_post = $post_id; + } + + $q = "SELECT ID FROM $wpdb->posts AS posts"; + $q .= " LEFT JOIN $wpdb->postmeta AS pm1"; + $q .= " ON posts.ID = pm1.post_id AND pm1.meta_key = '_original_post'"; + $q .= " LEFT JOIN $wpdb->postmeta AS pm2"; + $q .= " ON posts.ID = pm2.post_id AND pm2.meta_key = '_locale'"; + $q .= " WHERE 1=1"; + $q .= " AND post_status = 'publish'"; + $q .= $wpdb->prepare( " AND post_type = %s", $post_type ); + + if ( is_int( $original_post ) ) { // For back-compat + $q .= $wpdb->prepare( " AND (ID = %d OR pm1.meta_value = %d)", + $original_post, $original_post + ); + } else { + $q .= $wpdb->prepare( " AND pm1.meta_value = %s", $original_post ); + } + + $q .= " AND (1=0"; + $q .= $wpdb->prepare( " OR pm2.meta_value LIKE %s", $locale ); + + if ( bogo_is_default_locale( $locale ) ) { + $q .= " OR pm2.meta_id IS NULL"; + } + + $q .= ")"; + + $translation = absint( $wpdb->get_var( $q ) ); + + if ( $translation ) { + return $translation; + } + + return $post_id; +} diff --git a/wp-content/plugins/bogo/includes/rest-api.php b/wp-content/plugins/bogo/includes/rest-api.php new file mode 100644 index 0000000000..f57262d7ba --- /dev/null +++ b/wp-content/plugins/bogo/includes/rest-api.php @@ -0,0 +1,249 @@ + WP_REST_Server::READABLE, + 'callback' => 'bogo_rest_languages', + 'permission_callback' => '__return_true', + ) + ); + + register_rest_route( 'bogo/v1', + '/posts/(?P\d+)/translations', + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => 'bogo_rest_post_translations', + 'permission_callback' => '__return_true', + ) + ); + + $locale_pattern = '[a-z]{2,3}(?:_[A-Z]{2}(?:_[A-Za-z0-9]+)?)?'; + + register_rest_route( 'bogo/v1', + '/posts/(?P\d+)/translations/(?P' . $locale_pattern . ')', + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => 'bogo_rest_create_post_translation', + 'permission_callback' => function( WP_REST_Request $request ) { + $locale = $request->get_param( 'locale' ); + + if ( current_user_can( 'bogo_access_locale', $locale ) ) { + return true; + } else { + return new WP_Error( 'bogo_locale_forbidden', + __( "You are not allowed to access posts in the requested locale.", 'bogo' ), + array( 'status' => 403 ) + ); + } + }, + ) + ); +} + +function bogo_rest_languages( WP_REST_Request $request ) { + if ( ! function_exists( 'wp_get_available_translations' ) ) { + require_once ABSPATH . 'wp-admin/includes/translation-install.php'; + } + + $available_translations = wp_get_available_translations(); + + $local_available_locales = bogo_available_locales(); + + $available_translations = array_intersect_key( + $available_translations, + array_flip( $local_available_locales ) + ); + + return rest_ensure_response( $available_translations ); +} + +function bogo_rest_post_translations( WP_REST_Request $request ) { + $post_id = $request->get_param( 'id' ); + + $post = get_post( $post_id ); + + if ( ! $post ) { + return new WP_Error( 'bogo_post_not_found', + __( "The requested post was not found.", 'bogo' ), + array( 'status' => 404 ) + ); + } + + if ( ! bogo_is_localizable_post_type( $post->post_type ) ) { + return new WP_Error( 'bogo_post_type_invalid', + __( "The requested post type is not localizable.", 'bogo' ), + array( 'status' => 400 ) + ); + } + + $post_type_object = get_post_type_object( $post->post_type ); + $edit_post_cap = $post_type_object->cap->edit_post; + + if ( ! current_user_can( $edit_post_cap, $post->ID ) + and 'publish' !== get_post_status( $post ) ) { + return new WP_Error( 'bogo_post_not_found', + __( "The requested post was not found.", 'bogo' ), + array( 'status' => 404 ) + ); + } + + $response = array(); + $translations = bogo_get_post_translations( $post ); + + foreach ( $translations as $locale => $translation ) { + if ( ! current_user_can( 'edit_post', $translation->ID ) + and 'publish' !== get_post_status( $translation ) ) { + continue; + } + + $response[$locale] = array( + 'lang' => array( 'tag' => bogo_language_tag( $locale ) ), + 'id' => $translation->ID, + 'link' => get_permalink( $translation->ID ), + 'slug' => $translation->post_name, + 'type' => $translation->post_type, + 'date' => mysql_to_rfc3339( $translation->post_date ), + 'date_gmt' => mysql_to_rfc3339( $translation->post_date_gmt ), + 'modified' => mysql_to_rfc3339( $translation->post_modified ), + 'modified_gmt' => mysql_to_rfc3339( $translation->post_modified_gmt ), + 'guid' => array( 'rendered' => '', 'raw' => '' ), + 'title' => array( 'rendered' => '', 'raw' => '' ), + 'content' => array( 'rendered' => '', 'raw' => '' ), + 'excerpt' => array( 'rendered' => '', 'raw' => '' ), + ); + + $lang = bogo_get_language( $locale ); + $lang = empty( $lang ) ? $locale : $lang; + $response[$locale]['lang']['name'] = $lang; + + if ( ! empty( $translation->guid ) ) { + $response[$locale]['guid']['rendered'] = + apply_filters( 'get_the_guid', $translation->guid ); + + if ( current_user_can( $edit_post_cap, $translation->ID ) ) { + $response[$locale]['guid']['raw'] = $translation->guid; + } + } + + if ( ! empty( $translation->post_title ) ) { + $response[$locale]['title']['rendered'] = + get_the_title( $translation->ID ); + + if ( current_user_can( $edit_post_cap, $translation->ID ) ) { + $response[$locale]['title']['raw'] = $translation->post_title; + } + } + + if ( ! empty( $translation->post_content ) ) { + $response[$locale]['content']['rendered'] = apply_filters( + 'the_content', + $translation->post_content + ); + + if ( current_user_can( $edit_post_cap, $translation->ID ) ) { + $response[$locale]['content']['raw'] = $translation->post_content; + } + } + + if ( ! empty( $translation->post_excerpt ) ) { + $response[$locale]['excerpt']['rendered'] = apply_filters( + 'the_excerpt', + apply_filters( 'get_the_excerpt', $translation->post_excerpt ) + ); + + if ( current_user_can( $edit_post_cap, $translation->ID ) ) { + $response[$locale]['excerpt']['raw'] = $translation->post_excerpt; + } + } + } + + return rest_ensure_response( $response ); +} + +function bogo_rest_create_post_translation( WP_REST_Request $request ) { + $post_id = $request->get_param( 'id' ); + + $post = get_post( $post_id ); + + if ( ! $post ) { + return new WP_Error( 'bogo_post_not_found', + __( "The requested post was not found.", 'bogo' ), + array( 'status' => 404 ) + ); + } + + if ( ! bogo_is_localizable_post_type( $post->post_type ) ) { + return new WP_Error( 'bogo_post_type_invalid', + __( "The requested post type is not localizable.", 'bogo' ), + array( 'status' => 400 ) + ); + } + + $locale = $request->get_param( 'locale' ); + + if ( ! bogo_is_available_locale( $locale ) ) { + return new WP_Error( 'bogo_locale_invalid', + __( "The requested locale is not available.", 'bogo' ), + array( 'status' => 400 ) + ); + } + + $new_post_id = bogo_duplicate_post( $post, $locale ); + + if ( ! $new_post_id ) { + return new WP_Error( 'bogo_post_duplication_failed', + __( "Failed to duplicate a post.", 'bogo' ), + array( 'status' => 500 ) + ); + } + + $new_post = get_post( $new_post_id ); + $response = array(); + + $response[$locale] = array( + 'lang' => array( 'tag' => bogo_language_tag( $locale ) ), + 'id' => $new_post->ID, + 'link' => get_permalink( $new_post->ID ), + 'edit_link' => get_edit_post_link( $new_post->ID, 'raw' ), + 'slug' => $new_post->post_name, + 'type' => $new_post->post_type, + 'date' => mysql_to_rfc3339( $new_post->post_date ), + 'date_gmt' => mysql_to_rfc3339( $new_post->post_date_gmt ), + 'modified' => mysql_to_rfc3339( $new_post->post_modified ), + 'modified_gmt' => mysql_to_rfc3339( $new_post->post_modified_gmt ), + 'guid' => array( 'rendered' => '', 'raw' => $new_post->guid ), + 'title' => array( 'rendered' => '', 'raw' => $new_post->post_title ), + 'content' => array( 'rendered' => '', 'raw' => $new_post->post_content ), + 'excerpt' => array( 'rendered' => '', 'raw' => $new_post->post_excerpt ), + ); + + $lang = bogo_get_language( $locale ); + $lang = empty( $lang ) ? $locale : $lang; + $response[$locale]['lang']['name'] = $lang; + + if ( ! empty( $new_post->guid ) ) { + $response[$locale]['guid']['rendered'] = + apply_filters( 'get_the_guid', $new_post->guid ); + } + + if ( ! empty( $new_post->post_title ) ) { + $response[$locale]['title']['rendered'] = + get_the_title( $new_post->ID ); + } + + if ( ! empty( $new_post->post_content ) ) { + $response[$locale]['content']['rendered'] = + apply_filters( 'the_content', $new_post->post_content ); + } + + if ( ! empty( $new_post->post_excerpt ) ) { + $response[$locale]['excerpt']['rendered'] = apply_filters( 'the_excerpt', + apply_filters( 'get_the_excerpt', $new_post->post_excerpt ) ); + } + + return rest_ensure_response( $response ); +} diff --git a/wp-content/plugins/bogo/includes/rewrite.php b/wp-content/plugins/bogo/includes/rewrite.php new file mode 100644 index 0000000000..db32bdac0f --- /dev/null +++ b/wp-content/plugins/bogo/includes/rewrite.php @@ -0,0 +1,524 @@ + 'index.php?lang=$matches[1]&rest_route=/', + "{$lang_regex}/{$rest_url_prefix}/(.*)?" + => 'index.php?lang=$matches[1]&rest_route=/$matches[2]', + "{$wp_rewrite->index}/{$lang_regex}/{$rest_url_prefix}/?$" + => 'index.php?lang=$matches[1]&rest_route=/', + "{$wp_rewrite->index}/{$lang_regex}/{$rest_url_prefix}/(.*)?" + => 'index.php?lang=$matches[1]&rest_route=/$matches[2]', + ); + } + + $localizable_post_types = bogo_localizable_post_types(); + + foreach ( $localizable_post_types as $post_type ) { + if ( ! $post_type_obj = get_post_type_object( $post_type ) + or false === $post_type_obj->rewrite ) { + continue; + } + + if ( $post_type_obj->has_archive ) { + if ( $post_type_obj->has_archive === true ) { + $archive_slug = $post_type_obj->rewrite['slug']; + } else { + $archive_slug = $post_type_obj->has_archive; + } + + if ( $post_type_obj->rewrite['with_front'] ) { + $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; + } else { + $archive_slug = $wp_rewrite->root . $archive_slug; + } + + $extra_rules += array( + "{$lang_regex}/{$archive_slug}/?$" + => 'index.php?lang=$matches[1]&post_type=' . $post_type, + ); + + if ( $post_type_obj->rewrite['feeds'] and $wp_rewrite->feeds ) { + $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; + + $extra_rules += array( + "{$lang_regex}/{$archive_slug}/feed/$feeds/?$" + => 'index.php?lang=$matches[1]&post_type=' . $post_type . '&feed=$matches[2]', + "{$lang_regex}/{$archive_slug}/$feeds/?$" + => 'index.php?lang=$matches[1]&post_type=' . $post_type . '&feed=$matches[2]', + ); + } + + if ( $post_type_obj->rewrite['pages'] ) { + $extra_rules += array( + "{$lang_regex}/{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$" + => 'index.php?lang=$matches[1]&post_type=' . $post_type . '&paged=$matches[2]', + ); + } + } + + $permastruct = $wp_rewrite->get_extra_permastruct( $post_type ); + $permastruct = bogo_add_lang_to_permastruct( $permastruct ); + + $extra_rules += bogo_generate_rewrite_rules( + $permastruct, + $post_type_obj->rewrite + ); + } + + $localizable_taxonomies = get_object_taxonomies( + $localizable_post_types, + 'objects' + ); + + foreach ( $localizable_taxonomies as $taxonomy ) { + if ( empty( $taxonomy->rewrite ) ) { + continue; + } + + $permastruct = $wp_rewrite->get_extra_permastruct( $taxonomy->name ); + $permastruct = bogo_add_lang_to_permastruct( $permastruct ); + + $extra_rules += bogo_generate_rewrite_rules( + $permastruct, + $taxonomy->rewrite + ); + } + + $root_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( $wp_rewrite->root ), + array( 'ep_mask' => EP_ROOT ) + ); + + $comments_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( + $wp_rewrite->root . $wp_rewrite->comments_base + ), + array( + 'ep_mask' => EP_COMMENTS, + 'forcomments' => true, + 'walk_dirs' => false, + ) + ); + + $search_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( $wp_rewrite->get_search_permastruct() ), + array( 'ep_mask' => EP_SEARCH ) + ); + + $author_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( $wp_rewrite->get_author_permastruct() ), + array( 'ep_mask' => EP_AUTHORS ) + ); + + $date_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( $wp_rewrite->get_date_permastruct() ), + array( 'ep_mask' => EP_DATE ) + ); + + $post_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( $wp_rewrite->permalink_structure ), + array( + 'ep_mask' => EP_PERMALINK, + 'paged' => false, + ) + ); + + $wp_rewrite->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' ); + + $page_rules = bogo_generate_rewrite_rules( + bogo_add_lang_to_permastruct( $wp_rewrite->get_page_permastruct() ), + array( + 'ep_mask' => EP_PAGES, + 'walk_dirs' => false, + ) + ); + + if ( $wp_rewrite->use_verbose_page_rules ) { + $rules = array_merge( + $extra_rules, + $root_rules, + $comments_rules, + $search_rules, + $author_rules, + $date_rules, + $page_rules, + $post_rules, + $rules + ); + } else { + $rules = array_merge( + $extra_rules, + $root_rules, + $comments_rules, + $search_rules, + $author_rules, + $date_rules, + $post_rules, + $page_rules, + $rules + ); + } + + return $rules; +} + + +function bogo_add_lang_to_permastruct( $permastruct ) { + global $wp_rewrite; + + $root_quoted = preg_quote( $wp_rewrite->root ); + + $remains = preg_replace( "#^{$root_quoted}#", '', $permastruct ); + $remains = path_join( '%lang%', ltrim( $remains, '/' ) ); + + return path_join( $wp_rewrite->root, $remains ); +} + + +function bogo_generate_rewrite_rules( $permalink_structure, $args = '' ) { + global $wp_rewrite; + + $args = wp_parse_args( $args, array( + 'ep_mask' => EP_NONE, + 'paged' => true, + 'feed' => true, + 'forcomments' => false, + 'walk_dirs' => true, + 'endpoints' => true, + ) ); + + if ( strpos( $permalink_structure, '%lang%' ) === false ) { + return array(); + } + + $feedregex2 = '(' . implode( '|', $wp_rewrite->feeds ) . ')/?$'; + $feedregex = $wp_rewrite->feed_base . '/' . $feedregex2; + $trackbackregex = 'trackback/?$'; + $pageregex = $wp_rewrite->pagination_base . '/?([0-9]{1,})/?$'; + $commentregex = $wp_rewrite->comments_pagination_base . '-([0-9]{1,})/?$'; + $embedregex = 'embed/?$'; + + if ( $args['endpoints'] ) { + $ep_query_append = array(); + + foreach ( (array) $wp_rewrite->endpoints as $endpoint ) { + $epmatch = $endpoint[1] . '(/(.*))?/?$'; + $epquery = '&' . $endpoint[2] . '='; + $ep_query_append[$epmatch] = array( $endpoint[0], $epquery ); + } + } + + $front = substr( + $permalink_structure, + 0, + strpos( $permalink_structure, '%' ) + ); + + preg_match_all( '/%.+?%/', $permalink_structure, $tokens ); + + $index = $wp_rewrite->index; + $feedindex = $index; + $trackbackindex = $index; + $embedindex = $index; + + $queries = array(); + + for ( $i = 0; $i < count( $tokens[0] ); ++$i ) { + if ( 0 < $i ) { + $queries[$i] = $queries[$i - 1] . '&'; + } else { + $queries[$i] = ''; + } + + $query_token = str_replace( + $wp_rewrite->rewritecode, + $wp_rewrite->queryreplace, + $tokens[0][$i] + ) . $wp_rewrite->preg_index( $i + 1 ); + + $queries[$i] .= $query_token; + } + + $structure = $permalink_structure; + + if ( '/' !== $front ) { + $structure = str_replace( $front, '', $structure ); + } + + $structure = trim( $structure, '/' ); + + $dirs = $args['walk_dirs'] + ? explode( '/', $structure ) + : array( $structure ); + + $front = preg_replace( '|^/+|', '', $front ); + + $post_rewrite = array(); + $struct = $front; + + for ( $j = 0; $j < count( $dirs ); ++$j ) { + $struct .= $dirs[$j] . '/'; + $struct = ltrim( $struct, '/' ); + + $match = str_replace( + $wp_rewrite->rewritecode, + $wp_rewrite->rewritereplace, + $struct + ); + + $num_toks = preg_match_all( '/%.+?%/', $struct, $toks ); + + if ( $num_toks < count( $tokens[0] ) + and $toks[0] === array( '%lang%' ) ) { + continue; + } + + $query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) + ? $queries[$num_toks - 1] + : ''; + + switch ( $dirs[$j] ) { + case '%year%': + $ep_mask_specific = EP_YEAR; + break; + case '%monthnum%': + $ep_mask_specific = EP_MONTH; + break; + case '%day%': + $ep_mask_specific = EP_DAY; + break; + default: + $ep_mask_specific = EP_NONE; + } + + $pagematch = $match . $pageregex; + $pagequery = $index . '?' . $query + . '&paged=' . $wp_rewrite->preg_index( $num_toks + 1 ); + + $commentmatch = $match . $commentregex; + $commentquery = $index . '?' . $query + . '&cpage=' . $wp_rewrite->preg_index( $num_toks + 1 ); + + if ( get_option( 'page_on_front' ) ) { + $rootcommentmatch = $match . $commentregex; + $rootcommentquery = $index . '?' . $query + . '&page_id=' . get_option( 'page_on_front' ) + . '&cpage=' . $wp_rewrite->preg_index( $num_toks + 1 ); + } + + $feedmatch = $match . $feedregex; + $feedquery = $feedindex . '?' . $query + . '&feed=' . $wp_rewrite->preg_index( $num_toks + 1 ); + + $feedmatch2 = $match . $feedregex2; + $feedquery2 = $feedindex . '?' . $query + . '&feed=' . $wp_rewrite->preg_index( $num_toks + 1 ); + + $embedmatch = $match . $embedregex; + $embedquery = $embedindex . '?' . $query . '&embed=true'; + + if ( $args['forcomments'] ) { + $feedquery .= '&withcomments=1'; + $feedquery2 .= '&withcomments=1'; + } + + $rewrite = array(); + + if ( $args['feed'] ) { + $rewrite = array( + $feedmatch => $feedquery, + $feedmatch2 => $feedquery2, + $embedmatch => $embedquery, + ); + } + + if ( $args['paged'] ) { + $rewrite = array_merge( + $rewrite, + array( $pagematch => $pagequery ) + ); + } + + if ( EP_PAGES & $args['ep_mask'] + or EP_PERMALINK & $args['ep_mask'] ) { + $rewrite = array_merge( + $rewrite, + array( $commentmatch => $commentquery ) + ); + } elseif ( EP_ROOT & $args['ep_mask'] + and get_option( 'page_on_front' ) ) { + $rewrite = array_merge( + $rewrite, + array( $rootcommentmatch => $rootcommentquery ) + ); + } + + if ( $args['endpoints'] ) { + foreach ( (array) $ep_query_append as $regex => $ep ) { + if ( $ep[0] & $args['ep_mask'] + or $ep[0] & $ep_mask_specific ) { + $rewrite[$match . $regex] = $index . '?' . $query + . $ep[1] . $wp_rewrite->preg_index( $num_toks + 2 ); + } + } + } + + if ( $num_toks ) { + $post = false; + $page = false; + + if ( strpos( $struct, '%postname%' ) !== false + or strpos( $struct, '%post_id%' ) !== false + or strpos( $struct, '%pagename%' ) !== false + or ( strpos( $struct, '%year%' ) !== false + and strpos( $struct, '%monthnum%' ) !== false + and strpos( $struct, '%day%' ) !== false + and strpos( $struct, '%hour%' ) !== false + and strpos( $struct, '%minute%' ) !== false + and strpos( $struct, '%second%' ) !== false ) ) { + $post = true; + + if ( strpos( $struct, '%pagename%' ) !== false ) { + $page = true; + } + } + + if ( ! $post ) { + foreach ( get_post_types( array( '_builtin' => false ) ) as $ptype ) { + if ( strpos( $struct, "%$ptype%" ) !== false ) { + $post = true; + $page = is_post_type_hierarchical( $ptype ); + break; + } + } + } + + if ( $post ) { + $trackbackmatch = $match . $trackbackregex; + $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; + + $embedmatch = $match . $embedregex; + $embedquery = $embedindex . '?' . $query . '&embed=true'; + + $match = rtrim( $match, '/' ); + $submatchbase = preg_replace( '/\(([^?].+?)\)/', '(?:$1)', $match ); + + $sub1 = $submatchbase . '/([^/]+)/'; + $sub1tb = $sub1 . $trackbackregex; + $sub1feed = $sub1 . $feedregex; + $sub1feed2 = $sub1 . $feedregex2; + $sub1comment = $sub1 . $commentregex; + $sub1embed = $sub1 . $embedregex; + + $sub2 = $submatchbase . '/attachment/([^/]+)/'; + $sub2tb = $sub2 . $trackbackregex; + $sub2feed = $sub2 . $feedregex; + $sub2feed2 = $sub2 . $feedregex2; + $sub2comment = $sub2 . $commentregex; + $sub2embed = $sub2 . $embedregex; + + $subquery = $index . '?attachment=' . $wp_rewrite->preg_index( 1 ); + $subtbquery = $subquery . '&tb=1'; + $subfeedquery = $subquery . '&feed=' . $wp_rewrite->preg_index( 2 ); + $subcommentquery = $subquery . '&cpage=' . $wp_rewrite->preg_index( 2 ); + $subembedquery = $subquery . '&embed=true'; + + if ( ! empty( $args['endpoints'] ) ) { + foreach ( (array) $ep_query_append as $regex => $ep ) { + if ( $ep[0] & EP_ATTACHMENT ) { + $rewrite[$sub1 . $regex] = + $subquery . $ep[1] . $wp_rewrite->preg_index( 3 ); + $rewrite[$sub2 . $regex] = + $subquery . $ep[1] . $wp_rewrite->preg_index( 3 ); + } + } + } + + $sub1 .= '?$'; + $sub2 .= '?$'; + + $match = $match . '(?:/([0-9]+))?/?$'; + $query = $index . '?' . $query + . '&page=' . $wp_rewrite->preg_index( $num_toks + 1 ); + } else { + $match .= '?$'; + $query = $index . '?' . $query; + } + + $rewrite = array_merge( $rewrite, array( $match => $query ) ); + + if ( $post ) { + $rewrite = array_merge( + array( $trackbackmatch => $trackbackquery ), + $rewrite + ); + + $rewrite = array_merge( + array( $embedmatch => $embedquery ), + $rewrite + ); + + if ( ! $page ) { + $rewrite = array_merge( + $rewrite, + array( + $sub1 => $subquery, + $sub1tb => $subtbquery, + $sub1feed => $subfeedquery, + $sub1feed2 => $subfeedquery, + $sub1comment => $subcommentquery, + $sub1embed => $subembedquery, + ) + ); + } + + $rewrite = array_merge( + array( + $sub2 => $subquery, + $sub2tb => $subtbquery, + $sub2feed => $subfeedquery, + $sub2feed2 => $subfeedquery, + $sub2comment => $subcommentquery, + $sub2embed => $subembedquery, + ), + $rewrite + ); + } + } + + $post_rewrite = array_merge( $rewrite, $post_rewrite ); + } + + return $post_rewrite; +} diff --git a/wp-content/plugins/bogo/includes/shortcodes.php b/wp-content/plugins/bogo/includes/shortcodes.php new file mode 100644 index 0000000000..07ce6ceca4 --- /dev/null +++ b/wp-content/plugins/bogo/includes/shortcodes.php @@ -0,0 +1,17 @@ + 'list', + ), $atts ); + + switch ( $atts['view'] ) { + case 'suggestion': + return bogo_language_suggestion( 'echo=0' ); + case 'list': + default: + return bogo_language_switcher( 'echo=0' ); + } +} diff --git a/wp-content/plugins/bogo/includes/user.php b/wp-content/plugins/bogo/includes/user.php new file mode 100644 index 0000000000..607f176eb4 --- /dev/null +++ b/wp-content/plugins/bogo/includes/user.php @@ -0,0 +1,169 @@ + true, + ) ); + + if ( isset( $available_languages[$current_locale] ) ) { + $current_language = $available_languages[$current_locale]; + unset( $available_languages[$current_locale] ); + } else { + $current_language = $current_locale; + } + + $wp_admin_bar->add_menu( array( + 'parent' => 'top-secondary', + 'id' => 'bogo-user-locale', + 'title' => sprintf( + '%s', + esc_html( $current_language ) ), + ) ); + + foreach ( $available_languages as $locale => $lang ) { + $url = add_query_arg( + array( + 'action' => 'bogo-switch-locale', + 'locale' => $locale, + 'redirect_to' => urlencode( $_SERVER['REQUEST_URI'] ), + ), + admin_url( 'profile.php' ) + ); + + $url = wp_nonce_url( $url, 'bogo-switch-locale' ); + + $wp_admin_bar->add_menu( array( + 'parent' => 'bogo-user-locale', + 'id' => 'bogo-user-locale-' . $locale, + 'title' => $lang, + 'href' => $url, + ) ); + } +} + +add_action( 'admin_init', 'bogo_switch_user_locale', 10, 0 ); + +function bogo_switch_user_locale() { + if ( empty( $_REQUEST['action'] ) + or 'bogo-switch-locale' != $_REQUEST['action'] ) { + return; + } + + check_admin_referer( 'bogo-switch-locale' ); + + $locale = isset( $_REQUEST['locale'] ) ? $_REQUEST['locale'] : ''; + + if ( ! bogo_is_available_locale( $locale ) + or $locale == bogo_get_user_locale() ) { + return; + } + + update_user_option( get_current_user_id(), 'locale', $locale, true ); + + if ( ! empty( $_REQUEST['redirect_to'] ) ) { + wp_safe_redirect( $_REQUEST['redirect_to'] ); + exit(); + } +} + +function bogo_get_user_locale( $user_id = 0 ) { + $default_locale = bogo_get_default_locale(); + + if ( ! $user_id = absint( $user_id ) ) { + if ( function_exists( 'wp_get_current_user' ) ) { + $current_user = wp_get_current_user(); + + if ( ! empty( $current_user->locale ) ) { + return $current_user->locale; + } + } + + if ( ! $user_id = get_current_user_id() ) { + return $default_locale; + } + } + + $locale = get_user_option( 'locale', $user_id ); + + if ( bogo_is_available_locale( $locale ) ) { + return $locale; + } + + return $default_locale; +} + +function bogo_get_user_accessible_locales( $user_id ) { + global $wpdb; + + $user_id = absint( $user_id ); + + if ( user_can( $user_id, 'bogo_access_all_locales' ) ) { + $locales = bogo_available_locales(); + + return $locales; + } + + $meta_key = $wpdb->get_blog_prefix() . 'accessible_locale'; + + $locales = (array) get_user_meta( $user_id, $meta_key ); + + if ( bogo_is_enus_deactivated() ) { + $locales = array_diff( $locales, array( 'en_US' ) ); + } + + $locales = bogo_filter_locales( $locales ); + + if ( empty( $locales ) ) { + $locales = array( bogo_get_default_locale() ); + } + + return $locales; +} + +add_filter( 'insert_user_meta', 'bogo_user_meta_filter', 10, 3 ); + +function bogo_user_meta_filter( $meta, $user, $update ) { + if ( user_can( $user, 'bogo_access_all_locales' ) ) { + return $meta; + } + + $locale = $meta['locale']; + + if ( empty( $locale ) ) { + $locale = bogo_get_default_locale(); + } + + $accessible_locales = bogo_filter_locales( + bogo_get_user_accessible_locales( $user->ID ) + ); + + if ( empty( $accessible_locales ) ) { + $locale = ''; + } elseif ( ! in_array( $locale, $accessible_locales, true ) ) { + $locale = $accessible_locales[0]; + } + + $meta['locale'] = $locale; + + return $meta; +} diff --git a/wp-content/plugins/bogo/includes/widgets.php b/wp-content/plugins/bogo/includes/widgets.php new file mode 100644 index 0000000000..852f66b774 --- /dev/null +++ b/wp-content/plugins/bogo/includes/widgets.php @@ -0,0 +1,81 @@ + __( 'Language switcher widget by Bogo plugin', 'bogo' ), + ); + + $control_ops = array(); + + WP_Widget::__construct( 'bogo_language_switcher', + __( 'Language Switcher', 'bogo' ), + $widget_ops, $control_ops + ); + } + + function widget( $args, $instance ) { + $title = apply_filters( 'widget_title', + empty( $instance['title'] ) + ? __( 'Language Switcher', 'bogo' ) + : $instance['title'], + $instance, $this->id_base + ); + + echo $args['before_widget']; + + if ( $title ) { + echo $args['before_title'] . $title . $args['after_title']; + } + + echo bogo_language_switcher(); + + echo $args['after_widget']; + } + + function form( $instance ) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); + $title = strip_tags( $instance['title'] ); + + echo '

    '; + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + + $new_instance = wp_parse_args( + (array) $new_instance, + array( 'title' => '' ) + ); + + $instance['title'] = strip_tags( $new_instance['title'] ); + + return $instance; + } + +} + +/* Locale Option */ + +add_filter( 'widget_display_callback', 'bogo_widget_display_callback', 10, 3 ); + +function bogo_widget_display_callback( $instance, $widget, $args ) { + if ( isset( $instance['bogo_locales'] ) ) { + $locale = get_locale(); + + if ( ! in_array( $locale, (array) $instance['bogo_locales'] ) ) { + $instance = false; + } + } + + return $instance; +} diff --git a/wp-content/plugins/bogo/languages/readme.txt b/wp-content/plugins/bogo/languages/readme.txt new file mode 100644 index 0000000000..2064f27a22 --- /dev/null +++ b/wp-content/plugins/bogo/languages/readme.txt @@ -0,0 +1,7 @@ +Dear translators, + +You can translate this plugin at + +https://translate.wordpress.org/projects/wp-plugins/bogo + +We appreciate your contribution. diff --git a/wp-content/plugins/bogo/license.txt b/wp-content/plugins/bogo/license.txt new file mode 100644 index 0000000000..5f5630fa58 --- /dev/null +++ b/wp-content/plugins/bogo/license.txt @@ -0,0 +1,358 @@ +Bogo WordPress Plugin, 2007-2023 Takayuki Miyoshi +Bogo is distributed under the terms of the GNU GPL + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/wp-content/plugins/bogo/readme.txt b/wp-content/plugins/bogo/readme.txt new file mode 100644 index 0000000000..f1d9b95fee --- /dev/null +++ b/wp-content/plugins/bogo/readme.txt @@ -0,0 +1,88 @@ +=== Bogo === +Contributors: takayukister, itpixelz +Tags: multilingual, localization, language, locale, admin +Requires at least: 6.1 +Tested up to: 6.2 +Stable tag: 3.7 +Requires PHP: 7.4 +License: GPL v2 or later +License URI: https://www.gnu.org/licenses/gpl-2.0.html +Donate link: https://contactform7.com/donate/ + +A straight-forward multilingual plugin. No more double-digit custom DB tables or hidden HTML comments that could cause you headaches later on. + +== Description == + +https://ideasilo.wordpress.com/bogo/ + +Bogo is a straight-forward multilingual plugin for WordPress. + +The core of WordPress itself has the built-in localization capability so you can use the dashboard and theme in one language other than English. Bogo expands this capability to let you easily build a multilingual blog on a single WordPress install. + +Here are some technical details for those interested. Bogo plugin assigns [one language per post](https://wordpress.org/support/article/multilingual-wordpress/#different-types-of-multilingual-plugins). It plays nice with WordPress – Bogo does not create any additional custom table on your database, unlike some other plugins in this category. This design makes Bogo a solid, reliable and conflict-free multilingual plugin. + += Getting started with Bogo = + +1. Install language packs + + First, install language packs for languages you use on the site. You can view and install language packs in the **Language Packs** screen (**Languages > Language Packs**). + +2. Select your language for admin screen + + Bogo lets each logged-in user select a language for their admin screen UI. Select a language from the menu on the [**Toolbar**](https://wordpress.org/support/article/administration-screens/#toolbar-keeping-it-all-together), or from the menu in the **Profile** screen (**Users > Your Profile**) if the **Toolbar** is invisible. + +3. Translate your posts and pages + + To create a translation post, go to the editor screen for the original post and find the **Language** box. Bogo does only make a copy of the post; translating the copied post is your task. + +4. Add language switcher widgets + + It would be useful for site visitors if you have a language switcher on your site. Bogo provides the **Language Switcher** widget in the **Widgets** screen (**Appearance > Widgets**). + + You can also use the `[bogo]` shortcode to put a language switcher inside a post content. If you want to use this shortcode in your theme's template files, embed the following code into the template: + + `` + += Privacy notices = + +With the default configuration, this plugin, in itself, does not: + +* track users by stealth; +* write any user personal data to the database; +* send any data to external servers; +* use cookies. + +== Installation == + +1. Upload the entire `bogo` folder to the `/wp-content/plugins/` directory. +1. Activate the plugin through the **Plugins** screen (**Plugins > Installed Plugins**). + +== Screenshots == + +1. You can select your language in the **Toolbar**. +1. The **Language** box manages the post's translations. +1. The **Language Packs** screen lets you view and install language packs. + +== Changelog == + += 3.7 = + +* Language switcher: Adds the language suggestion view. +* Improves `bogo_format_atts()`. +* Updates the languages list in `bogo_languages()` based on translate.wordpress.org. +* Uses a static list to retrieve language native names. +* National flags: Drops famfamfam.com icons in favor of Unicode regional indicator symbols. +* New filter hook: `bogo_get_language` +* New filter hook: `bogo_get_language_native_name` +* New filter hook: `bogo_get_country_code` + += 3.6.1 = + +* Updates bundled JS libraries. +* Includes asset files in the wp.org SVN repository. + += 3.6 = + +* Introduces the language switcher block. +* Fixes a bug that causes multiple serialization on post duplication. +* Fixes a bug in jQuery code that makes the site language unable to switch.