Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-jacob committed Dec 2, 2024
2 parents d0f8c93 + b5e4a46 commit 2bf57c2
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 116 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ $ gulp archive

<br><hr>

**Tags:** wpLingua, WP Lingua, WP-Lingua, Multilingual, Bilingual, Translation, Translate, Translated, Localization, Automatic translation, Machine translation, Languages, WordPress, WP, Plugin
**Tags:** wpLingua, WP Lingua, WP-Lingua, Multilingual, Bilingual, Translation, Translate, Translated, Localization, Automatic translation, Machine translation, Languages, WordPress, WP, Plugin, Language switcher, Language selector, API, SEO, Custom flags
6 changes: 5 additions & 1 deletion data.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function wplng_data_json_to_translate() {

// Plugin : YITH
array( 'yith_wcwl_l10n', 'labels', 'cookie_disabled' ),

// Plugin : WF Cookie Consent
array( 'wfCookieConsentSettings', 'wf_cookietext' ),
array( 'wfCookieConsentSettings', 'wf_dismisstext' ),
Expand Down Expand Up @@ -98,6 +98,7 @@ function wplng_data_excluded_selector_default() {
'iframe',
'code',
'address',
'xml',

// Link tag
'link[rel="EditURI"]',
Expand All @@ -111,6 +112,8 @@ function wplng_data_excluded_selector_default() {

// Wordpress
'#wpadminbar',
'.wp-embed-share-input',
'[aria-label="HTML"]',

// wpLingua
'link[hreflang]',
Expand Down Expand Up @@ -155,6 +158,7 @@ function wplng_data_excluded_node_text() {
'link',
'script',
'code',

// Plugin: Contact Form 7
'.wpcf7-textarea',
)
Expand Down
2 changes: 1 addition & 1 deletion inc/admin/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function wplng_option_page_register_assets( $hook ) {
/**
* Register wpLingua assets for option page : Switcher
*
* @param string $hook
* @param string $hook The current admin page hook.
* @return void
*/
function wplng_option_page_switcher_assets( $hook ) {
Expand Down
21 changes: 11 additions & 10 deletions inc/admin/option-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,22 @@ function wplng_settings_part_first_use() {
);

if ( ! empty( $language_target ) ) {

global $wplng_languages_target_simplified;
$wplng_languages_target_simplified = array( $language_target );

update_option(
'wplng_target_languages',
wp_json_encode(
array( $language_target )
)
);

update_option(
'wplng_flags_style',
'rectangular'
);

} else {
return false;
}
Expand Down Expand Up @@ -278,16 +288,7 @@ function wplng_settings_part_language_website() {
*/
function wplng_settings_part_languages_target() {

$languages_target = wplng_get_languages_target_simplified();
$languages_target_ids = array();

foreach ( $languages_target as $language_target ) {
if ( ! empty( $language_target['id'] ) ) {
$languages_target_ids[] = $language_target['id'];
}
}

$languages_target = wplng_get_languages_by_ids( $languages_target_ids );
$languages_target = wplng_get_languages_target_simplified();

?>
<fieldset id="fieldset-add-target-language">
Expand Down
11 changes: 6 additions & 5 deletions inc/admin/option-page-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,11 @@ function wplng_options_switcher_update_flags_style( $old_flags_style, $new_flags
}
}

$target_languages_json = wp_json_encode(
$target_languages,
JSON_UNESCAPED_SLASHES
update_option(
'wplng_target_languages',
wp_json_encode(
$target_languages,
JSON_UNESCAPED_SLASHES
)
);

update_option( 'wplng_target_languages', $target_languages_json );
}
71 changes: 50 additions & 21 deletions inc/admin/slug-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ function wplng_register_post_type_slug() {


/**
* Remove quick edit on wpLingua slugs list
* Remove quick edit on wpLingua slugs list.
*
* This function is a filter on post_row_actions and is used to remove the
* quick edit action from the list of actions on the slugs list page.
*
* @param array $actions An array of row action links.
* @param WP_Post $post The post object.
*
* @param array $actions
* @param object $post
* @return array
*/
function wplng_slug_remove_quick_edit( $actions, $post ) {

// Check if the post type is 'wplng_slug'.
if ( $post->post_type != 'wplng_slug' ) {
return $actions;
}
Expand All @@ -67,10 +72,14 @@ function wplng_slug_remove_quick_edit( $actions, $post ) {
/**
* Display 100 translations by default in admin area
*
* This function is a filter on the posts_per_page option and is used to
* display 100 translations by default in the admin area.
*
* @param mixed $result
* @return mixed
*/
function wplng_slug_per_page( $result ) {

if ( false === $result ) {
$result = '100';
}
Expand All @@ -87,36 +96,52 @@ function wplng_slug_per_page( $result ) {
*/
function wplng_restrict_manage_posts_slug_status() {

// Check if we are on the right post type.
if ( empty( $_GET['post_type'] )
|| 'wplng_slug' !== $_GET['post_type']
) {
return;
}

// Get languages target IDs.
$languages_target = wplng_get_languages_target_ids();
$options = array();
$slug_status = '';

// Set default options for the select.
$options = array(
'' => __( 'All slug status', 'wplingua' ),
);

// Set slug status value from URL parameter if set.
$slug_status = '';

if ( ! empty( $_GET['slug_status'] ) ) {
$slug_status = sanitize_title( $_GET['slug_status'] );
}

// If only one language target id, then use simple status options.
if ( count( $languages_target ) === 1 ) {
$options = array(
'' => __( 'All slug status', 'wplingua' ),
'reviewed' => __( 'Reviewed', 'wplingua' ),
'unreviewed' => __( 'Unreviewed', 'wplingua' ),
$options = array_merge(
$options,
array(
'reviewed' => __( 'Reviewed', 'wplingua' ),
'unreviewed' => __( 'Unreviewed', 'wplingua' ),
)
);
} else {
$options = array(
'' => __( 'All slug status', 'wplingua' ),
'full-reviewed' => __( 'Full reviewed', 'wplingua' ),
'partially-reviewed' => __( 'Partially reviewed', 'wplingua' ),
'reviewed' => __( 'Reviewed', 'wplingua' ),
'unreviewed' => __( 'Full unreviewed', 'wplingua' ),
// If more than one language target id,
// then use full, partially and reviewed status options.
$options = array_merge(
$options,
array(
'full-reviewed' => __( 'Full reviewed', 'wplingua' ),
'partially-reviewed' => __( 'Partially reviewed', 'wplingua' ),
'reviewed' => __( 'Reviewed', 'wplingua' ),
'unreviewed' => __( 'Full unreviewed', 'wplingua' ),
)
);
}

// Display the select with options.
$html = '<select name="slug_status">';

foreach ( $options as $value => $label ) {
Expand All @@ -140,9 +165,13 @@ function wplng_restrict_manage_posts_slug_status() {


/**
* Filter slugs by status: Apply custom query on CPT for slug_status
* Filter slugs by status: Apply custom query on CPT for slug_status.
*
* This function modifies the query to filter slugs based on their review status.
* It is hooked into the WordPress query system for 'wplng_slug' post type
* on the admin edit screen.
*
* @param object $query
* @param object $query The current WP_Query instance.
* @return void
*/
function wplng_posts_filter_slug_status( $query ) {
Expand All @@ -158,6 +187,7 @@ function wplng_posts_filter_slug_status( $query ) {
return;
}

// Determine the slug status and set the corresponding meta query.
switch ( $_GET['slug_status'] ) {
case 'full-reviewed':
$query->set(
Expand Down Expand Up @@ -224,9 +254,7 @@ function wplng_posts_filter_slug_status( $query ) {
)
);
break;

}

}


Expand All @@ -235,20 +263,21 @@ function wplng_posts_filter_slug_status( $query ) {
/**
* Add status custom column on translations
*
* @param array String array
* @param array $columns String array
* @return array
*/
function wplng_slug_status_columns( $columns ) {

// Save the 'cb' column value if it exists
$cb = array();

if ( isset( $columns['cb'] ) ) {
$cb = array(
'cb' => $columns['cb'],
);
unset( $columns['cb'] );
}

// Add the 'wplng_status' column
$columns = array_merge(
$cb,
array(
Expand Down
Loading

0 comments on commit 2bf57c2

Please sign in to comment.