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

New: comply with WP Plugin Check standards #899

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
455b4c2
Wip
alexmigf Oct 28, 2024
91ba102
Tweak
alexmigf Oct 28, 2024
d74d02d
Wip
alexmigf Oct 29, 2024
321a2ac
Update settings-page.php
alexmigf Oct 29, 2024
5e5f652
Update Admin.php
alexmigf Oct 29, 2024
2a76d92
Wip
alexmigf Oct 29, 2024
41bfa95
Update OrderDocument.php
alexmigf Oct 29, 2024
72928bb
Update OrderDocumentMethods.php
alexmigf Oct 29, 2024
4afb52a
Update OrderDocumentMethods.php
alexmigf Oct 29, 2024
d17e056
Update OrderDocumentMethods.php
alexmigf Oct 29, 2024
369dc68
Update Install.php
alexmigf Oct 29, 2024
b87663d
Update Settings.php
alexmigf Oct 29, 2024
1fa9e91
Wip
alexmigf Oct 29, 2024
8bc4a37
Wip
alexmigf Oct 29, 2024
602b53b
Wip
alexmigf Oct 29, 2024
a66a364
Update Main.php
alexmigf Oct 29, 2024
00f6cb8
Tweaks
alexmigf Oct 29, 2024
c2eb4c6
Small fixes
alexmigf Oct 29, 2024
05de395
Tweaks
alexmigf Oct 29, 2024
61b0f4b
Ignore errors
alexmigf Oct 29, 2024
2747a90
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Oct 31, 2024
26c57cf
Tweaks
alexmigf Oct 31, 2024
724af2d
Improves `get_document_pdf_attachment()` and fixes issue in Semaphore…
alexmigf Oct 31, 2024
efb85aa
Update Main.php
alexmigf Oct 31, 2024
1a657f9
Tweaks
alexmigf Nov 1, 2024
b25d4d1
Rename $lock to $semaphore
alexmigf Nov 1, 2024
dd21de1
Fix
alexmigf Nov 1, 2024
659b859
Fixes
alexmigf Nov 1, 2024
960c3ce
Tweaks
alexmigf Nov 1, 2024
fec4025
Fix
alexmigf Nov 1, 2024
ef5745b
Update OrderDocumentMethods.php
alexmigf Nov 1, 2024
b66b1c2
Tweaks
alexmigf Nov 1, 2024
1b425eb
Update Settings.php
alexmigf Nov 1, 2024
c1c5296
Tweaks
alexmigf Nov 1, 2024
7fd3f60
Tweaks
alexmigf Nov 1, 2024
f2d6d1b
Improvements
alexmigf Nov 1, 2024
db37b10
Tweaks
alexmigf Nov 1, 2024
7f23995
Update Main.php
alexmigf Nov 1, 2024
5e04eba
Update Main.php
alexmigf Nov 1, 2024
6e8837b
Update Main.php
alexmigf Nov 1, 2024
3e8318e
Update SettingsDebug.php
alexmigf Nov 4, 2024
1e97e57
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Nov 4, 2024
f6b06df
Tweaks
alexmigf Nov 11, 2024
411fe99
Generate minified JS and CSS files
alexmigf Nov 11, 2024
e01c64a
Improvement
alexmigf Nov 11, 2024
b2b817f
Tweaks
alexmigf Nov 11, 2024
1abd77d
Update advanced-status.php
alexmigf Nov 11, 2024
b6cdaef
Update Main.php
alexmigf Nov 11, 2024
8db09bb
Update OrderDocument.php
alexmigf Nov 11, 2024
0fc3991
Update OrderDocument.php
alexmigf Nov 11, 2024
2ad3cfc
Update advanced-status.php
alexmigf Nov 11, 2024
aa6ae1a
Update advanced-status.php
alexmigf Nov 11, 2024
b4ab3f6
Wip
alexmigf Nov 11, 2024
119b4e8
Update wpo-ips-functions.php
alexmigf Nov 11, 2024
46c0b21
Update advanced-status.php
alexmigf Nov 11, 2024
9cc368c
Update advanced-status.php
alexmigf Nov 11, 2024
f268a4a
Tweaks
alexmigf Nov 11, 2024
3e8147c
Tweaks
alexmigf Nov 11, 2024
eba36c3
Update Main.php
alexmigf Nov 11, 2024
96a4115
New `wpo_wcpdf_reuse_attachment` filter
alexmigf Nov 11, 2024
e062fb4
Update Main.php
alexmigf Nov 12, 2024
99d2d68
Update Main.php
alexmigf Nov 12, 2024
2ee9196
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Nov 19, 2024
ef49aeb
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Nov 20, 2024
3a99a57
Delete templates
alexmigf Nov 22, 2024
4bc85e0
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Nov 22, 2024
c4ec1b0
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 4, 2024
2422fb8
Update wpo-ips-functions.php
alexmigf Dec 11, 2024
d3d84c7
Update wpo-ips-functions.php
alexmigf Dec 11, 2024
6c2c9a0
Fix
alexmigf Dec 11, 2024
e4ca013
Reinstate template changes
alexmigf Dec 11, 2024
3be8547
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 11, 2024
f28f5e4
Update OrderDocument.php
alexmigf Dec 11, 2024
5291ae2
Update wpo-ips-functions.php
alexmigf Dec 11, 2024
4ffc956
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 13, 2024
7289edd
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 16, 2024
e2343fd
Generate minified JS and CSS files
alexmigf Dec 16, 2024
0d0343b
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 17, 2024
bb70baa
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 18, 2024
cc9f15e
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Dec 20, 2024
6b17249
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Jan 9, 2025
2100c37
Generate minified JS and CSS files
alexmigf Jan 9, 2025
93f3940
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Jan 20, 2025
7ceff32
Generate minified JS and CSS files
alexmigf Jan 20, 2025
5a023c6
Merge branch 'main' into apply-wp-plugin-check-fixes
alexmigf Jan 22, 2025
1d8d702
v4.0.0-beta-1
alexmigf Jan 22, 2025
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 assets/css/debug-tools.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.wcpdf_debug_settings_sections,
#debug-tools {
width: calc(100% - 4em);
width: 100%;
max-width: 50vw;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/css/debug-tools.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions assets/css/jquery-ui.min.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion assets/css/settings-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ body.woocommerce_page_wpo_wcpdf_options_page {
font-size: 12px;
}

