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

Dev #217

Merged
merged 11 commits into from
Feb 2, 2024
4 changes: 2 additions & 2 deletions scripts/wp-init-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# INSTALL DEV ENVIRONMENT #
###########################
# Install theme dependencies with composer
docker exec --user 1000:1000 wp_docker_les_verts bash -c "cd /var/www/html/wp-content/themes/les-verts && composer install"
docker exec --user $(id -u):$(id -g) wp_docker_les_verts bash -c "cd /var/www/html/wp-content/themes/les-verts && composer install"

# Install wp core
docker exec wp_docker_les_verts wp core install --url=localhost --title=LesVERTS --admin_user=admin --admin_password=admin --admin_email=admin@gruene.ch
Expand All @@ -21,7 +21,7 @@ docker exec wp_docker_les_verts bash -c "chmod +x wp-configure.sh && export WPCL
yarn install && yarn build

# Create dist symlink
docker exec --user 1000:1000 wp_docker_les_verts bash -c "cd wp-content/themes/les-verts && ln -sf styleguide/dist/static static"
docker exec --user $(id -u):$(id -g) wp_docker_les_verts bash -c "cd wp-content/themes/les-verts && ln -sf styleguide/dist/static static"

# Import demo content
docker cp scripts/wp-add-demo-content.sh wp_docker_les_verts:/var/www/html/wp-add-demo-content.sh
Expand Down
14 changes: 7 additions & 7 deletions wordpress/wp-content/themes/les-verts/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified wordpress/wp-content/themes/les-verts/languages/de_DE.mo
Binary file not shown.
21 changes: 16 additions & 5 deletions wordpress/wp-content/themes/les-verts/languages/de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2018gruenech\n"
"POT-Creation-Date: 2023-11-03 19:25+0100\n"
"PO-Revision-Date: 2023-11-03 18:28\n"
"PO-Revision-Date: 2024-02-02 15:17\n"
"Last-Translator: Cyrill Bolliger <bolliger@gmx.ch>\n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -2315,7 +2315,7 @@ msgstr "E-Mailvorlage"
#: lib/form/include/Mailer.php:228
#, php-format
msgid "%s: ERROR while sending mail"
msgstr ""
msgstr "%s: ERROR beim Senden einer Mail"

#: lib/form/include/Mailer.php:234
#, php-format
Expand All @@ -2331,7 +2331,18 @@ msgid "Hi Admin of %s\n\n"
"Your Website - %s\n\n"
"Error message:\n"
"%s"
msgstr ""
msgstr "Hallo Admin von %s\n\n"
"Beim Versenden der folgenden Mail ist ein FEHLER aufgetreten und wir konnten sie nicht in der Warteschlange speichern. Die Mail:\n\n"
"---\n\n"
"an: %s\n"
"subject: %s\n"
"body: %s\n\n"
"---\n\n"
"Mehr Details in der Fehlermeldung unten.\n\n"
"Einen schönen Tag noch.\n"
"Deine Website - %s\n\n"
"Fehlermeldung:\n"
"%s"

#: lib/form/include/SubmissionExport.php:92
msgid "Website export"
Expand Down Expand Up @@ -2629,12 +2640,12 @@ msgstr "Die 'tag not in' Funktion wird nicht unterstützt."
#: lib/tweaks/limit-image-upload-dims.php:39
#, php-format
msgid "PNG images must not exceed the area of %d * %d pixels. Reduce the image dimensions or convert it to JPEG."
msgstr ""
msgstr "PNG-Bilder dürfen die Fläche von %d * %d Pixel nicht überschreiten. Verkleinere die Bildgrösse oder wandle sie in JPEG um."

#: lib/tweaks/limit-image-upload-dims.php:48
#, php-format
msgid "Images must not exceed the area of %d * %d pixels. Please reduce the image dimensions and try again."
msgstr ""
msgstr "Die Bilder dürfen die Fläche von %d * %d nicht überschreiten. Bitte reduziere die Bildgrösse und versuche es erneut."

