2017 © Pedro Peláez
 

wordpress-plugin dustpress-js

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

image

devgeniem/dustpress-js

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  • Wednesday, June 27, 2018
  • by devgeniem
  • Repository
  • 15 Watchers
  • 2 Stars
  • 3,676 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 43 Versions
  • 10 % Grown

The README.md

geniem-github-banner, (*1)

DustPress Plugin: DustPress.js

A DustPress plugin that provides a handy JavaScript library for using your DustPress model methods on the front end., (*2)

  • Contributors: devgeniem / Nomafin, villesiltala, godbone
  • Plugin url: https://github.com/devgeniem/dustpress-debugger
  • Tags: dustpress, wordpress, plugins, dustjs, dust.js
  • Requires at least: 4.9.0
  • Requires DustPress version: 1.25.0
  • Tested up to: 5.2.0
  • License: GPL-3.0
  • License URI: http://www.gnu.org/licenses/gpl-3.0.html

Usage

You can call for SomeModel's method SomeMethod with following code:, (*3)

dp( 'SomeModel/SomeMethod', {
    tidy: true,
    args: {
        'foo': 'bar'
    }
}).then( ( data ) => {
    // do what you want with the data
}).catch( ( error ) => {
    // possible error
});

tidy: true parameter cleans up the data tree a bit for more usability. Feel free to try the queries with and without it to see the difference., (*4)

args parameter passes arguments to the PHP side. They can be accessed there with $this->get_args();., (*5)

If you want, you can even render HTML with Dust templates., (*6)

dp( 'SomeModel/SomeMethod', {
    partial: 'SomePartial',
}).then( ( data ) => {
    // do what you want with the data
}).catch( ( error ) => {
    // possible error
});

This code takes the data of SomeMethod and renders it with SomePartial. Variable data then contains the ready html., (*7)

If you still want to get the data output as well, use argument data: true and you will get the resulting data as the second parameter of your success function., (*8)

You can also omit the method completely if you want to get the data of a complete model., (*9)

dp( 'SomeModel/SomeMethod' ).then( ( data ) => {
    // do what you want with the data
}).catch( ( error ) => {
    // possible error
});

It is also possible to use the dp call with the async-await pattern:, (*10)

try {
    var foobar = await dp( 'SomeModel/SomeMethod', {
        tidy: true,
        args: {
            foo: 'bar'
        }
    });
} catch( err ) {
    console.error( err );
}

Now data will consist of an object with the methods' names as keys and their return values as the values. Obviously you can also render that to HTML as well., (*11)

Additional parameters

bypassMainQuery

By default DustPress.js requests bypass WordPress' main WP_Query so that it wouldn't slow the request down when it's not necessary. You can prevent that from happening by setting bypassMainQuery: false if you want to use the default query., (*12)

Model function front-end visibility

You need to make your methods accessible for DustPress.js by defining a property named $api in your model. It should be an array consisting of the names of your accessible methods. DustPress.js can also run protected methods which are not automatically run by DustPress normally., (*13)

class SomeModel extends DustPressModel {
    public $api = [
        'SomeMethod'
    ];

    protected function SomeMethod() {
        // Some code..
    }
}

If you need to determine whether a call has been made from ajax or not, you can use dustpress()->is_dustpress_ajax() function like shown below:, (*14)

class SomeModel extends DustPressModel {
    public $api = [
        'PublicMethod'
    ];

    public function PublicMethod() {
        if ( dustpress()->is_dustpress_ajax() ) {
            // Do not run if this an ajax request.
            return;
        }
        // Some code..
    }
}

Install

Recommended installation to a WordPress project is through composer:, (*15)

$ composer require devgeniem/dustpress-js

Obviously you can also download the ZIP file from GitHub and extract it into your plugins directory., (*16)

The Versions

27/06 2018

v2.3.1.x-dev

2.3.1.9999999-dev

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

2.3.3

2.3.3.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

dev-master

9999999-dev

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

dev-hotfix-180627-b

dev-hotfix-180627-b

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

3.0.2

3.0.2.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

dev-hotfix-180627

dev-hotfix-180627

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

3.0.1

3.0.1.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

27/06 2018

2.3.2

2.3.2.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/06 2018

2.3.1

2.3.1.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/06 2018

v3.x-dev

3.9999999.9999999.9999999-dev

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/06 2018

3.0.0

3.0.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/06 2018

dev-bypassmainquery

dev-bypassmainquery

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/06 2018

2.3.0

2.3.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

14/06 2018

v2.2.0.x-dev

2.2.0.9999999-dev

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

14/06 2018

2.2.0

2.2.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

25/05 2018

dev-hotfix-180525

dev-hotfix-180525

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

25/05 2018

2.1.2

2.1.2.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

17/01 2018

2.1.1

2.1.1.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

17/01 2018

2.1.0

2.1.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

17/01 2018

dev-data-parameter

dev-data-parameter

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

16/11 2017

2.0.2

2.0.2.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

15/11 2017

dev-fix-171115

dev-fix-171115

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

10/11 2017

2.0.1

2.0.1.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

09/11 2017

dev-enqueue-version-fix

dev-enqueue-version-fix

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/10 2017

2.0.0

2.0.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

20/10 2017

dev-ajax-json

dev-ajax-json

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

04/10 2017

1.1.3

1.1.3.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

04/10 2017

1.1.3.x-dev

1.1.3.9999999-dev

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

13/03 2017

1.1.2

1.1.2.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

13/03 2017

dev-parse_json_error

dev-parse_json_error

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

08/03 2017

1.1.1

1.1.1.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

06/03 2017

dev-js_version_bump

dev-js_version_bump

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

01/03 2017

1.1.0

1.1.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

01/03 2017

1.0.8

1.0.8.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

16/02 2017

1.0.7

1.0.7.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

26/01 2017

1.0.6

1.0.6.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

14/12 2016

1.0.5

1.0.5.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

14/12 2016

1.0.4

1.0.4.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

16/10 2016

1.0.3

1.0.3.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

19/09 2016

1.0.2

1.0.2.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

10/06 2016

1.0.1

1.0.1.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress framework javascript theme debugger dustjs dustpress

08/06 2016

1.0.0

1.0.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

MIT

The Requires

 

03/06 2016

0.1.0

0.1.0.0

A DustPress plugin that provides a handy JavaScript library for using your DustPress Model methods on the front end.

  Sources   Download

MIT

The Requires