PluginProbe
Bogo / 2.4
Bogo v2.4
3.9.3 trunk 1.0 1.1 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.6 2.6.1 2.7 2.8 2.8.1 2.9 3.0 3.0.1 All 52 releases
← All changes | admin/admin.php +135 -8 2.22.4 View file →
@@ -1,17 +1,19 @@
1 1 <?php
2 2
3 -require_once BOGO_PLUGIN_DIR . '/admin/user.php';
4 -require_once BOGO_PLUGIN_DIR . '/admin/post.php';
5 -require_once BOGO_PLUGIN_DIR . '/admin/nav-menu.php';
6 -require_once BOGO_PLUGIN_DIR . '/admin/widgets.php';
3 +require_once BOGO_PLUGIN_DIR . '/admin/includes/user.php';
4 +require_once BOGO_PLUGIN_DIR . '/admin/includes/post.php';
5 +require_once BOGO_PLUGIN_DIR . '/admin/includes/nav-menu.php';
6 +require_once BOGO_PLUGIN_DIR . '/admin/includes/widgets.php';
7 7
8 8 add_action( 'admin_enqueue_scripts', 'bogo_admin_enqueue_scripts' );
9 9
10 10 function bogo_admin_enqueue_scripts( $hook_suffix ) {
11 - if ( 'widgets.php' == $hook_suffix ) {
11 + if ( false !== strpos( $hook_suffix, 'bogo-tools' )
12 + || 'widgets.php' == $hook_suffix
13 + || 'user-edit.php' == $hook_suffix ) {
12 14 wp_enqueue_style( 'bogo-admin',
13 - plugins_url( 'admin/admin.css', BOGO_PLUGIN_BASENAME ),
15 + plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ),
14 16 array(), BOGO_VERSION, 'all' );
15 17
16 18 return;
17 19 }
@@ -27,9 +29,9 @@
27 29
28 30 $prefix = 'menu-item-bogo-locale';
29 31
30 32 wp_enqueue_script( 'bogo-admin',
31 - plugins_url( 'admin/admin.js', BOGO_PLUGIN_BASENAME ),
33 + plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ),
32 34 array( 'jquery' ),
33 35 BOGO_VERSION, true );
34 36
35 37 wp_localize_script( 'bogo-admin', '_bogo', array(
@@ -38,12 +40,137 @@
38 40 'selectorLegend' => __( 'Displayed on pages in', 'bogo' ),
39 41 'cbPrefix' => $prefix ) );
40 42
41 43 wp_enqueue_style( 'bogo-admin',
42 - plugins_url( 'admin/admin.css', BOGO_PLUGIN_BASENAME ),
44 + plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ),
43 45 array(), BOGO_VERSION, 'all' );
44 46
45 47 return;
46 48 }
49 +}
50 +
51 +add_action( 'admin_menu', 'bogo_admin_menu' );
52 +
53 +function bogo_admin_menu() {
54 + $tools = add_management_page(
55 + __( 'Bogo Tools', 'bogo' ), __( 'Bogo', 'bogo' ),
56 + 'update_core', 'bogo-tools', 'bogo_tools_page' );
57 +
58 + add_action( 'load-' . $tools, 'bogo_load_tools_page' );
59 +}
60 +
61 +function bogo_load_tools_page() {
62 + require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
63 +
64 + $action = isset( $_GET['action'] ) ? $_GET['action'] : '';
65 +
66 + if ( 'install_translation' == $action ) {
67 + check_admin_referer( 'bogo-tools' );
68 +
69 + if ( ! current_user_can( 'update_core' ) ) {
70 + wp_die( __( 'You are not allowed to install translations.', 'bogo' ) );
71 + }
72 +
73 + $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null;
74 +
75 + if ( wp_download_language_pack( $locale ) ) {
76 + $redirect_to = add_query_arg(
77 + array( 'locale' => $locale, 'message' => 'success' ),
78 + menu_page_url( 'bogo-tools', false ) );
79 + } else {
80 + $redirect_to = add_query_arg(
81 + array( 'locale' => $locale, 'message' => 'failed' ),
82 + menu_page_url( 'bogo-tools', false ) );
83 + }
84 +
85 + wp_safe_redirect( $redirect_to );
86 + exit();
87 + }
88 +}
89 +
90 +function bogo_tools_page() {
91 + $message = "";
92 +
93 + if ( isset( $_GET['message'] ) ) {
94 + if ( 'success' == $_GET['message'] ) {
95 + $message = __( "Translation installed successfully.", 'bogo' );
96 + } elseif ( 'failed' == $_GET['message'] ) {
97 + $message = __( "Translation install failed.", 'bogo' );
98 + }
99 + }
100 +
101 +?>
102 +<div class="wrap">
103 +
104 +<h2><?php echo esc_html( __( 'Bogo Tools', 'bogo' ) ); ?></h2>
105 +
106 +<?php if ( ! empty( $message ) ) : ?>
107 +<div id="message" class="updated"><p><?php echo esc_html( $message ); ?></p></div>
108 +<?php endif; ?>
109 +
110 +<?php
111 + bogo_toolbox_installed_translations();
112 + bogo_toolbox_add_translations();
113 +?>
114 +
115 +</div>
116 +<?php
117 +}
118 +
119 +function bogo_toolbox_installed_translations() {
120 + $title = __( 'Available Languages', 'bogo' );
121 +
122 + $default_locale = bogo_get_default_locale();
123 + $languages = array( $default_locale => bogo_get_language( $default_locale ) )
124 + + bogo_available_languages();
125 +?>
126 +<div class="tool-box">
127 +<h3 class="title"><?php echo esc_html( $title ); ?></h3>
128 +<ul id="translations">
129 +<?php
130 + foreach ( $languages as $locale => $language ) {
131 + echo sprintf( '<li>%s</li>', esc_html( $language ) );
132 + }
133 +?>
134 +</ul>
135 +</div>
136 +<?php
137 +}
138 +
139 +function bogo_toolbox_add_translations() {
140 + if ( ! wp_can_install_language_pack() ) {
141 + return;
142 + }
143 +
144 + $title = __( 'Add Languages', 'bogo' );
145 +
146 + $available_translations = wp_get_available_translations();
147 + $languages = array_diff( bogo_languages(), bogo_available_languages() );
148 +
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] ) ) {
156 + $install_link = menu_page_url( 'bogo-tools', false );
157 + $install_link = add_query_arg(
158 + array( 'action' => 'install_translation', 'locale' => $locale ),
159 + $install_link );
160 + $install_link = wp_nonce_url( $install_link, 'bogo-tools' );
161 + $install_link = sprintf( '<a href="%1$s" class="install">%2$s</a>',
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 ) );
168 + }
169 + }
170 +?>
171 +</ul>
172 +</div>
173 +<?php
47 174 }
48 175
49 176 ?>