Giter Club home page Giter Club logo

wp-fields's People

Contributors

chrico avatar luislard avatar szepeviktor avatar widoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wp-fields's Issues

Wrong method names in documentation

The Problem

In many cases, the documentation mentions method names that are incorrect.

Possible Cause

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.

Suggested Solution

Update the documentation to reflect the new names.

Do not wrap hidden fields within row view

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 inconsistent with function

The Problem

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.

Suggested Solution

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;
    }

  	// ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.