| @@ -45,20 +45,8 @@ | ||
| 45 | 45 | array(), BOGO_VERSION, 'all' ); |
| 46 | 46 | |
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | - | |
| 50 | - if ( 'options-general.php' == $hook_suffix ) { | |
| 51 | - wp_enqueue_script( 'bogo-admin', | |
| 52 | - plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ), | |
| 53 | - array( 'jquery' ), | |
| 54 | - BOGO_VERSION, true ); | |
| 55 | - | |
| 56 | - wp_localize_script( 'bogo-admin', '_bogo', array( | |
| 57 | - 'defaultLocale' => bogo_get_default_locale() ) ); | |
| 58 | - | |
| 59 | - return; | |
| 60 | - } | |
| 61 | 49 | } |
| 62 | 50 | |
| 63 | 51 | add_action( 'admin_menu', 'bogo_admin_menu' ); |
| 64 | 52 | |
| @@ -109,11 +97,8 @@ | ||
| 109 | 97 | $message = __( "Translation install failed.", 'bogo' ); |
| 110 | 98 | } |
| 111 | 99 | } |
| 112 | 100 | |
| 113 | - $default_locale = bogo_get_default_locale(); | |
| 114 | - $available_locales = bogo_available_locales(); | |
| 115 | - | |
| 116 | 101 | ?> |
| 117 | 102 | <div class="wrap"> |
| 118 | 103 | |
| 119 | 104 | <h2><?php echo esc_html( __( 'Bogo Tools', 'bogo' ) ); ?></h2> |
| @@ -121,54 +106,54 @@ | ||
| 121 | 106 | <?php if ( ! empty( $message ) ) : ?> |
| 122 | 107 | <div id="message" class="updated"><p><?php echo esc_html( $message ); ?></p></div> |
| 123 | 108 | <?php endif; ?> |
| 124 | 109 | |
| 125 | -<h3 class="title"><?php echo esc_html( __( 'Available Languages', 'bogo' ) ); ?></h3> | |
| 110 | +<?php | |
| 111 | + bogo_toolbox_installed_translations(); | |
| 112 | + bogo_toolbox_add_translations(); | |
| 113 | +?> | |
| 126 | 114 | |
| 127 | -<table id="bogo-languages-table" class="widefat"> | |
| 128 | -<thead> | |
| 129 | - <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr> | |
| 130 | -</thead> | |
| 131 | -<tfoot> | |
| 132 | - <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr> | |
| 133 | -</tfoot> | |
| 134 | -<tbody id="translations"> | |
| 135 | - <tr><th>1</th><td><p> | |
| 136 | - <strong><?php echo esc_html( bogo_get_language( $default_locale ) ); ?></strong> | |
| 137 | - [<?php echo esc_html( $default_locale ); ?>] | |
| 138 | - <br /><?php echo esc_html( __( 'Site Default Language', 'bogo' ) ); ?> | |
| 139 | - </p></td></tr> | |
| 140 | - | |
| 115 | +</div> | |
| 141 | 116 | <?php |
| 142 | - $count = 1; | |
| 117 | +} | |
| 143 | 118 | |
| 144 | - foreach ( $available_locales as $locale ) { | |
| 145 | - if ( $locale == $default_locale ) { | |
| 146 | - continue; | |
| 147 | - } | |
| 119 | +function bogo_toolbox_installed_translations() { | |
| 120 | + $title = __( 'Available Languages', 'bogo' ); | |
| 148 | 121 | |
| 149 | - $count += 1; | |
| 122 | + $default_locale = bogo_get_default_locale(); | |
| 123 | + $languages = array( $default_locale => bogo_get_language( $default_locale ) ) | |
| 124 | + + bogo_available_languages(); | |
| 150 | 125 | ?> |
| 151 | - <tr><th><?php echo $count; ?></th><td><p> | |
| 152 | - <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong> | |
| 153 | - [<?php echo esc_html( $locale ); ?>] | |
| 154 | - <br /><?php echo esc_html( __( 'Installed', 'bogo' ) ); ?> | |
| 155 | - </p></td></tr> | |
| 126 | +<div class="tool-box"> | |
| 127 | +<h3 class="title"><?php echo esc_html( $title ); ?></h3> | |
| 128 | +<ul id="translations"> | |
| 156 | 129 | <?php |
| 130 | + foreach ( $languages as $locale => $language ) { | |
| 131 | + echo sprintf( '<li>%s</li>', esc_html( $language ) ); | |
| 157 | 132 | } |
| 133 | +?> | |
| 134 | +</ul> | |
| 135 | +</div> | |
| 136 | +<?php | |
| 137 | +} | |
| 158 | 138 | |
| 159 | - $can_install = wp_can_install_language_pack(); | |
| 139 | +function bogo_toolbox_add_translations() { | |
| 140 | + if ( ! wp_can_install_language_pack() ) { | |
| 141 | + return; | |
| 142 | + } | |
| 160 | 143 | |
| 161 | - foreach ( wp_get_available_translations() as $locale => $translation ) { | |
| 162 | - if ( in_array( $locale, $available_locales ) ) { | |
| 163 | - continue; | |
| 164 | - } | |
| 144 | + $title = __( 'Add Languages', 'bogo' ); | |
| 165 | 145 | |
| 166 | - $count += 1; | |
| 146 | + $available_translations = wp_get_available_translations(); | |
| 147 | + $languages = array_diff( bogo_languages(), bogo_available_languages() ); | |
| 167 | 148 | |
| 168 | - $install_link = ''; | |
| 169 | - | |
| 170 | - if ( $can_install ) { | |
| 149 | +?> | |
| 150 | +<div class="tool-box"> | |
| 151 | +<h3 class="title"><?php echo esc_html( $title ); ?></h3> | |
| 152 | +<ul id="translations"> | |
| 153 | +<?php | |
| 154 | + foreach ( $languages as $locale => $language ) { | |
| 155 | + if ( isset( $available_translations[$locale] ) ) { | |
| 171 | 156 | $install_link = menu_page_url( 'bogo-tools', false ); |
| 172 | 157 | $install_link = add_query_arg( |
| 173 | 158 | array( 'action' => 'install_translation', 'locale' => $locale ), |
| 174 | 159 | $install_link ); |
| @@ -173,24 +158,19 @@ | ||
| 173 | 158 | array( 'action' => 'install_translation', 'locale' => $locale ), |
| 174 | 159 | $install_link ); |
| 175 | 160 | $install_link = wp_nonce_url( $install_link, 'bogo-tools' ); |
| 176 | 161 | $install_link = sprintf( '<a href="%1$s" class="install">%2$s</a>', |
| 177 | - $install_link, esc_html( __( 'Install', 'bogo' ) ) ); | |
| 162 | + $install_link, __( 'Install', 'bogo' ) ); | |
| 163 | + | |
| 164 | + echo sprintf( '<li>%1$s %2$s</li>', | |
| 165 | + esc_html( $language ), $install_link ); | |
| 166 | + } else { | |
| 167 | + echo sprintf( '<li>%s</li>', esc_html( $language ) ); | |
| 178 | 168 | } |
| 179 | -?> | |
| 180 | - <tr><th><?php echo $count; ?></th><td><p> | |
| 181 | - <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong> | |
| 182 | - [<?php echo esc_html( $locale ); ?>] | |
| 183 | - <?php echo $install_link; ?> | |
| 184 | - </p></td></tr> | |
| 185 | -<?php | |
| 186 | 169 | } |
| 187 | 170 | ?> |
| 188 | - | |
| 189 | -</tbody> | |
| 190 | -</table> | |
| 191 | - | |
| 171 | +</ul> | |
| 192 | 172 | </div> |
| 193 | 173 | <?php |
| 194 | 174 | } |
| 195 | 175 | |
| 196 | 176 | ?> |