db_id] = $item->bogo_locales; } wp_localize_script( 'bogo-admin', '_bogo', array( 'availableLanguages' => bogo_available_languages( array( 'exclude_enus_if_inactive' => true, 'orderby' => 'value' ) ), 'locales' => $locales, 'selectorLegend' => __( 'Displayed on pages in', 'bogo' ), 'cbPrefix' => 'menu-item-bogo-locale' ) ); } if ( 'options-general.php' == $hook_suffix ) { wp_localize_script( 'bogo-admin', '_bogo', array( 'defaultLocale' => bogo_get_default_locale() ) ); } } add_action( 'admin_menu', 'bogo_admin_menu' ); function bogo_admin_menu() { $tools = add_management_page( __( 'Bogo Tools', 'bogo' ), __( 'Bogo', 'bogo' ), 'update_core', 'bogo-tools', 'bogo_tools_page' ); add_action( 'load-' . $tools, 'bogo_load_tools_page' ); } function bogo_load_tools_page() { require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); $action = isset( $_GET['action'] ) ? $_GET['action'] : ''; if ( 'install_translation' == $action ) { check_admin_referer( 'bogo-tools' ); if ( ! current_user_can( 'update_core' ) ) { wp_die( __( 'You are not allowed to install translations.', 'bogo' ) ); } $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null; if ( wp_download_language_pack( $locale ) ) { $redirect_to = add_query_arg( array( 'locale' => $locale, 'message' => 'install_success' ), menu_page_url( 'bogo-tools', false ) ); } else { $redirect_to = add_query_arg( array( 'locale' => $locale, 'message' => 'install_failed' ), menu_page_url( 'bogo-tools', false ) ); } wp_safe_redirect( $redirect_to ); exit(); } if ( 'delete_translation' == $action ) { check_admin_referer( 'bogo-tools' ); if ( ! current_user_can( 'update_core' ) ) { wp_die( __( 'You are not allowed to delete translations.', 'bogo' ) ); } $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null; if ( bogo_delete_language_pack( $locale ) ) { $redirect_to = add_query_arg( array( 'locale' => $locale, 'message' => 'delete_success' ), menu_page_url( 'bogo-tools', false ) ); } else { $redirect_to = add_query_arg( array( 'locale' => $locale, 'message' => 'delete_failed' ), menu_page_url( 'bogo-tools', false ) ); } wp_safe_redirect( $redirect_to ); exit(); } if ( 'deactivate_enus' == $action ) { check_admin_referer( 'bogo-tools' ); bogo_set_prop( 'enus_deactivated', true ); $redirect_to = add_query_arg( array( 'message' => 'enus_deactivated' ), menu_page_url( 'bogo-tools', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'activate_enus' == $action ) { check_admin_referer( 'bogo-tools' ); bogo_set_prop( 'enus_deactivated', false ); $redirect_to = add_query_arg( array( 'message' => 'enus_activated' ), menu_page_url( 'bogo-tools', false ) ); wp_safe_redirect( $redirect_to ); exit(); } } function bogo_tools_page() { $enus_deactivated = bogo_get_prop( 'enus_deactivated' ); $can_install = wp_can_install_language_pack(); $default_locale = bogo_get_default_locale(); $available_locales = bogo_available_locales(); ?>
| 1 |
[]
|
|---|---|
| [] | |
| [] |
%s
', esc_html( $message ) ); } else { echo sprintf( '%s