chrico / wp-fields Goto Github PK
View Code? Open in Web Editor NEWChriCo Fields is a Composer package (not a plugin) that allows to generate form fields in WordPress.
License: GNU General Public License v3.0
ChriCo Fields is a Composer package (not a plugin) that allows to generate form fields in WordPress.
License: GNU General Public License v3.0
In many cases, the documentation mentions method names that are incorrect.
At first, the library was written using WP code standards, and the names used to be e.g. set_field()
. Later, the library got re-factored to use a more modern standard, where the names are e.g. withField()
; but the documentation was not updated.
Update the documentation to reflect the new names.
I noticed that hidden fields are treated like normal visible fields, so they are put within a table row when the form get rendered.
This has the disadvantage to introduce extra vertical space in the form where apparently there's nothing but the field exists, it's just hidden.
Wouldn't be ok to extract the hidden fields when the form is rendered and move them as direct childs of the form markup instead of within a table row?
Method names such as ElementInterface#withAttribute()
return the same instance. This makes them nothing more than a setter. However, a setter would be named e.g. setAttribute()
. Names such as withAttribute()
may mislead the consumer to think that it would return a new instance. Alas, they are simply mutable, and mutability is a bad thing most of the time.
The problem is further enhanced by the fact that these methods do not declare what they return.
Have the methods return a new instance every time, and declare the return type everywhere, including the interface. Example:
class Element implements
ElementInterface,
LabelAwareInterface,
ErrorAwareInterface,
DescriptionAwareInterface
{
// ...
/**
* Creates a new element with the specified attribute value.
*
* @param string $key The attribute key.
* @param bool|int|string $value The attribute value/
*
* @return Element The new element which has the given value of the specified attribute.
*/
public function withAttribute(string $key, $value): ElementInterface
{
$element = clone $this;
$element->attributes[$key] = $value;
return $element;
}
// ...
}
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.