Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only mention “public” in post status option if relevant. #3

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 46 additions & 18 deletions admin/settings-field-post-types-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,40 +93,68 @@ function ( $post_status_object ) {

$current = ( null === $post_expiration_info ) ? '' : $post_expiration_info->post_status;

$options = [
'' => '',
$groups = [
'public' => [
'label' => __( 'Public', 'pronamic-post-expiration' ),
'options' => [],
],
'non-public' => [
'label' => __( 'Non Public', 'pronamic-post-expiration' ),
'options' => [],
],
];

foreach ( $post_status_objects as $key => $post_status_info ) {
$options[ $key ] = \sprintf(
/* translators: 1: Post status label, 2: Post status name, 3: Public yes/no. */
\__( '%1$s (%2$s) · Public: %3$s', 'pronamic-post-expiration' ),
$group = $post_status_info->public ? 'public' : 'non-public';

$groups[ $group ]['options'][ $key ] = \sprintf(
/* translators: 1: Post status label, 2: Post status name */
\__( '%1$s (%2$s)', 'pronamic-post-expiration' ),
\esc_html( $post_status_info->label ),
\esc_html( $post_status_info->name ),
\esc_html( $post_status_info->public ? \__( 'Yes', 'pronamic-post-expiration' ) : \__( 'No', 'pronamic-post-expiration' ) )
\esc_html( $post_status_info->name )
);
}

if ( ! \array_key_exists( $current, $options ) ) {
$options[ $current ] = $current;
}

$name = \sprintf(
'pronamic_post_expiration_config[post_types][%s][post_status]',
$post_type_info->name
);

// Filter groups without options.
$groups = array_filter(
$groups,
function ( $group ) {
return 0 !== count( $group['options'] );
}
);

?>
<select name="<?php echo \esc_attr( $name ); ?>" <?php \disabled( $disabled ); ?>>
<option value=""></option>

<?php

foreach ( $options as $value => $label ) {
printf(
'<option value="%s" %s>%s</option>',
\esc_attr( $value ),
\selected( $value, $current, false ),
\esc_html( $label )
);
foreach ( $groups as $group ) {
?>

<optgroup label="<?php echo \esc_attr( $group['label'] ); ?>">

<?php

foreach ( $group['options'] as $value => $label ) {
printf(
'<option value="%s" %s>%s</option>',
\esc_attr( $value ),
\selected( $value, $current, false ),
\esc_html( $label )
);
}

?>

</optgroup>

<?php
}

?>
Expand Down
Binary file modified languages/pronamic-post-expiration-nl_NL.mo
Binary file not shown.
52 changes: 25 additions & 27 deletions languages/pronamic-post-expiration-nl_NL.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Project-Id-Version: Pronamic Post Expiration 1.0.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pronamic-post-"
"expiration\n"
"POT-Creation-Date: 2024-10-24T18:42:22+00:00\n"
"PO-Revision-Date: 2024-10-24 20:42+0200\n"
"POT-Creation-Date: 2024-12-06T08:50:52+00:00\n"
"PO-Revision-Date: 2024-12-06 09:53+0100\n"
"Last-Translator: Remco Tolsma <info@remcotolsma.nl>\n"
"Language-Team: \n"
"Language: nl_NL\n"
Expand All @@ -18,8 +18,8 @@ msgstr ""
"X-Domain: pronamic-post-expiration\n"

#. Plugin Name of the plugin
#: pronamic-post-expiration.php php/SettingsController.php:95
#: php/SettingsController.php:96
#: pronamic-post-expiration.php php/SettingsController.php:102
#: php/SettingsController.php:103
msgid "Pronamic Post Expiration"
msgstr "Pronamic Post Expiration"

Expand All @@ -44,61 +44,59 @@ msgstr "Pronamic"
msgid "https://www.pronamic.eu/"
msgstr "https://www.pronamic.nl/"

#: admin/settings-field-post-types-support.php:51
#: admin/settings-field-post-types-support.php:49
msgid "Post type"
msgstr "Berichttype"

#: admin/settings-field-post-types-support.php:52
#: admin/settings-field-post-types-support.php:50
msgid "Label"
msgstr "Label"

#: admin/settings-field-post-types-support.php:53
#: admin/settings-field-post-types-support.php:51
msgid "Support"
msgstr "Support"

#: admin/settings-field-post-types-support.php:54
#: admin/settings-field-post-types-support.php:52
msgid "Post status"
msgstr "Berichtstatus"

#. translators: 1: Post status label, 2: Post status name, 3: Public yes/no.
#: admin/settings-field-post-types-support.php:105
msgid "%1$s (%2$s) · Public: %3$s"
msgstr "%1$s (%2$s) · Openbaar: %3$s"
#: admin/settings-field-post-types-support.php:98
msgid "Public"
msgstr "Openbaar"

#: admin/settings-field-post-types-support.php:108
msgid "Yes"
msgstr "Ja"
#: admin/settings-field-post-types-support.php:102
msgid "Non Public"
msgstr "Niet openbaar"

#: admin/settings-field-post-types-support.php:108
msgid "No"
msgstr "Nee"
#. translators: 1: Post status label, 2: Post status name
#: admin/settings-field-post-types-support.php:112
#| msgid "%1$s (`%2$s`)"
msgid "%1$s (%2$s)"
msgstr "%1$s (%2$s)"

#: php/Plugin.php:95
#: php/Plugin.php:94
msgid "Expired"
msgstr "Verlopen"

#. translators: %s: count value
#: php/Plugin.php:97
#: php/Plugin.php:96
msgid "Expired <span class=\"count\">(%s)</span>"
msgid_plural "Expired <span class=\"count\">(%s)</span>"
msgstr[0] "Verlopen <span class=“count”>(%s)</span>"
msgstr[1] "Verlopen <span class=“count”>(%s)</span>"

#: php/Plugin.php:166
#: php/Plugin.php:165
msgid "Expiration"
msgstr "Vervaldatum"

#: php/Plugin.php:356
#: php/Plugin.php:359
msgid "View scheduled expire action"
msgstr "Bekijk geplande vervaldatum actie"

#: php/SettingsController.php:71
#: php/SettingsController.php:78
msgid "General"
msgstr "Algemeen"

#: php/SettingsController.php:78
#: php/SettingsController.php:85
msgid "Post types"
msgstr "Berichttypen"

#~ msgid "View scheduled expire event"
#~ msgstr "Bekijk geplande verloop gebeurtenis"
40 changes: 20 additions & 20 deletions languages/pronamic-post-expiration.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-10-24T18:42:22+00:00\n"
"POT-Creation-Date: 2024-12-06T08:50:52+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: pronamic-post-expiration\n"

#. Plugin Name of the plugin
#: pronamic-post-expiration.php
#: php/SettingsController.php:95
#: php/SettingsController.php:96
#: php/SettingsController.php:102
#: php/SettingsController.php:103
msgid "Pronamic Post Expiration"
msgstr ""

Expand All @@ -41,58 +41,58 @@ msgstr ""
msgid "https://www.pronamic.eu/"
msgstr ""

#: admin/settings-field-post-types-support.php:51
#: admin/settings-field-post-types-support.php:49
msgid "Post type"
msgstr ""

#: admin/settings-field-post-types-support.php:52
#: admin/settings-field-post-types-support.php:50
msgid "Label"
msgstr ""

#: admin/settings-field-post-types-support.php:53
#: admin/settings-field-post-types-support.php:51
msgid "Support"
msgstr ""

#: admin/settings-field-post-types-support.php:54
#: admin/settings-field-post-types-support.php:52
msgid "Post status"
msgstr ""

#. translators: 1: Post status label, 2: Post status name, 3: Public yes/no.
#: admin/settings-field-post-types-support.php:105
msgid "%1$s (%2$s) · Public: %3$s"
#: admin/settings-field-post-types-support.php:98
msgid "Public"
msgstr ""

#: admin/settings-field-post-types-support.php:108
msgid "Yes"
#: admin/settings-field-post-types-support.php:102
msgid "Non Public"
msgstr ""

#: admin/settings-field-post-types-support.php:108
msgid "No"
#. translators: 1: Post status label, 2: Post status name
#: admin/settings-field-post-types-support.php:112
msgid "%1$s (%2$s)"
msgstr ""

#: php/Plugin.php:95
#: php/Plugin.php:94
msgid "Expired"
msgstr ""

#. translators: %s: count value
#: php/Plugin.php:97
#: php/Plugin.php:96
msgid "Expired <span class=\"count\">(%s)</span>"
msgid_plural "Expired <span class=\"count\">(%s)</span>"
msgstr[0] ""
msgstr[1] ""

#: php/Plugin.php:166
#: php/Plugin.php:165
msgid "Expiration"
msgstr ""

#: php/Plugin.php:356
#: php/Plugin.php:359
msgid "View scheduled expire action"
msgstr ""

#: php/SettingsController.php:71
#: php/SettingsController.php:78
msgid "General"
msgstr ""

#: php/SettingsController.php:78
#: php/SettingsController.php:85
msgid "Post types"
msgstr ""