inpsyde / metaboxorchestra Goto Github PK
View Code? Open in Web Editor NEWA Composer package that provides metabox orchestration for WordPress.
License: GNU General Public License v2.0
A Composer package that provides metabox orchestration for WordPress.
License: GNU General Public License v2.0
I tested a plugin with PHP 8.1 which uses metabox-orchestra and see some deprecation warnings.
We can add bool
, void
needs PHP 7.1 and mixed
needs PHP 8.0.
Should we add #[\ReturnTypeWillChange]
to the methods?
PHP 8.1
Deprecated: Return type of MetaboxOrchestra\BoxInfo::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .../vendor/inpsyde/metabox-orchestra/src/BoxInfo.php on line 107
Deprecated: Return type of MetaboxOrchestra\BoxInfo::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .../vendor/inpsyde/metabox-orchestra/src/BoxInfo.php on line 115
Deprecated: Return type of MetaboxOrchestra\BoxInfo::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .../vendor/inpsyde/metabox-orchestra/src/BoxInfo.php on line 123
Deprecated: Return type of MetaboxOrchestra\BoxInfo::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .../vendor/inpsyde/metabox-orchestra/src/BoxInfo.php on line 131
Right now the MetBox Orchestra is using global $wp_meta_boxes;
in Boxes.php
Class to check if there is a hook in order to print the Terms Metboxes and it's dose not remove the hook after it's being executed which cause the possibility of same MetaBoxes of being printer again.
For Example:
If other plugins use the same structure to print the MetaBoxes terms for example MultiLanguage Press
which basically use same exact code, and if any package use MetaBoxes Orchestra Package to register the terms MetBoxes the terms MetaBoxes will be printed twice.
Suggested solution:
Remove the current hook from $wp_meta_boxes;
after it's being executed to make sure no other plugin/packages will print the MetaBoxes again.
Code Before:
/**
* WordPress does not print metaboxes for terms, let's fix this.
*
* @param \WP_Term $term
*/
public function print_term_boxes( \WP_Term $term ) {
if ( current_filter() !== "{$term->taxonomy}_edit_form" ) {
return;
}
global $wp_meta_boxes;
if ( empty( $wp_meta_boxes[ "edit-{$term->taxonomy}" ] ) ) {
return;
}
$script = '!function(J,D){J(function(){J(".meta-box-sortables").sortable();'
. 'J(D).on("click",".termbox-container button.handlediv",function(){'
. 'var D=J(this),t=D.siblings(".inside");t.toggle();var e=t.is(":visible")?"true":"false";'
. 'D.attr("aria-expanded",e)})})}(jQuery,document);';
wp_enqueue_script( 'jquery-ui-sortable' );
wp_add_inline_script( 'jquery-ui-sortable', $script );
echo '<div id="poststuff"><div class="postbox-container termbox-container">';
// WordPress does not print metaboxes for terms, let's fix this
do_meta_boxes( "edit-{$term->taxonomy}", 'side', $term );
do_meta_boxes( "edit-{$term->taxonomy}", 'normal', $term );
do_meta_boxes( "edit-{$term->taxonomy}", 'advanced', $term );
echo '</div></div>';
}
Code After:
/**
* WordPress does not print metaboxes for terms, let's fix this.
*
* @param \WP_Term $term
*/
public function print_term_boxes( \WP_Term $term ) {
if ( current_filter() !== "{$term->taxonomy}_edit_form" ) {
return;
}
global $wp_meta_boxes;
if ( empty( $wp_meta_boxes[ "edit-{$term->taxonomy}" ] ) ) {
return;
}
$script = '!function(J,D){J(function(){J(".meta-box-sortables").sortable();'
. 'J(D).on("click",".termbox-container button.handlediv",function(){'
. 'var D=J(this),t=D.siblings(".inside");t.toggle();var e=t.is(":visible")?"true":"false";'
. 'D.attr("aria-expanded",e)})})}(jQuery,document);';
wp_enqueue_script( 'jquery-ui-sortable' );
wp_add_inline_script( 'jquery-ui-sortable', $script );
echo '<div id="poststuff"><div class="postbox-container termbox-container">';
// WordPress does not print metaboxes for terms, let's fix this
do_meta_boxes( "edit-{$term->taxonomy}", 'side', $term );
do_meta_boxes( "edit-{$term->taxonomy}", 'normal', $term );
do_meta_boxes( "edit-{$term->taxonomy}", 'advanced', $term );
echo '</div></div>';
// remove the hook after beign excuted
unset($wp_meta_boxes["edit-{$term->taxonomy}"]);
}
Does make sense since the class does not implements the following methods by an interface that the class isn't marked as final
.
I understand that's just a data structure but in terms of unit tests correctness I want to mock the instance of that class but obviously it's not possible.
Additional reasons are:
final
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.