Skip to content

Commit

Permalink
Adds notice to Danger Zone tools when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmigf committed Oct 6, 2023
1 parent 5cd02ff commit 579815d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions assets/js/debug-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ jQuery( function( $ ) {
}
} ).trigger( 'change' );

// danger zone enabled notice
if ( true === wpo_wcpdf_debug.danger_zone['enabled'] ) {
let notice = '<div class="notice notice-warning inline"><p>' + wpo_wcpdf_debug.danger_zone['message'] + '</p></div>';
$( "input#enable_danger_zone_tools" ).closest( 'td' ).find( '.description' ).append( notice );
}

// number search
$( document.body ).on( 'click', '#wpo-wcpdf-settings a.number-search-button', function( e ) {
e.preventDefault();
Expand Down
9 changes: 9 additions & 0 deletions includes/class-wcpdf-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ public function backend_scripts_styles ( $hook ) {
'download_label' => __( 'Download', 'woocommerce-pdf-invoices-packing-slips' ),
'confirm_reset' => __( 'Are you sure you want to reset this settings? This cannot be undone.', 'woocommerce-pdf-invoices-packing-slips' ),
'select_document_type' => __( 'Please select a document type', 'woocommerce-pdf-invoices-packing-slips' ),
'danger_zone' => array(
'enabled' => isset( WPO_WCPDF()->settings->debug_settings['enable_danger_zone_tools'] ) ? true : false,
'message' => sprintf(
/* translators: <a> tags */
__( '<strong>Enabled</strong>: %sclick here%s to start using the tools.', 'woocommerce-pdf-invoices-packing-slips' ),
'<a href="' . esc_url( add_query_arg( 'section', 'tools' ) ) . '#danger_zone">',
'</a>'
),
),
)
);

Expand Down
7 changes: 1 addition & 6 deletions includes/settings/class-wcpdf-settings-debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,7 @@ public function init_settings() {
'args' => array(
'option_name' => $option_name,
'id' => 'enable_danger_zone_tools',
'description' => sprintf(
/* translators: <a> tags */
__( 'Enables the danger zone tools %shere%s. The actions performed by these tools are irreversible!', 'woocommerce-pdf-invoices-packing-slips' ),
'<a href="' . esc_url( add_query_arg( 'section', 'tools' ) ) . '">',
'</a>'
),
'description' => __( 'Enables the danger zone tools. The actions performed by these tools are irreversible!', 'woocommerce-pdf-invoices-packing-slips' ),
)
),
);
Expand Down

0 comments on commit 579815d

Please sign in to comment.