Skip to content
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
28 changes: 23 additions & 5 deletions assets/js/recommendations/remove-terms-without-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
taxonomyElement: popover.querySelector(
'#prpl-delete-term-taxonomy'
),
taxonomyNameElement: popover.querySelector(
'#prpl-delete-term-taxonomy-name'
),
termIdField: popover.querySelector( '#prpl-delete-term-id' ),
taxonomyField: popover.querySelector( '#prpl-delete-taxonomy' ),
};
Expand Down Expand Up @@ -82,6 +85,9 @@
taxonomy: this.decodeHtmlEntities(
event.detail.target_taxonomy
),
taxonomyName: this.decodeHtmlEntities(
event.detail.target_taxonomy_name
),
termName: this.decodeHtmlEntities(
event.detail.target_term_name
),
Expand All @@ -97,19 +103,27 @@
this.currentTermData.termId,
this.currentTermData.taxonomy,
this.currentTermData.termName,
this.currentTermData.taxonomyName,
this.decodeHtmlEntities( event.detail.post_title )
);
}

/**
* Update the popover content.
*
* @param {string} termId The term ID.
* @param {string} taxonomy The taxonomy.
* @param {string} termName The term name.
* @param {string} postTitle The post title.
* @param {string} termId The term ID.
* @param {string} taxonomy The taxonomy.
* @param {string} termName The term name.
* @param {string} taxonomyName The taxonomy name.
* @param {string} postTitle The post title.
*/
updatePopoverContent( termId, taxonomy, termName, postTitle ) {
updatePopoverContent(
termId,
taxonomy,
termName,
taxonomyName,
postTitle
) {
if ( this.elements.popoverTitle ) {
this.elements.popoverTitle.textContent = postTitle;
}
Expand All @@ -122,6 +136,10 @@
this.elements.taxonomyElement.textContent = taxonomy;
}

if ( this.elements.taxonomyNameElement ) {
this.elements.taxonomyNameElement.textContent = taxonomyName;
}

if ( this.elements.termIdField ) {
this.elements.termIdField.value = termId;
}
Expand Down
28 changes: 23 additions & 5 deletions assets/js/recommendations/update-term-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
taxonomyElement: popover.querySelector(
'#prpl-update-term-taxonomy'
),
taxonomyNameElement: popover.querySelector(
'#prpl-update-term-taxonomy-name'
),
termIdField: popover.querySelector( '#prpl-update-term-id' ),
taxonomyField: popover.querySelector( '#prpl-update-taxonomy' ),
descriptionField: popover.querySelector(
Expand Down Expand Up @@ -86,6 +89,9 @@
taxonomy: this.decodeHtmlEntities(
event.detail.target_taxonomy
),
taxonomyName: this.decodeHtmlEntities(
event.detail.target_taxonomy_name
),
termName: this.decodeHtmlEntities(
event.detail.target_term_name
),
Expand All @@ -101,19 +107,27 @@
this.currentTermData.termId,
this.currentTermData.taxonomy,
this.currentTermData.termName,
this.currentTermData.taxonomyName,
this.decodeHtmlEntities( event.detail.post_title )
);
}