#wpo-wcpdf-settings .system-status-table {
#wpo-wcpdf-settings .system-status-table,
#wpo-wcpdf-settings .form-table {
margin-top: 2em;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/css/settings-styles.min.css

Large diffs are not rendered by default.

247 changes: 160 additions & 87 deletions includes/Admin.php

Large diffs are not rendered by default.

108 changes: 50 additions & 58 deletions includes/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,18 @@ public static function instance() {
}

public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'backend_scripts_styles' ) );
}

/**
* Load styles & scripts
*/
public function frontend_scripts_styles ( $hook ) {
# none yet
}

/**
* Load styles & scripts
*/
public function backend_scripts_styles ( $hook ) {
public function backend_scripts_styles( $hook ) {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$pdfjs_version = '4.3.136';

global $wp_version;

if ( WPO_WCPDF()->admin->is_order_page() ) {

// STYLES
Expand Down Expand Up @@ -94,10 +87,10 @@ public function backend_scripts_styles ( $hook ) {

// only load on our own settings page
// maybe find a way to refer directly to WPO\IPS\Settings::$options_page_hook ?
if (
in_array( $hook, array( 'woocommerce_page_wpo_wcpdf_options_page', 'settings_page_wpo_wcpdf_options_page' ) ) ||
( isset( $_GET['page'] ) && 'wpo_wcpdf_options_page' === $_GET['page'] )
) {
if ( ! empty( $hook ) && false !== strpos( $hook, 'wpo_wcpdf_options_page' ) ) {
$tab = filter_input( INPUT_GET, 'tab', FILTER_DEFAULT );
$tab = sanitize_text_field( $tab );
wp_enqueue_style(
'wpo-wcpdf-settings-styles',
WPO_WCPDF()->plugin_url() . '/assets/css/settings-styles'.$suffix.'.css',
Expand Down Expand Up @@ -208,6 +201,50 @@ public function backend_scripts_styles ( $hook ) {
WPO_WCPDF_VERSION
);

// status/debug page scripts
if ( 'debug' === $tab ) {
wp_enqueue_style(
'wpo-wcpdf-jquery-ui-styles',
WPO_WCPDF()->plugin_url() . '/assets/css/jquery-ui' . $suffix . '.css',
'1.14.0'
);

wp_enqueue_script( 'jquery-ui-datepicker' );

wp_enqueue_style(
'wpo-wcpdf-debug-tools-styles',
WPO_WCPDF()->plugin_url() . '/assets/css/debug-tools'.$suffix.'.css',
WPO_WCPDF_VERSION
);

wp_enqueue_script(
'wpo-wcpdf-debug',
WPO_WCPDF()->plugin_url() . '/assets/js/debug-script'.$suffix.'.js',
array( 'jquery', 'jquery-blockui', 'jquery-ui-datepicker' ),
WPO_WCPDF_VERSION
);

wp_localize_script(
'wpo-wcpdf-debug',
'wpo_wcpdf_debug',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpo_wcpdf_debug_nonce' ),
'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: 1. open anchor tag, 2. close anchor tag */
__( '<strong>Enabled</strong>: %1$sclick here%2$s to start using the tools.', 'woocommerce-pdf-invoices-packing-slips' ),
'<a href="' . esc_url( add_query_arg( 'section', 'tools' ) ) . '#danger_zone">',
'</a>'
),
),
)
);
}
}

if (
Expand All @@ -230,51 +267,6 @@ public function backend_scripts_styles ( $hook ) {
)
);
}

// status/debug page scripts
if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wpo_wcpdf_options_page' && isset( $_REQUEST['tab'] ) && $_REQUEST['tab'] == 'debug' ) {
wp_enqueue_style(
'wpo-wcpdf-jquery-ui-styles',
'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'
);

wp_enqueue_script( 'jquery-ui-datepicker' );

wp_enqueue_style(
'wpo-wcpdf-debug-tools-styles',
WPO_WCPDF()->plugin_url() . '/assets/css/debug-tools'.$suffix.'.css',
WPO_WCPDF_VERSION
);

wp_enqueue_script(
'wpo-wcpdf-debug',
WPO_WCPDF()->plugin_url() . '/assets/js/debug-script'.$suffix.'.js',
array( 'jquery', 'jquery-blockui', 'jquery-ui-datepicker' ),
WPO_WCPDF_VERSION
);

wp_localize_script(
'wpo-wcpdf-debug',
'wpo_wcpdf_debug',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpo_wcpdf_debug_nonce' ),
'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: 1. open anchor tag, 2. close anchor tag */
__( '<strong>Enabled</strong>: %1$sclick here%2$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
4 changes: 2 additions & 2 deletions includes/Documents/BulkDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ public function merge_documents( $html_content ) {
public function output_pdf( $output_mode = 'download' ) {
$pdf = $this->get_pdf();
wcpdf_pdf_headers( $this->get_filename(), $output_mode, $pdf );
echo $pdf;
echo $pdf; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
die();
}

public function output_html() {
echo $this->get_html();
echo $this->get_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
die();
}

Expand Down
8 changes: 6 additions & 2 deletions includes/Documents/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public function init_settings() {
* PDF settings fields
*/
public function get_pdf_settings_fields( $option_name ) {
$wp_filesystem = wpo_wcpdf_get_wp_filesystem();

$settings_fields = array(
array(
'type' => 'section',
Expand Down Expand Up @@ -232,7 +234,7 @@ public function get_pdf_settings_fields( $option_name ) {
'id' => 'attach_to_email_ids',
'fields_callback' => array( $this, 'get_wc_emails' ),
/* translators: directory path */
'description' => !is_writable( WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ) ? '<span class="wpo-warning">' . sprintf( __( 'It looks like the temp folder (<code>%s</code>) is not writable, check the permissions for this folder! Without having write access to this folder, the plugin will not be able to email invoices.', 'woocommerce-pdf-invoices-packing-slips' ), WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ).'</span>':'',
'description' => ! $wp_filesystem->is_writable( WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ) ? '<span class="wpo-warning">' . sprintf( __( 'It looks like the temp folder (<code>%s</code>) is not writable, check the permissions for this folder! Without having write access to this folder, the plugin will not be able to email invoices.', 'woocommerce-pdf-invoices-packing-slips' ), WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ).'</span>':'',
)
),
array(
Expand Down Expand Up @@ -570,6 +572,8 @@ public function get_pdf_settings_fields( $option_name ) {
* UBL settings fields
*/
public function get_ubl_settings_fields( $option_name ) {
$wp_filesystem = wpo_wcpdf_get_wp_filesystem();

$settings_fields = array(
array(
'type' => 'section',
Expand Down Expand Up @@ -599,7 +603,7 @@ public function get_ubl_settings_fields( $option_name ) {
'id' => 'attach_to_email_ids',
'fields_callback' => array( $this, 'get_wc_emails' ),
/* translators: directory path */
'description' => ! is_writable( WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ) ? '<span class="wpo-warning">' . sprintf( __( 'It looks like the temp folder (<code>%s</code>) is not writable, check the permissions for this folder! Without having write access to this folder, the plugin will not be able to email invoices.', 'woocommerce-pdf-invoices-packing-slips' ), WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ).'</span>':'',
'description' => ! $wp_filesystem->is_writable( WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ) ? '<span class="wpo-warning">' . sprintf( __( 'It looks like the temp folder (<code>%s</code>) is not writable, check the permissions for this folder! Without having write access to this folder, the plugin will not be able to email invoices.', 'woocommerce-pdf-invoices-packing-slips' ), WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ).'</span>':'',
)
),
array(
Expand Down
Loading
Loading