#: lib/widgets/ButtonWidget.php:27
msgid "Show your main calls to action"
Expand Down
Binary file modified wordpress/wp-content/themes/les-verts/languages/fr_FR.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions wordpress/wp-content/themes/les-verts/languages/fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2018gruenech\n"
"POT-Creation-Date: 2023-11-03 19:25+0100\n"
"PO-Revision-Date: 2023-11-03 18:28\n"
"PO-Revision-Date: 2024-01-12 12:27\n"
"Last-Translator: Cyrill Bolliger <bolliger@gmx.ch>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -1895,7 +1895,7 @@ msgstr "Sera affiché sous la zone de saisie du texte (en petits caractères)"

#: lib/form/acf/input.php:156
msgid "Please add <em>Hallo</em>, <em>Liebe</em>, <em>Lieber</em> or <em>salut</em>, <em>chère</em>, <em>cher</em>. All other values will be ignored!"
msgstr "Merci d'insérer <em>Hallo</em>, <em>Liebe</em>, <em>Lieber</em> ou <em>salut</em>, <em>chère</em>, <em>cher</em>. Toutes les autres valeurs seront ignorées!"
msgstr "Merci d'insérer <em>Hallo</em>, <em>Liebe</em>, <em>Lieber</em> ou <em>Salut</em>, <em>Chère</em>, <em>Cher</em>. Toutes les autres valeurs seront ignorées!"

#: lib/form/acf/input.php:162
msgid "Choices"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function queue() {

if ( ! empty( $data ) ) {
$item = new CrmQueueItem( $data, $this->submission );
$this->queue->push( $item );
$this->queue->push_if_not_in_queue( $item );

if ( defined( 'SUPT_FORM_ASYNC' ) && ! SUPT_FORM_ASYNC ) {
do_action( self::CRON_HOOK_CRM_SAVE );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function queue_confirmation() {
$this->submission->meta_get_referer()
);

$this->queue->push( $confirmation );
$this->queue->push_if_not_in_queue( $confirmation );
}
}

Expand All @@ -111,7 +111,7 @@ private function queue_notification() {
$this->submission->meta_get_referer()
);

$this->queue->push( $notification );
$this->queue->push_if_not_in_queue( $notification );
}
}

