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

Fix: adds missing deprecated filters to document title methods #880

Merged
merged 5 commits into from
Oct 8, 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
50 changes: 25 additions & 25 deletions includes/documents/abstract-wcpdf-order-document.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public function get_due_date_title() {
public function due_date_title() {
echo $this->get_due_date_title();
}

/**
* Get the billing address title
*
Expand All @@ -665,7 +665,7 @@ public function due_date_title() {
public function get_billing_address_title(): string {
return $this->get_title_for( 'billing_address' );
}

/**
* Print the billing address title
*
Expand All @@ -674,7 +674,7 @@ public function get_billing_address_title(): string {
public function billing_address_title(): void {
echo $this->get_billing_address_title();
}

/**
* Get the shipping address title
*
Expand All @@ -683,7 +683,7 @@ public function billing_address_title(): void {
public function get_shipping_address_title(): string {
return $this->get_title_for( 'shipping_address' );
}

/**
* Print the shipping address title
*
Expand All @@ -692,7 +692,7 @@ public function get_shipping_address_title(): string {
public function shipping_address_title(): void {
echo $this->get_shipping_address_title();
}

/**
* Get the order number title
*
Expand All @@ -701,7 +701,7 @@ public function shipping_address_title(): void {
public function get_order_number_title(): string {
return $this->get_title_for( 'order_number' );
}

/**
* Print the order number title
*
Expand All @@ -710,7 +710,7 @@ public function get_order_number_title(): string {
public function order_number_title(): void {
echo $this->get_order_number_title();
}

/**
* Get the order date title
*
Expand All @@ -719,7 +719,7 @@ public function order_number_title(): void {
public function get_order_date_title(): string {
return $this->get_title_for( 'order_date' );
}

/**
* Print the order date title
*
Expand All @@ -728,7 +728,7 @@ public function get_order_date_title(): string {
public function order_date_title(): void {
echo $this->get_order_date_title();
}

/**
* Get the payment method title
*
Expand All @@ -737,7 +737,7 @@ public function order_date_title(): void {
public function get_payment_method_title(): string {
return $this->get_title_for( 'payment_method' );
}

/**
* Print the payment method title
*
Expand All @@ -746,7 +746,7 @@ public function get_payment_method_title(): string {
public function payment_method_title(): void {
echo $this->get_payment_method_title();
}

/**
* Get the payment date title
*
Expand All @@ -755,7 +755,7 @@ public function payment_method_title(): void {
public function get_payment_date_title(): string {
return $this->get_title_for( 'payment_date' );
}

/**
* Print the payment date title
*
Expand All @@ -764,7 +764,7 @@ public function get_payment_date_title(): string {
public function payment_date_title(): void {
echo $this->get_payment_date_title();
}

/**
* Get the shipping method title
*
Expand All @@ -773,7 +773,7 @@ public function payment_date_title(): void {
public function get_shipping_method_title(): string {
return $this->get_title_for( 'shipping_method' );
}

/**
* Print the shipping method title
*
Expand All @@ -782,7 +782,7 @@ public function get_shipping_method_title(): string {
public function shipping_method_title(): void {
echo $this->get_shipping_method_title();
}

/**
* Get the SKU title
*
Expand All @@ -791,7 +791,7 @@ public function shipping_method_title(): void {
public function get_sku_title(): string {
return $this->get_title_for( 'sku' );
}

/**
* Print the SKU title
*
Expand All @@ -800,7 +800,7 @@ public function get_sku_title(): string {
public function sku_title(): void {
echo $this->get_sku_title();
}

/**
* Get the weight title
*
Expand All @@ -809,7 +809,7 @@ public function sku_title(): void {
public function get_weight_title(): string {
return $this->get_title_for( 'weight' );
}

/**
* Print the weight title
*
Expand All @@ -818,7 +818,7 @@ public function get_weight_title(): string {
public function weight_title(): void {
echo $this->get_weight_title();
}

/**
* Get the notes title
*
Expand All @@ -827,7 +827,7 @@ public function weight_title(): void {
public function get_notes_title(): string {
return $this->get_title_for( 'notes' );
}

/**
* Print the notes title
*
Expand All @@ -836,7 +836,7 @@ public function get_notes_title(): string {
public function notes_title(): void {
echo $this->get_notes_title();
}

/**
* Get the customer notes title
*
Expand All @@ -845,7 +845,7 @@ public function notes_title(): void {
public function get_customer_notes_title(): string {
return $this->get_title_for( 'customer_notes' );
}

/**
* Print the customer notes title
*
Expand All @@ -854,7 +854,7 @@ public function get_customer_notes_title(): string {
public function customer_notes_title(): void {
echo $this->get_customer_notes_title();
}

/**
* Get the title for a specific slug
*
Expand Down Expand Up @@ -923,9 +923,9 @@ public function get_title_for( string $slug ): string {
$title = '';
break;
}

$title = apply_filters( 'wpo_wcpdf_title_for', $title, $slug, $this ); // used by Pro to translate strings

return apply_filters( "wpo_wcpdf_{$slug}_title", $title, $this );
}

Expand Down
18 changes: 12 additions & 6 deletions includes/documents/class-wcpdf-invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,35 @@ public function storing_settings_enabled() {
*/
public function get_title() {
// override/not using $this->title to allow for language switching!
return apply_filters( 'wpo_wcpdf_document_title', __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' ), $this );
$title = __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' );
$title = apply_filters_deprecated( "wpo_wcpdf_{$this->slug}_title", array( $title, $this ), '3.8.7', 'wpo_wcpdf_document_title' ); // deprecated
return apply_filters( 'wpo_wcpdf_document_title', $title, $this );
}

/**
* Get the document number title
*
* @return string
*/
public function get_number_title() {
// override to allow for language switching!
return apply_filters( 'wpo_wcpdf_document_number_title', __( 'Invoice Number:', 'woocommerce-pdf-invoices-packing-slips' ), $this );
$title = __( 'Invoice Number:', 'woocommerce-pdf-invoices-packing-slips' );
$title = apply_filters_deprecated( "wpo_wcpdf_{$this->slug}_number_title", array( $title, $this ), '3.8.7', 'wpo_wcpdf_document_number_title' ); // deprecated
return apply_filters( 'wpo_wcpdf_document_number_title', $title, $this );
}

/**
* Get the document date title
*
* @return string
*/
public function get_date_title() {
// override to allow for language switching!
return apply_filters( 'wpo_wcpdf_document_date_title', __( 'Invoice Date:', 'woocommerce-pdf-invoices-packing-slips' ), $this );
$title = __( 'Invoice Date:', 'woocommerce-pdf-invoices-packing-slips' );
$title = apply_filters_deprecated( "wpo_wcpdf_{$this->slug}_date_title", array( $title, $this ), '3.8.7', 'wpo_wcpdf_document_date_title' ); // deprecated
return apply_filters( 'wpo_wcpdf_document_date_title', $title, $this );
}

/**
* Get the shipping address title
*
Expand Down
16 changes: 11 additions & 5 deletions includes/documents/class-wcpdf-packing-slip.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,33 @@ public function __construct( $order = 0 ) {
*/
public function get_title() {
// override/not using $this->title to allow for language switching!
return apply_filters( 'wpo_wcpdf_document_title', __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ), $this );
$title = __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' );
$title = apply_filters_deprecated( "wpo_wcpdf_{$this->slug}_title", array( $title, $this ), '3.8.7', 'wpo_wcpdf_document_title' ); // deprecated
return apply_filters( 'wpo_wcpdf_document_title', $title, $this );
}

/**
* Get the document number title
*
* @return string
*/
public function get_number_title() {
// override to allow for language switching!
return apply_filters( 'wpo_wcpdf_document_number_title', __( 'Packing Slip Number:', 'woocommerce-pdf-invoices-packing-slips' ), $this );
$title = __( 'Packing Slip Number:', 'woocommerce-pdf-invoices-packing-slips' );
$title = apply_filters_deprecated( "wpo_wcpdf_{$this->slug}_number_title", array( $title, $this ), '3.8.7', 'wpo_wcpdf_document_number_title' ); // deprecated
return apply_filters( 'wpo_wcpdf_document_number_title', $title, $this );
}

/**
* Get the document date title
*
* @return string
*/
public function get_date_title() {
// override to allow for language switching!
return apply_filters( 'wpo_wcpdf_document_date_title', __( 'Packing Slip Date:', 'woocommerce-pdf-invoices-packing-slips' ), $this );
$title = __( 'Packing Slip Date:', 'woocommerce-pdf-invoices-packing-slips' );
$title = apply_filters_deprecated( "wpo_wcpdf_{$this->slug}_date_title", array( $title, $this ), '3.8.7', 'wpo_wcpdf_document_date_title' ); // deprecated
return apply_filters( 'wpo_wcpdf_document_date_title', $title, $this );
}

public function get_filename( $context = 'download', $args = array() ) {
Expand Down
Loading