db_id] = $item->bogo_locales; } $prefix = 'menu-item-bogo-locale'; wp_enqueue_script( 'bogo-admin', plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ), array( 'jquery' ), BOGO_VERSION, true ); wp_localize_script( 'bogo-admin', '_bogo', array( 'availableLanguages' => bogo_available_languages( 'orderby=value' ), 'locales' => $locales, 'selectorLegend' => __( 'Displayed on pages in', 'bogo' ), 'cbPrefix' => $prefix ) ); wp_enqueue_style( 'bogo-admin', plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ), array(), BOGO_VERSION, 'all' ); return; } } 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' => 'success' ), menu_page_url( 'bogo-tools', false ) ); } else { $redirect_to = add_query_arg( array( 'locale' => $locale, 'message' => 'failed' ), menu_page_url( 'bogo-tools', false ) ); } wp_safe_redirect( $redirect_to ); exit(); } } function bogo_tools_page() { $message = ""; if ( isset( $_GET['message'] ) ) { if ( 'success' == $_GET['message'] ) { $message = __( "Translation installed successfully.", 'bogo' ); } elseif ( 'failed' == $_GET['message'] ) { $message = __( "Translation install failed.", 'bogo' ); } } ?>