Expand Down Expand Up @@ -199,7 +199,7 @@ public static function send_mails() {
// requeue mail on error if number of retries is not exceeded
if ( $mail->get_sending_attempts() < self::SENDING_RETRIES ) {
try {
$queue->push( $mail );
$queue->push_if_not_in_queue( $mail );
} catch ( Exception $e ) {
self::send_error_notification( $mail, $e );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,23 @@ public function __construct( $key ) {
*
* @param mixed $item
*
* @return void
* @throws Exception
*/
public function push( $item ) {
$this->lock();
$queue = $this->get_all();
if ( ! in_array( $item, $queue, true ) ) {
$queue[] = $item;
$this->save( $queue );
}
$this->unlock();
$this->_push( $item, true );
}

/**
* Add item to the end of the queue if not yet in queue
*
* @param mixed $item
*
* @return void
* @throws Exception
*/
public function push_if_not_in_queue( $item ) {
$this->_push( $item, false );
}

/**
Expand Down Expand Up @@ -182,4 +189,41 @@ private function get_lock_name(): string {

return DB_NAME . '.' . $wpdb->postmeta . '.' . $this->key;
}

/**
* Add item to the end of the queue
*
* @param mixed $item
* @param bool $allow_duplicates prevent adding the same item twice
*
* @return void
* @throws Exception
*/
private function _push( $item, $allow_duplicates ) {
$this->lock();
$queue = $this->get_all();
if ( $allow_duplicates || ! $this->contains( $queue, $item ) ) {
$queue[] = $item;
$this->save( $queue );
}
$this->unlock();
}

/**
* Check if all_items contains item by comparing the values.
*
* @param $all_items
* @param $item
*
* @return bool
*/
private function contains( $all_items, $item ) {
if ( is_scalar( $item ) ) {
// strict: true => prevent type coercion
return in_array( $item, $all_items, true );
}

// strict: false => compare objects / arrays by value
return in_array( $item, $all_items, false );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function meta_get_linked_email() {
$predecessor = $predecessor->meta_get_predecessor();
}

return false;
return $email ?? false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion wordpress/wp-content/themes/les-verts/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Theme Name: Les Verts
* Description: Custom theme for the GREENS of Switzerland. Designed by superhuit.ch, built by gruene.ch on top of superhuit's stack.
* Author: superhuit.ch & gruene.ch
* Version: 0.38.1
* Version: 0.38.2
* Requires PHP: 7.4
* Requires at least: 5.0
* Theme URI: https://github.com/grueneschweiz/2018.gruene.ch/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
Parameters:
- id: string (optional, name is used if id is not provided)
- id: string (optional, `{{ default_id_prefix }}-{{ uniqueid }}-{{ name }}` is used if id is not provided)
- classes: string (optional, appended)
- name: string must be unique in form
- label: string
Expand All @@ -9,10 +9,11 @@ Parameters:
- type: string. accepted values 'radio' and 'checkbox'
- checked: bool (optional)
- modifiers_classes: string (optional)
- default_id_prefix: string
#}

{% if not id %}
{% set id = name|uniqueid %}
{% set id = default_id_prefix|uniqueid ~ "-" ~ name %}
{% endif %}

<div class="a-checkoption{% if classes %} {{ classes }}{% endif %}">
Expand All @@ -26,14 +27,15 @@ Parameters:
class="a-checkoption__field">
{% else %}
<input type="hidden" name="{{ name }}" value="0">{# make sure unchecked elements still show up in post data #}
<input id="{{ id|default(name) }}"
<input id="{{ id }}"
class="a-checkoption__field"
type="checkbox"
name="{{ name }}"
{% if required %}required{% endif %}
{% if checked %}checked="checked"{% endif %}>
{% endif %}
<label for="{{ id|default(name) }}" class="a-checkoption__label{% if 'radio' == type %} a-checkoption--option{% endif %} {{ modifiers_classes }}">
<label for="{{ id }}"
class="a-checkoption__label{% if 'radio' == type %} a-checkoption--option{% endif %} {{ modifiers_classes }}">
{{ label|wptexturize }}
</label>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
Parameters:
- id: string (optional, name is used if id is not provided)
- id: string (optional, `{{ default_id_prefix }}-{{ uniqueid }}-{{ name }}` is used if id is not provided)
- classes: string (optional, appended)
- name: string must be unique in form
- label: string
Expand All @@ -11,18 +11,24 @@ Parameters:
- required: bool
- modifiers_classes: string (optional)
- type: string. accepted values 'textarea' and the html5 input types
- default_id_prefix: string
#}

{% if not id %}
{% set id = default_id_prefix|uniqueid ~ "-" ~ name %}
{% endif %}

<div class="a-input{% if wrapper_classes %} {{ wrapper_classes }}{% endif %}{% if classes %} {{ classes }}{% endif %}">
<label for="{{ id|default(name) }}" class="a-input__label {% if required %}a-input__label--required{% endif %}">
<label for="{{ id }}" class="a-input__label {% if required %}a-input__label--required{% endif %}">
{{ label|wptexturize }}
</label>
{% if 'textarea' == type %}
<textarea id="{{ id|default(name) }}"
<textarea id="{{ id }}"
class="a-input__field {{ modifiers_classes }}"
name="{{ name }}"
{% if required %}required="required"{% endif %}>{{ value }}</textarea>
{% else %}
<input id="{{ id|default(name) }}"
<input id="{{ id }}"
class="a-input__field {{ modifiers_classes }}{% if required %} is-required{% endif %}"
type="{{ type }}"
name="{{ name }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
Parameters:
- id: string (optional, name is used if id is not provided)
- id: string (optional, `{{ default_id_prefix }}-{{ uniqueid }}-{{ name }}` is used if id is not provided)
- classes: string (optional, appended)
- name: string must be unique in form
- label: string
Expand All @@ -9,13 +9,19 @@ Parameters:
- modifiers_classes: string (optional)
- options: array
- keyed_options: array #used for map block, use option OR keyed_options but not both
- default_id_prefix: string
#}

{% if not id %}
{% set id = default_id_prefix|uniqueid ~ "-" ~ name %}
{% endif %}

<div class="a-select {{ modifiers_classes }}{% if classes %} {{ classes }}{% endif %}">
<label for="{{ id|default(name) }}" class="a-select__label {% if required %}a-select__label--required{% endif %}">
<label for="{{ id }}" class="a-select__label {% if required %}a-select__label--required{% endif %}">
{{ label|wptexturize }}
</label>
<div class="a-select__background">
<select id="{{ id|default(name) }}"
<select id="{{ id }}"
class="a-select__field"
name="{{ name }}"
{% if required %}required="required"{% endif %}>
Expand Down
Loading
Loading