...
 
Commits (16)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

This diff is collapsed.
......@@ -21,13 +21,13 @@
$( function() {
$( '#bogo-add-translation' ).click( function() {
if ( ! bogo.post_id ) {
if ( ! bogo.currentPost.postId ) {
return;
}
var locale = $( '#bogo-translations-to-add' ).val();
var rest_url = bogo.apiSettings.getRoute(
'/posts/' + bogo.post_id + '/translations/' + locale );
'/posts/' + bogo.currentPost.postId + '/translations/' + locale );
$( '#bogo-add-translation' ).next( '.spinner' )
.css( 'visibility', 'visible' );
......@@ -51,12 +51,12 @@
} ).html( function() {
var output = post.title.rendered;
output += ' <span class="screen-reader-text">'
+ bogo.screenReaderText.targetBlank + '</span>';
+ bogo.l10n.targetBlank + '</span>';
return output;
} );
$added = $( '<li></li>' ).append( $added ).append(
' [' + post.lang.name + ']' );
' [' + bogo.availableLanguages[ locale ] + ']' );
$( '#bogo-translations' ).append( $added );
$( '#bogo-translations-to-add option[value="' + locale + '"]' ).detach();
......@@ -82,8 +82,8 @@
} );
if ( changed ) {
event.returnValue = bogo.saveAlert;
return bogo.saveAlert;
event.returnValue = bogo.l10n.saveAlert;
return bogo.l10n.saveAlert;
}
} );
......
......@@ -35,7 +35,7 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
$locales = array_unique( array_merge(
array( bogo_get_default_locale() ),
bogo_available_locales( 'exclude_enus_if_inactive=1' ),
bogo_available_locales(),
array( 'en_US' ),
array_keys( wp_get_available_translations() )
) );
......@@ -69,8 +69,8 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
}
}
if ( 'active' == $status && ! $is_active
|| 'inactive' == $status && $is_active ) {
if ( 'active' == $status and ! $is_active
or 'inactive' == $status and $is_active ) {
continue;
}
......@@ -99,6 +99,7 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
$count_all = $this->count_active + $this->count_inactive;
$all = sprintf(
/* translators: %s: number of language packs */
_nx(
'All <span class="count">(%s)</span>',
'All <span class="count">(%s)</span>',
......@@ -115,6 +116,7 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
// Active
$active = sprintf(
/* translators: %s: number of language packs */
_nx(
'Active <span class="count">(%s)</span>',
'Active <span class="count">(%s)</span>',
......@@ -131,6 +133,7 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
// Inactive
$inactive = sprintf(
/* translators: %s: number of language packs */
_nx(
'Inactive <span class="count">(%s)</span>',
'Inactive <span class="count">(%s)</span>',
......@@ -188,6 +191,7 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
if ( $count_posts ) {
$count_posts = sprintf(
/* translators: %s: number of posts */
_n( '%s Post', '%s Posts', $count_posts, 'bogo' ),
number_format_i18n( $count_posts )
);
......@@ -195,6 +199,7 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
if ( $count_pages ) {
$count_pages = sprintf(
/* translators: %s: number of pages */
_n( '%s Page', '%s Pages', $count_pages, 'bogo' ),
number_format_i18n( $count_pages )
);
......@@ -245,7 +250,8 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
$actions = array();
if ( 'en_US' == $item->locale || $this->can_install_language_pack() ) {
if ( 'en_US' == $item->locale
or $this->can_install_language_pack() ) {
if ( bogo_is_default_locale( $item->locale ) ) {
// nothing
} elseif ( $item->active ) {
......@@ -260,7 +266,8 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
}
}
if ( $item->active && ! bogo_is_default_locale( $item->locale ) ) {
if ( $item->active
and ! bogo_is_default_locale( $item->locale ) ) {
$actions['translate'] = $this->action_link( $item, 'translate' );
}
......@@ -374,12 +381,13 @@ class Bogo_Language_Packs_List_Table extends WP_List_Table {
function bogo_delete_language_pack( $locale ) {
if ( 'en_US' == $locale
|| ! bogo_is_available_locale( $locale )
|| bogo_is_default_locale( $locale ) ) {
or ! bogo_is_available_locale( $locale )
or bogo_is_default_locale( $locale ) ) {
return false;
}
if ( ! is_dir( WP_LANG_DIR ) || ! $files = scandir( WP_LANG_DIR ) ) {
if ( ! is_dir( WP_LANG_DIR )
or ! $files = scandir( WP_LANG_DIR ) ) {
return false;
}
......@@ -395,7 +403,8 @@ function bogo_delete_language_pack( $locale ) {
);
foreach ( $files as $file ) {
if ( '.' === $file[0] || is_dir( $file ) ) {
if ( '.' === $file[0]
or is_dir( $file ) ) {
continue;
}
......
......@@ -12,14 +12,14 @@ class Bogo_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
$parallel_output = preg_replace(
'/<div class="menu-item-settings wp-clearfix" id="menu-item-settings-([0-9]+)">/',
'<div class="menu-item-settings wp-clearfix has-bogo-settings" id="menu-item-settings-${1}">' . $this->language_settings( $item ),
$parallel_output, 1 );
$parallel_output, 1
);
$output .= $parallel_output;
}
private function language_settings( $menu_item ) {
$available_languages = bogo_available_languages( array(
'exclude_enus_if_inactive' => true,
'orderby' => 'value',
) );
......@@ -101,12 +101,12 @@ function bogo_update_nav_menu_item( $menu_id, $menu_item_id ) {
foreach ( (array) bogo_available_locales() as $locale ) {
if ( in_array( $locale, $current_locales )
&& ! in_array( $locale, $requested_locales ) ) {
and ! in_array( $locale, $requested_locales ) ) {
delete_post_meta( $menu_item_id, '_locale', $locale );
}
if ( ! in_array( $locale, $current_locales )
&& in_array( $locale, $requested_locales ) ) {
and in_array( $locale, $requested_locales ) ) {
add_post_meta( $menu_item_id, '_locale', $locale );
}
}
......
......@@ -26,6 +26,16 @@ class Bogo_Terms_Translation_List_Table extends WP_List_Table {
$items = bogo_terms_translation( $this->locale_to_edit );
foreach ( $items as $key => $item ) {
$cap = isset( $item['cap'] )
? $item['cap']
: 'bogo_edit_terms_translation';
if ( ! current_user_can( $cap ) ) {
unset( $items[$key] );
}
}
if ( ! empty( $_REQUEST['s'] ) ) {
$keywords = preg_split( '/[\s]+/', $_REQUEST['s'] );
......@@ -95,10 +105,10 @@ class Bogo_Terms_Translation_List_Table extends WP_List_Table {
echo '<select name="locale" id="select-locale">';
echo sprintf(
'<option value="">%1$s</option>',
esc_html( __( '-- Select Language to Edit --', 'bogo' ) ) );
esc_html( __( '-- Select Language to Edit --', 'bogo' ) )
);
$available_locales = bogo_available_locales( array(
'exclude_enus_if_inactive' => true,
'current_user_can_access' => true,
) );
......@@ -131,7 +141,8 @@ function bogo_terms_translation( $locale_to_edit ) {
static $items = array();
static $locale = null;
if ( ! empty( $items ) && $locale === $locale_to_edit ) {
if ( ! empty( $items )
and $locale === $locale_to_edit ) {
return $items;
}
......@@ -151,6 +162,7 @@ function bogo_terms_translation( $locale_to_edit ) {
'translated' => bogo_translate( 'blogname', 'blogname',
get_option( 'blogname' ) ),
'context' => __( 'Site Title', 'bogo' ),
'cap' => 'manage_options',
);
$items[] = array(
......@@ -159,6 +171,7 @@ function bogo_terms_translation( $locale_to_edit ) {
'translated' => bogo_translate( 'blogdescription', 'blogdescription',
get_option( 'blogdescription' ) ),
'context' => __( 'Tagline', 'bogo' ),
'cap' => 'manage_options',
);
remove_filter( 'get_term', 'bogo_get_term_filter' );
......@@ -179,6 +192,7 @@ function bogo_terms_translation( $locale_to_edit ) {
'translated' => bogo_translate( $name, $taxonomy->name,
$term->name ),
'context' => $tax_labels->name,
'cap' => $taxonomy->cap->edit_terms,
);
}
}
......
<?php
add_action( 'bogo_upgrade', 'flush_rewrite_rules' );
add_action( 'bogo_upgrade', 'flush_rewrite_rules', 10, 0 );
<?php
add_action( 'personal_options_update', 'bogo_update_user_option' );
add_action( 'edit_user_profile_update', 'bogo_update_user_option' );
add_action( 'personal_options_update', 'bogo_update_user_option', 10, 1 );
add_action( 'edit_user_profile_update', 'bogo_update_user_option', 10, 1 );
function bogo_update_user_option( $user_id ) {
global $wpdb;
......@@ -35,32 +35,24 @@ function bogo_update_user_option( $user_id ) {
}
}
add_action( 'personal_options', 'bogo_set_locale_options' );
add_action( 'personal_options', 'bogo_set_locale_options', 10, 1 );
function bogo_set_locale_options( $profileuser ) {
if ( is_network_admin() ) {
if ( is_network_admin() or IS_PROFILE_PAGE ) {
return;
}
if ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
bogo_select_own_locale( $profileuser );
} elseif ( ! user_can( $profileuser, 'bogo_access_all_locales' ) ) {
if ( ! user_can( $profileuser, 'bogo_access_all_locales' ) ) {
bogo_set_accessible_locales( $profileuser );
}
}
function bogo_set_accessible_locales( $profileuser ) {
$available_languages = bogo_available_languages( array(
'exclude_enus_if_inactive' => true,
'orderby' => 'value',
) );
$accessible_locales = bogo_get_user_accessible_locales( $profileuser->ID );
if ( empty( $accessible_locales ) ) {
$accessible_locales = array_keys( $available_languages );
} else {
$accessible_locales = bogo_filter_locales( $accessible_locales );
}
$accessible_locales = bogo_get_user_accessible_locales( $profileuser->ID );
?>
......@@ -89,33 +81,3 @@ function bogo_set_accessible_locales( $profileuser ) {
<?php
}
function bogo_select_own_locale( $profileuser ) {
if ( ! empty( $profileuser->locale ) ) { // WordPress 4.7+
return;
}
$available_languages = bogo_available_languages( array(