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

refactor: improve translation handling #434

Merged
merged 8 commits into from
Nov 27, 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
2 changes: 1 addition & 1 deletion backend/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ function ppom_load_pro_options() {
'ppom-enf-btn-class' => array(
'type' => 'text',
'title' => __( 'Button Class', 'woocommerce-product-addon' ),
'desc' => __( ' Add custom CSS classes to the enquiry form button, separated by commas.', 'woocommerce-product-addon' ),
'desc' => __( 'Add custom CSS classes to the enquiry form button, separated by commas.', 'woocommerce-product-addon' ),
),
'ppom-enf-btn-text-color' => array(
'type' => 'color',
Expand Down
22 changes: 20 additions & 2 deletions backend/templates/admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ class="nmsf-label <?php echo ! $is_available ? 'ppom-is-locked-section' : ''; ?
<div class="nmsf-panel-settings-area <?php echo ! $is_available ? 'ppom-is-locked-panel' : ''; ?>">
<?php if ( ! $is_available ): ?>
<div class="ppom-notice-upsell"><p>
<?php echo sprintf( __( '%s customization is not available on your current plan. %sUpgrade to the Pro%s plan to unlock the ability to fully enable and customize this functionality.', 'woocommerce-product-addon' ), esc_html( $title ), sprintf( '<a href="%s" target="_blank">', esc_url( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), '</a>' ); ?>
<?php echo sprintf(
// translators: %1$s: the name of plugin feature, %2$s: the upgrade link.
__( '%1$s customization is not available on your current plan. %2$s plan to unlock the ability to fully enable and customize this functionality.', 'woocommerce-product-addon' ),
esc_html( $title ),
sprintf(
'<a href="%s" target="_blank">%s</a>',
esc_url( tsdk_translate_link( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ),
__( 'Upgrade to the Pro', 'woocommerce-product-addon' )
)
); ?>
</p>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -142,7 +151,16 @@ class="<?php echo $condition_class; ?>"
<td class="nmsf-section-type" colspan="2">
<?php if ( $is_available && !$is_input_available ): ?>
<div class="ppom-notice-upsell"><p>
<?php echo sprintf( __( '%s customization is not available on your current plan. %sUpgrade to the Pro%s plan to unlock the ability to fully enable and customize this functionality.', 'woocommerce-product-addon' ), esc_html( $title ), sprintf( '<a href="%s" target="_blank">', esc_url( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), '</a>' ); ?>
<?php echo sprintf(
// translators: %1$s: the name of plugin feature, %2$s: opening anchor tag.
__( '%1$s customization is not available on your current plan. %2$s plan to unlock the ability to fully enable and customize this functionality.', 'woocommerce-product-addon' ),
esc_html( $title ),
sprintf(
'<a href="%s" target="_blank">%s</a>',
esc_url( tsdk_translate_link( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ),
__( 'Upgrade to the Pro', 'woocommerce-product-addon' )
)
); ?>
</p>
</div>
<?php endif; ?>
Expand Down
38 changes: 26 additions & 12 deletions classes/admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function add_menu_pages() {

$menu = add_submenu_page(
$page ['parent_slug'],
__( $page ['page_title'], 'woocommerce-product-addon' ),
$page ['page_title'],
__( 'PPOM Fields', 'woocommerce-product-addon' ),
$cap,
$page ['slug'],
Expand All @@ -165,7 +165,7 @@ function add_menu_pages() {
$cap = 'ppom_options_page';
// Menu page for roles set by PPOM Permission Settings
$menu = add_menu_page(
__( $page ['page_title'], 'woocommerce-product-addon' ),
$page ['page_title'],
__( 'PPOM Fields', 'woocommerce-product-addon' ),
$cap,
$page ['slug'],
Expand Down Expand Up @@ -239,14 +239,14 @@ function product_meta() {
// existing meta group tables show only ppom main page
if ( $action != 'new' && $do_meta != 'edit' && $view != 'addons' && $view != 'changelog' ) {
ppom_load_template( 'admin/existing-meta.php' );

// NOTE: Allow only for Tier 1 Plan or lower if license is present.
$should_load_banner = NM_PersonalizedProduct::LICENSE_PLAN_1 >= NM_PersonalizedProduct::get_license_category( intval( apply_filters( 'product_ppom_license_plan', 0 ) ) );

if ( $should_load_banner ) {
do_action( 'themeisle_sdk_load_banner', 'ppom' );
}

}

echo '</div>';
Expand All @@ -270,7 +270,17 @@ function get_products() {
$ppom_id = intval( $_GET['ppom_id'] );
$license_status = apply_filters( 'product_ppom_license_status', '' );
$current_saved_value = $this->get_db_field( $ppom_id );
$pro_multiple_fields = ! ppom_pro_is_installed() || 'valid' !== $license_status ? '</br><i style="font-size: 90%">' . sprintf( __( 'Your current plan supports adding one group of fields per product. To add multiple groups to the same product, please %supgrade%s your plan!', 'woocommerce-product-addon' ), '<a target="_blank" href="' . tsdk_utmify( tsdk_translate_link( PPOM_UPGRADE_URL ), 'multiple-fields' ) . '">', '</a>' ) . '</i>' : '';
$pro_multiple_fields = ! ppom_pro_is_installed() || 'valid' !== $license_status
? '</br><i style="font-size: 90%">' . sprintf(
// translators: %1$s: the link to the store with label 'upgrade'.
__( 'Your current plan supports adding one group of fields per product. To add multiple groups to the same product, please %1$s your plan!', 'woocommerce-product-addon' ),
sprintf(
'<a href="%1$s" target="_blank">%2$s</a>',
esc_url( tsdk_utmify( tsdk_translate_link( PPOM_UPGRADE_URL ), 'multiple-fields' ) ),
__( 'Upgrade to the Pro', 'woocommerce-product-addon' )
)
) . '</i>'
: '';
$select_products_id_component = ( new \PPOM\Attach\SelectComponent() )
->set_id( 'attach-to-products' )
->set_title( __( 'Display on Specific Products', 'woocommerce-product-addon' ) )
Expand Down Expand Up @@ -477,7 +487,7 @@ public function get_wc_categories( $current_values ) {
* Retrieves WooCommerce product tags and checks if they are used in the current values.
*
* @param array $current_values The current values to check against.
*
*
* @return array An array containing the options of product tags and a flag indicating if any category is used.
*/
function get_wc_tags( $current_values ) {
Expand Down Expand Up @@ -635,7 +645,13 @@ function ppom_attach_ppoms() {
self::save_categories_and_tags( $ppom_id, $categories_to_attach, $tags_to_attach );

$response = array(
'message' => "PPOM updated for {$updated_products} Products, {$updated_cat} Categories and {$updated_tags} Tags.",
'message' => sprintf(
// translators: %1$d: number of products, %2$d: number of categories, %3$d: number of tags.
__('PPOM updated for %1$d Products, %2$d Categories and %3$d Tags.', 'woocommerce-product-addon'),
$updated_products,
$updated_cat,
$updated_tags
),
'status' => 'success',
);

Expand Down Expand Up @@ -680,10 +696,8 @@ function validate_plugin() {

echo '<div class="wrap">';
echo '<h2>' . __( 'Provide API key below:', 'woocommerce-product-addon' ) . '</h2>';
echo '<p>' . __( 'If you don\'t know your API key, please login into your: <a target="_blank" href="http://wordpresspoets.com/member-area">Member area</a>', 'woocommerce-product-addon' ) . '</p>';

echo '<form onsubmit="return validate_api_wooproduct(this)">';
echo '<p><label id="plugin_api_key">' . __( 'Entery API key', 'woocommerce-product-addon' ) . ':</label><br /><input type="text" name="plugin_api_key" id="plugin_api_key" /></p>';
echo '<p><label id="plugin_api_key">' . __( 'Enter API key', 'woocommerce-product-addon' ) . ':</label><br /><input type="text" name="plugin_api_key" id="plugin_api_key" /></p>';
wp_nonce_field();
echo '<p><input type="submit" class="button-primary button" name="plugin_api_key" /></p>';
echo '<p id="nm-sending-api"></p>';
Expand Down Expand Up @@ -873,7 +887,7 @@ public function ppom_create_db_tables() {
) {
return;
}

NM_PersonalizedProduct::activate_plugin();
}
}
2 changes: 1 addition & 1 deletion classes/attach-popup/container-view.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ContainerView {
* @return string
*/
public function render() {
return 'Empty!';
return '';
}

/**
Expand Down
Loading
Loading