| @@ -4,43 +4,21 @@ | ||
| 4 | 4 | require_once BOGO_PLUGIN_DIR . '/admin/includes/post.php'; |
| 5 | 5 | require_once BOGO_PLUGIN_DIR . '/admin/includes/nav-menu.php'; |
| 6 | 6 | require_once BOGO_PLUGIN_DIR . '/admin/includes/widgets.php'; |
| 7 | 7 | |
| 8 | -add_action( 'admin_init', 'bogo_upgrade' ); | |
| 9 | - | |
| 10 | -function bogo_upgrade() { | |
| 11 | - $old_ver = bogo_get_prop( 'version' ); | |
| 12 | - $new_ver = BOGO_VERSION; | |
| 13 | - | |
| 14 | - if ( $old_ver != $new_ver ) { | |
| 15 | - require_once BOGO_PLUGIN_DIR . '/admin/includes/upgrade.php'; | |
| 16 | - do_action( 'bogo_upgrade', $new_ver, $old_ver ); | |
| 17 | - bogo_set_prop( 'version', $new_ver ); | |
| 18 | - } | |
| 19 | -} | |
| 20 | - | |
| 21 | 8 | add_action( 'admin_enqueue_scripts', 'bogo_admin_enqueue_scripts' ); |
| 22 | 9 | |
| 23 | 10 | function bogo_admin_enqueue_scripts( $hook_suffix ) { |
| 24 | - wp_enqueue_style( 'bogo-admin', | |
| 25 | - plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ), | |
| 26 | - array(), BOGO_VERSION, 'all' ); | |
| 11 | + if ( false !== strpos( $hook_suffix, 'bogo-tools' ) | |
| 12 | + || 'widgets.php' == $hook_suffix | |
| 13 | + || 'user-edit.php' == $hook_suffix ) { | |
| 14 | + wp_enqueue_style( 'bogo-admin', | |
| 15 | + plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ), | |
| 16 | + array(), BOGO_VERSION, 'all' ); | |
| 27 | 17 | |
| 28 | - if ( is_rtl() ) { | |
| 29 | - wp_enqueue_style( 'bogo-admin-rtl', | |
| 30 | - plugins_url( 'admin/includes/css/admin-rtl.css', BOGO_PLUGIN_BASENAME ), | |
| 31 | - array(), BOGO_VERSION, 'all' ); | |
| 18 | + return; | |
| 32 | 19 | } |
| 33 | 20 | |
| 34 | - wp_enqueue_script( 'bogo-admin', | |
| 35 | - plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ), | |
| 36 | - array( 'jquery' ), BOGO_VERSION, true ); | |
| 37 | - | |
| 38 | - $local_args = array( | |
| 39 | - 'rest_api' => array( | |
| 40 | - 'url' => trailingslashit( rest_url( 'bogo/v1' ) ), | |
| 41 | - 'nonce' => wp_create_nonce( 'wp_rest' ) ) ); | |
| 42 | - | |
| 43 | 21 | if ( 'nav-menus.php' == $hook_suffix ) { |
| 44 | 22 | $nav_menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) ); |
| 45 | 23 | $nav_menu_items = wp_get_nav_menu_items( $nav_menu_id ); |
| 46 | 24 | $locales = array(); |
| @@ -48,29 +26,41 @@ | ||
| 48 | 26 | foreach ( (array) $nav_menu_items as $item ) { |
| 49 | 27 | $locales[$item->db_id] = $item->bogo_locales; |
| 50 | 28 | } |
| 51 | 29 | |
| 52 | - $local_args = array_merge( $local_args, array( | |
| 30 | + $prefix = 'menu-item-bogo-locale'; | |
| 31 | + | |
| 32 | + wp_enqueue_script( 'bogo-admin', | |
| 33 | + plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ), | |
| 34 | + array( 'jquery' ), | |
| 35 | + BOGO_VERSION, true ); | |
| 36 | + | |
| 37 | + wp_localize_script( 'bogo-admin', '_bogo', array( | |
| 53 | 38 | 'availableLanguages' => bogo_available_languages( array( |
| 54 | 39 | 'exclude_enus_if_inactive' => true, |
| 55 | 40 | 'orderby' => 'value' ) ), |
| 56 | 41 | 'locales' => $locales, |
| 57 | 42 | 'selectorLegend' => __( 'Displayed on pages in', 'bogo' ), |
| 58 | - 'cbPrefix' => 'menu-item-bogo-locale' ) ); | |
| 43 | + 'cbPrefix' => $prefix ) ); | |
| 44 | + | |
| 45 | + wp_enqueue_style( 'bogo-admin', | |
| 46 | + plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ), | |
| 47 | + array(), BOGO_VERSION, 'all' ); | |
| 48 | + | |
| 49 | + return; | |
| 59 | 50 | } |
| 60 | 51 | |
| 61 | 52 | if ( 'options-general.php' == $hook_suffix ) { |
| 62 | - $local_args = array_merge( $local_args, array( | |
| 53 | + wp_enqueue_script( 'bogo-admin', | |
| 54 | + plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ), | |
| 55 | + array( 'jquery' ), | |
| 56 | + BOGO_VERSION, true ); | |
| 57 | + | |
| 58 | + wp_localize_script( 'bogo-admin', '_bogo', array( | |
| 63 | 59 | 'defaultLocale' => bogo_get_default_locale() ) ); |
| 64 | - } | |
| 65 | 60 | |
| 66 | - if ( 'post.php' == $hook_suffix && ! empty( $GLOBALS['post'] ) ) { | |
| 67 | - $post = $GLOBALS['post']; | |
| 68 | - $local_args = array_merge( $local_args, array( | |
| 69 | - 'post_id' => $post->ID ) ); | |
| 61 | + return; | |
| 70 | 62 | } |
| 71 | - | |
| 72 | - wp_localize_script( 'bogo-admin', '_bogo', $local_args ); | |
| 73 | 63 | } |
| 74 | 64 | |
| 75 | 65 | add_action( 'admin_menu', 'bogo_admin_menu' ); |
| 76 | 66 | |
| @@ -183,13 +173,13 @@ | ||
| 183 | 173 | <tfoot> |
| 184 | 174 | <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr> |
| 185 | 175 | </tfoot> |
| 186 | 176 | <tbody id="translations"> |
| 187 | - <tr class="active"><th>1</th><td> | |
| 177 | + <tr class="active"><th>1</th><td><p> | |
| 188 | 178 | <strong><?php echo esc_html( bogo_get_language( $default_locale ) ); ?></strong> |
| 189 | 179 | [<?php echo esc_html( $default_locale ); ?>] |
| 190 | 180 | <div class="status"><span class="status"><?php echo esc_html( __( 'Site Default Language', 'bogo' ) ); ?></span></div> |
| 191 | - </td></tr> | |
| 181 | + </p></td></tr> | |
| 192 | 182 | |
| 193 | 183 | <?php |
| 194 | 184 | $count = 1; |
| 195 | 185 | |
| @@ -264,12 +254,13 @@ | ||
| 264 | 254 | } |
| 265 | 255 | ?> |
| 266 | 256 | <tr class="<?php echo esc_attr( $class ); ?>"> |
| 267 | 257 | <th><?php echo $count; ?></th> |
| 268 | - <td> | |
| 258 | + <td><p> | |
| 269 | 259 | <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong> |
| 270 | 260 | [<?php echo esc_html( $locale ); ?>] |
| 271 | 261 | <?php echo $status; ?> |
| 262 | + </p> | |
| 272 | 263 | </td> |
| 273 | 264 | </tr> |
| 274 | 265 | <?php |
| 275 | 266 | } |
| @@ -292,13 +283,13 @@ | ||
| 292 | 283 | $install_link = sprintf( '<a href="%1$s" class="install">%2$s</a>', |
| 293 | 284 | $install_link, esc_html( __( 'Install', 'bogo' ) ) ); |
| 294 | 285 | } |
| 295 | 286 | ?> |
| 296 | - <tr><th><?php echo $count; ?></th><td> | |
| 287 | + <tr><th><?php echo $count; ?></th><td><p> | |
| 297 | 288 | <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong> |
| 298 | 289 | [<?php echo esc_html( $locale ); ?>] |
| 299 | 290 | <?php echo $install_link; ?> |
| 300 | - </td></tr> | |
| 291 | + </p></td></tr> | |
| 301 | 292 | <?php |
| 302 | 293 | } |
| 303 | 294 | ?> |
| 304 | 295 | |