Giter VIP home page Giter VIP logo

silk's Introduction

Silk

Travis Build Coveralls Scrutinizer Code Quality Gitter Packagist Packagist

A modern API for WordPress.

The current API is still evolving as the project grows closer to v1.0 and may introduce breaking changes.

Use with confidence, upgrade with care.

What is Silk?

Silk is a library designed as a thin layer on top of WordPress, abstracting away the mess of functions into a clean and expressive object-oriented API. Use as much or little as you want, while maintaining compatibility with everything else that's meant to work with WordPress.

Read the documentation for examples and more.

Or check out the API documentation if you're into that kind of thing.

Installation

composer require silk/silk

Contributing

Contributions are welcome! If you're interested in contributing to the project, please open an issue first. I would hate to decline a Pull Request forged by hours of effort for any reason, so please read the contribution guidelines first.

silk's People

Contributors

aaemnnosttv avatar scrutinizer-auto-fixer avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

silk's Issues

Remove deprecated methods

A few methods have been deprecated which should be removed.

These are named constructors which are no longer necessary at all.

  • Silk\Post\Model::fromWpPost - can use ::make(WpPost) or simply new Model(WpPost)
  • Silk\Term\Model::fromWpTerm - can use ::make(WpTerm) or simply new Model(WpTerm)

Add method for returning IDs from a query builder

As it is, using a Query Builder with a model will always return a collection of model instances.

This means doing a bunch of queries that may not be necessary if IDs are all that are needed.

This would likely be possible via a new alternate terminating method of the query builder, such as resultIds() and/or another builder method like ids().

Move WordPress models to new package

Silk currently comes bundled with models for all initial post types, terms, and users.

These allow for users to start using Silk models right away for these initial types without the need to create model classes for them.

While these may be useful for some, they're better off being maintained apart from the core library.

Roadmap

In no particular order:

  • Taxonomies & Terms
  • Post Type registration
  • Query Builder
  • Post Relationships
  • Actions & Filters
  • Users
  • Roles & capabilities
  • Options & Transients
  • Themes
  • Plugins
  • CLI

Taxonomy Builder

A class dedicated to building up a new Taxonomy to be registered using a fluent api, similar to what we can do now with the PostTypeBuilder.

Query\Builder Name

The Query\Builder class is specific to posts, it should probably be renamed to Post\PostQueryBuilder.

Taxonomy builder missing public setter

Post Type builders have open and closed methods for setting the public property of a type's registration args.

This should be present for the taxonomy builder as well for consistency.

Improve PostTypeBuilder label handling with defaults

As it is, the methods for setting the singular and plural post type labels only set two keys in the array of labels. Ideally, these methods (or others if it makes more sense) should allow for setting all of the other labels which use them while remaining mutable.

The biggest consideration here is probably making sure that i18n is not sacrificed in the process.

Taxonomy Model

A class for modeling an individual Taxonomy. Should be able to do things like providing useful methods to query it's terms, and the PostTypes it holds relationships with.

Soft Model Retrieval Methods

As it is, the current methods for retrieving a model instance are all "hard" methods, in that they all throw a not found exception in the event that there is no record found for the given ID, slug, etc.

There are times however when an exception is not necessary and a simple falsy value would be more efficient. This would allow for more flexibility by not forcing the user to handle exceptions in all cases.

Document 0.10

Update docs to include changes for 0.10

Items to document

  • Conditional Hooks
  • Taxonomy
  • Taxonomy Builder
  • Label handling with Post/Taxonomy Builders
  • Term Models
  • Term Query Builder
  • Update class name references
  • Meta all/collect methods

Query Scopes

Right now there currently is no way to add query scopes via a Query\Builder.

The closest you can get is to define the scope all at once with a new query from the model like so:

class Thing extends Silk\Post\Model
{
    public static function published()
    {
        return static::query()->withStatus('published');
    }
}

This works, but doesn't allow for composition using multiple scopes as each call starts a new query.

Query scopes should be chainable methods to allow for composing a complex scope.

Relationships

The ability to define relationships between models.

At a minimum, this should include:

  • One to One
  • One to Many
  • Many to Many

The relationship should be polymorphic, so we can use the same syntax for all types:

PostModel <--> TermModel
TermModel <--> TermModel
PostModel <--> PostModel

Depends on #5.

Artwork / Logo

We need some sexy branding. Nobody will ever use this unless something somewhere looks cool.

User Model

A class to model a single user.

Should provide CRUD methods, similar to Post and Term models, as well as methods for interacting with user meta, add/remove/check roles or capabilities.

Build out Term Query Builder

Need more methods for building a more robust term query.

Easy targets for methods:

  • orderby
  • order
  • include
  • exclude
  • hierarchical
  • child_of

Term Model

A class to model a term object, similar to Silk\Post\Model. Will have methods for CRUD operations, getting related taxonomies, post models, and term meta.

Update Collection library

tightenco/collect which provides the Illuminate\Support\Collection class is currently locked to 5.2.* for compatibility.

The library has a breaking change as of 5.3 which affects a few methods.

From the docs:


Key / Value Order Change

The first, last, and contains collection methods all pass the "value" as the first parameter to their given callback Closure. For example:

$collection->first(function ($value, $key) {
    return ! is_null($value);
});

In previous versions of Laravel, the $key was passed first. Since most use cases are only interested in the $value it is now passed first. You should do a "global find" in your application for these methods to verify that you are expecting the $value to be passed as the first argument to your Closure.


Upgrading the library will provide access to newer methods as well as provide better compatibility with other illuminate packages, should you so desire.

In the future, this Collections in Silk may change to use a namespaced version rather than relying on a 3rd party dependency.

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.