/**
* Update the popover content.
*
* @param {string} termId The term ID.
* @param {string} taxonomy The taxonomy.
* @param {string} termName The term name.
* @param {string} postTitle The post title.
* @param {string} termId The term ID.
* @param {string} taxonomy The taxonomy.
* @param {string} termName The term name.
* @param {string} taxonomyName The taxonomy name.
* @param {string} postTitle The post title.
*/
updatePopoverContent( termId, taxonomy, termName, postTitle ) {
updatePopoverContent(
termId,
taxonomy,
termName,
taxonomyName,
postTitle
) {
if ( this.elements.popoverTitle ) {
this.elements.popoverTitle.textContent = postTitle;
}
Expand All @@ -126,6 +140,10 @@
this.elements.taxonomyElement.textContent = taxonomy;
}

if ( this.elements.taxonomyNameElement ) {
this.elements.taxonomyNameElement.textContent = taxonomyName;
}

if ( this.elements.termIdField ) {
this.elements.termIdField.value = termId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ public function add_task_actions( $data = [], $actions = [] ) {

$task_details = $this->get_task_details( $task_data );

$taxonomy = \get_taxonomy( $term->taxonomy );

$actions[] = [
'priority' => 10,
'html' => \sprintf(
Expand All @@ -360,10 +362,11 @@ public function add_task_actions( $data = [], $actions = [] ) {
\htmlspecialchars(
\wp_json_encode(
[
'post_title' => $task_details['post_title'],
'target_term_id' => $task_data['target_term_id'],
'target_taxonomy' => $task_data['target_taxonomy'],
'target_term_name' => $task_data['target_term_name'],
'post_title' => $task_details['post_title'],
'target_term_id' => $task_data['target_term_id'],
'target_taxonomy' => $task_data['target_taxonomy'],
'target_taxonomy_name' => $taxonomy ? $taxonomy->label : '',
'target_term_name' => $task_data['target_term_name'],
]
),
ENT_QUOTES,
Expand Down Expand Up @@ -401,14 +404,23 @@ public function print_popover_form_contents() {
<span id="prpl-delete-term-name"></span>
</p>
<p style="margin: 5px 0 0 0; font-size: 12px; color: #646970;">
<span id="prpl-delete-term-taxonomy"></span>
<?php
printf(
/* translators: %1$s: The taxonomy name, %2$s: The term slug */
\esc_html__( 'You are deleting the term which belongs to the "%1$s" (slug "%2$s").', 'progress-planner' ),
'<span id="prpl-delete-term-taxonomy-name"></span>',
'<span id="prpl-delete-term-taxonomy"></span>'
);
?>
</p>
</div>
<input type="hidden" name="term_id" id="prpl-delete-term-id" value="">
<input type="hidden" name="taxonomy" id="prpl-delete-taxonomy" value="">
<button type="submit" class="prpl-button prpl-button-primary" id="prpl-delete-term-button">
<?php \esc_html_e( 'Delete term', 'progress-planner' ); ?>
</button>
<div class="prpl-steps-nav-wrapper">
<button type="submit" class="prpl-button prpl-button-primary" id="prpl-delete-term-button">
<?php \esc_html_e( 'Delete term', 'progress-planner' ); ?>
</button>
</div>
<?php
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ public function add_task_actions( $data = [], $actions = [] ) {

$task_details = $this->get_task_details( $task_data );

$taxonomy = \get_taxonomy( $term->taxonomy );

$actions[] = [
'priority' => 10,
'html' => \sprintf(
Expand All @@ -344,10 +346,11 @@ public function add_task_actions( $data = [], $actions = [] ) {
\htmlspecialchars(
\wp_json_encode(
[
'post_title' => $task_details['post_title'],
'target_term_id' => $task_data['target_term_id'],
'target_taxonomy' => $task_data['target_taxonomy'],
'target_term_name' => $task_data['target_term_name'],
'post_title' => $task_details['post_title'],
'target_term_id' => $task_data['target_term_id'],
'target_taxonomy' => $task_data['target_taxonomy'],
'target_taxonomy_name' => $taxonomy ? $taxonomy->label : '',
'target_term_name' => $task_data['target_term_name'],
]
),
ENT_QUOTES,
Expand Down Expand Up @@ -385,7 +388,14 @@ public function print_popover_form_contents() {
<span id="prpl-update-term-name"></span>
</p>
<p style="margin: 0 0 10px 0; font-size: 12px; color: #646970;">
<span id="prpl-update-term-taxonomy"></span>
<?php
printf(
/* translators: %1$s: The taxonomy name, %2$s: The term slug */
\esc_html__( 'You are updating the term which belongs to the "%1$s" (slug "%2$s").', 'progress-planner' ),
'<span id="prpl-update-term-taxonomy-name"></span>',
'<span id="prpl-update-term-taxonomy"></span>'
);
?>
</p>
</div>
<textarea
Expand Down
Loading