-
Notifications
You must be signed in to change notification settings - Fork 3
(feat): add percentage field to Leges #15
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
base: master
Are you sure you want to change the base?
Changes from all commits
7bf8b81
6bd1498
ada1ff9
477da09
444edf4
4bac202
511682d
23bb993
ce57499
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| (function () { | ||
| var checkbox = document.getElementById('_pdc-lege-use-percentage'); | ||
|
|
||
| if (!checkbox) { | ||
| return; | ||
| } | ||
|
|
||
| var priceFields = [ | ||
| document.getElementById('_pdc-lege-price').closest('.cmb-row'), | ||
| document.getElementById('_pdc-lege-new-price').closest('.cmb-row'), | ||
| ]; | ||
|
|
||
| var percentageFields = [ | ||
| document.getElementById('_pdc-lege-percentage').closest('.cmb-row'), | ||
| document.getElementById('_pdc-lege-new-percentage').closest('.cmb-row'), | ||
| ]; | ||
|
|
||
| function toggle() { | ||
| var usePercentage = checkbox.checked; | ||
|
|
||
| priceFields.forEach(function (row) { | ||
| row.style.display = usePercentage ? 'none' : ''; | ||
| }); | ||
|
|
||
| percentageFields.forEach(function (row) { | ||
| row.style.display = usePercentage ? '' : 'none'; | ||
| }); | ||
| } | ||
|
|
||
| checkbox.addEventListener('change', toggle); | ||
| toggle(); | ||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,20 @@ public function registerPostType(): PostType | |
| echo $price ? number_format_i18n((float) $price, 2) : ''; | ||
| }, | ||
| ], | ||
| 'percentage' => [ | ||
| 'title' => __('Lege percentage (%)', 'pdc-leges'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ik weet even niet meer wat het doel is van de percentages, wellicht een kleine omschrijving erbij plaatsen?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ik heb de werking wat aangepast en een video toegevoegd aan deze PR, hopelijk is het daarmee wat duidelijker. |
||
| 'function' => function () { | ||
| $percentage = get_post_meta(get_the_ID(), "{$this->prefix}-percentage", true); | ||
| echo ('' !== $percentage && null !== $percentage) ? esc_html(str_replace('.', ',', $percentage)) . '%' : ''; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ik zou hier alleen maar checken op datgeen wat je wilt, bijvoorbeeld: Stel dat er een keer een array voorbij komt dan heb je een fatal error. |
||
| }, | ||
| ], | ||
| 'new-percentage' => [ | ||
| 'title' => __('Lege new percentage (%)', 'pdc-leges'), | ||
| 'function' => function () { | ||
| $percentage = get_post_meta(get_the_ID(), "{$this->prefix}-new-percentage", true); | ||
| echo ('' !== $percentage && null !== $percentage) ? esc_html(str_replace('.', ',', $percentage)) . '%' : ''; | ||
| }, | ||
| ], | ||
| 'active-date' => [ | ||
| 'title' => __('Date new lege active', 'pdc-leges'), | ||
| 'meta_key' => "{$this->prefix}-active-date", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.