-
Notifications
You must be signed in to change notification settings - Fork 48
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
Improvements for "PDF document data" metabox #757
Closed
Closed
Changes from 5 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
72c030f
Move PDF document data markup to views
MohamadNateqi 69e9b3d
WPCS
MohamadNateqi 34ee8d1
Update and improvements for metabox markup
MohamadNateqi e39996f
Add auto update documents data using heartbeat
MohamadNateqi 0058f6f
Generate minified JS and CSS files
MohamadNateqi ac6ec0d
Fix nonce validation
MohamadNateqi 6ecfebe
Validate the document type
MohamadNateqi 2251d16
Improve performance
MohamadNateqi 00c299c
Better sanitize
MohamadNateqi ed6bc11
WPCS
MohamadNateqi 7fd96b7
Add DocBlock
MohamadNateqi 75c411b
Improvement
MohamadNateqi acc87cb
Fix bugs
MohamadNateqi 2b66b21
Indentation fixes
alexmigf 46ee270
Improve the meta box method to print all documents data,
MohamadNateqi bcbb368
Update version
MohamadNateqi 969f928
Merge branch 'main' into document-data-metabox
alexmigf 69e812e
Rename a parameter
MohamadNateqi 146180c
Fix HPOS compatibility
MohamadNateqi 0d02eda
Fix input width issue on Firefox
MohamadNateqi fedccf6
Merge branch 'main' into document-data-metabox
MohamadNateqi b407d25
Merge remote-tracking branch 'origin/document-data-metabox' into docu…
MohamadNateqi 8fa23bf
Generate minified JS and CSS files
MohamadNateqi ab89e8c
Fix a bug
MohamadNateqi d19708a
Rename a parameter
MohamadNateqi bcccb26
Fix not removing dependent document
MohamadNateqi f9cbcca
Check if we have an order ID
MohamadNateqi 8f7c72c
Better name for a hook
MohamadNateqi db3c341
Use another AS method
MohamadNateqi 46e8aa9
Generate minified JS and CSS files
MohamadNateqi a13139e
Merge branch 'main' into document-data-metabox
MohamadNateqi 813e746
Add document number to output
MohamadNateqi e424202
Revert outputting all documents in the meta box
MohamadNateqi 721ef11
Merge branch 'main' into document-data-metabox
MohamadNateqi a58ff0f
Improvements for the default data labels
MohamadNateqi df58528
WPCS
MohamadNateqi 0bbec3f
Improvement
MohamadNateqi 55b47a8
Update the usage of a filter
MohamadNateqi a6c5927
Introducing a new propery in Order_Document class to store prerequisi…
MohamadNateqi 48d0371
Check document prerequisites in `is_allowed()` method
MohamadNateqi 2a9d4e9
Introduce the new `do_prerequisites_exist()` method
MohamadNateqi 2393848
Remove an unnecessary filter
MohamadNateqi 8c6ed82
Update `pdf_actions_meta_box()` method
MohamadNateqi c391c99
Updates
MohamadNateqi 6e4349d
Merge branch 'main' into document-data-metabox
MohamadNateqi 08cff80
Revert changes and improvements
MohamadNateqi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this would work below line
1049
? Because we are not forcing the document generation at this stage, so it's safe to call the document first.This can be also applied to the
data_input_box_content()
inside the loop I think.And maybe inside
is_allowed()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add checking prerequisites inside the
is_allowed()
method, inside the condition you mentioned, but again we need to change the value that thewpo_wcpdf_bypass_prerequisites_restriction
filter returns, before line1049
, since otherwisewcpdf_get_document()
method won't return the document.So, I think it's again adding a filter above the line
1049
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this commit: 08cff80, I added again checking prerequisites to
is_allowed()
method, but made itfalse
as default, since otherwise it'll allow creation of documents without prerequisites, and also used the filter you mentioned.Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could avoid having it inside
is_allowed()
, and call it when you need to check theis_allowed()
output. I think returning an empty array seems strange to me and a bit like hacking.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't add checking prerequisites to the
is_allowed()
method, thewcpdf_get_document()
method will return a document even if the prerequisites of it don't exist. so I thought maybe it should be inside that as default?You're right.
In the recent commit, I used the filter you mentioned:
wpo_wcpdf_bypass_prerequisites_restriction
. What do you think about it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since a document object is required to call the
do_prerequisites_exist()
, to check the prerequisite before forcing the document generation, I must call thewcpdf_get_document()
again without the third parameter. I'm not sure if this is a good approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the document from here:
$document = WPO_WCPDF()->documents->get_document( $document_type, $order );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add to
is_allowed()
I think you don't need to add ongenerate_document_ajax()
? I haven't tested.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that to
is_allowed()
method like this:But since it'll bypass by default, it won't affect it. If we change the bypass to
false
by default, then we need to use the filter to change it anywhere we want, for example, for metabox.I think checking prerequisites is a requirement for the
wcpdf_get_document()
method, so maybe it's better to keep the bypassfalse
as default?Also, we can use the
WPO_WCPDF()->documents->get_document()
method here, but I think it'll make the usage ofwcpdf_get_document()
and it should be something that should be considered for using ofwcpdf_get_document()
method.If you agree, I will revert the related change to this matter and open another PR to address this issue, which is related to issue #760.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's better, we continue from there.