diff options
author | Yury German <blueknight@gentoo.org> | 2017-01-24 23:51:34 -0500 |
---|---|---|
committer | Yury German <blueknight@gentoo.org> | 2017-01-24 23:51:34 -0500 |
commit | 3c539a4713a80181af84c1fedc742436f75c92c4 (patch) | |
tree | e1896c286f3fb98337a6297465974c65f1fe8f26 /plugins/jetpack/_inc/lib/admin-pages | |
parent | Update theme twentyfifteen to 1.7 (diff) | |
download | blogs-gentoo-3c539a4713a80181af84c1fedc742436f75c92c4.tar.gz blogs-gentoo-3c539a4713a80181af84c1fedc742436f75c92c4.tar.bz2 blogs-gentoo-3c539a4713a80181af84c1fedc742436f75c92c4.zip |
updating jetpack plugin
Diffstat (limited to 'plugins/jetpack/_inc/lib/admin-pages')
-rw-r--r-- | plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php index 1d1ac0bb..2f8251e8 100644 --- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php +++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php @@ -149,7 +149,7 @@ class Jetpack_React_Page extends Jetpack_Admin_Page { function get_i18n_data() { - $i18n_json = JETPACK__PLUGIN_DIR . 'languages/json/jetpack-' . get_locale() . '.json'; + $i18n_json = JETPACK__PLUGIN_DIR . 'languages/json/jetpack-' . jetpack_get_user_locale() . '.json'; if ( is_file( $i18n_json ) && is_readable( $i18n_json ) ) { $locale_data = @file_get_contents( $i18n_json ); @@ -203,7 +203,7 @@ class Jetpack_React_Page extends Jetpack_Admin_Page { wp_enqueue_script( 'jp-tracks', '//stats.wp.com/w.js', array(), gmdate( 'YW' ), true ); } - $localeSlug = explode( '_', get_locale() ); + $localeSlug = explode( '_', jetpack_get_user_locale() ); $localeSlug = $localeSlug[0]; // Collecting roles that can view site stats @@ -228,6 +228,12 @@ class Jetpack_React_Page extends Jetpack_Admin_Page { $modules[ $slug ]['long_description'] = html_entity_decode( $data['long_description'] ); } + // Get last post, to build the link to Customizer in the Related Posts module. + $last_post = get_posts( array( 'posts_per_page' => 1 ) ); + if ( $last_post[0] instanceof WP_Post ) { + $last_post = get_permalink( $last_post[0]->ID ); + } + // Add objects to be passed to the initial state of the app wp_localize_script( 'react-plugin', 'Initial_State', array( 'WP_API_root' => esc_url_raw( rest_url() ), @@ -278,7 +284,8 @@ class Jetpack_React_Page extends Jetpack_Admin_Page { 'errorDescription' => Jetpack::state( 'error_description' ), ), 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(), - 'currentIp' => function_exists( 'jetpack_protect_get_ip' ) ? jetpack_protect_get_ip() : false + 'currentIp' => function_exists( 'jetpack_protect_get_ip' ) ? jetpack_protect_get_ip() : false, + 'lastPostUrl' => esc_url( $last_post ), ) ); } } @@ -413,3 +420,23 @@ function jetpack_current_user_data() { return $current_user_data; } + +/** + * Set the admin language, based on user language. + * + * @since 4.5.0 + * + * @return string + * + * @todo Remove this function when WordPress 4.8 is released + * and replace `jetpack_get_user_locale()` in this file with `get_user_locale()`. + */ +function jetpack_get_user_locale() { + $locale = get_locale(); + + if ( function_exists( 'get_user_locale' ) ) { + $locale = get_user_locale(); + } + + return $locale; +} |