2017 © Pedro Peláez
 

library wordpress-add-on-post-picker

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

image

amostajo/wordpress-add-on-post-picker

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  • Saturday, February 3, 2018
  • by amostajo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Wordpress Post Picker ADD-ON

Latest Stable Version Total Downloads License, (*1)

Wordpress Post Picker add-on, (*2)

Add-on package for Wordpress Plugin Template and Wordpress Theme Template exclusively., (*3)

Post Picker is a built-in modal that can be used within Wordpress' admin dashboard to pick / select posts., (*4)

Installation

This package requires Composer and Bower to install its dependencies. Make sure to have these install before proceeding., (*5)

Add it as dependency in your composer.json file located on your template's root folder:, (*6)

"amostajo/wordpress-add-on-post-picker": "1.0.*"

Then add a the following to your composer.json file:, (*7)

"scripts": {
    "post-package-install": [
        "php vendor/amostajo/wordpress-add-on-post-picker/ayuco bowerInstall"
    ],
    "post-package-update": [
        "php vendor/amostajo/wordpress-add-on-post-picker/ayuco bowerUpdate"
    ]
}

Then run, (*8)

composer install

or, (*9)

composer update

to download package and dependencies., (*10)

Configure in Template

Add the following string line in your addons array option located at your template's config file., (*11)

    'Amostajo\Wordpress\PostPickerAddon\PostPicker',

This should be added to: * config\plugin.php on Wordpress Plugin Template * config\theme.php on Wordpress Theme Template, (*12)

Usage

Enqueue on Main

Before you do any custom code, you need to load or enqueue the Post Picker to Wordpress., (*13)

Call addon_post_picker() function within your template's Main class, like this:, (*14)

class Main extends Plugin
{
    public function metabox()
    {
        // The function must be called within your Main.php file
        $this->addon_post_picker();
    }
}

HTML and JS

Create a clickable element, who will call the Post Picker:, (*15)

<a id="post-picker-caller">
    Add Posts
</a>

Init Post Picker, ala jQuery, with the options wanted:, (*16)

$("#post-picker-caller").postPicker({
    render: false,
    success: function (posts) {
        // YOUR CUSTOM CODE HERE
        // Example:
        $.each(posts, function(index) {
            // Print post in console
            console.log(this);
        });
    } 
});

Rendering

Post Picker has a built-in rendering system that will lets you display the results easily., (*17)

To do this, you need two things in your HTML. * Template: A template for each of the results to display. * Placeholder target: A target element that will act as placeholder for the results., (*18)

Example using the previous sample:, (*19)

<a id="post-picker-caller">
    Add Posts
</a>




{{ title }} {{ title }}

The javascript section should look like this:, (*20)

$("#post-picker-caller").postPicker({
    target: "#post-picker-placeholder",
    templateElement: "#post-picker-templateholder"
});

Post Picker renders the results by default., (*21)

Templates

There are 3 ways to set your template., (*22)

  • Inside caller (Default): Your template will be the HTML inside the caller tags. In the example case #post-picker-caller.
  • An element: Same as the previous example.
  • As option: Pass it as jQuery option.

These are the available Post properties for display:, (*23)

Property Description
{{ ID }} Post ID.
{{ title }} Post title.
{{ slug }} Post name / slug.
{{ permalink }} Post permalink.
{{ image_id }} Featured image ID.
{{ image_url }} Featured image url.
{{ thumb_image_url }} Featured image thumb url (120x120 px).
{{ post_type }} Post type.
{{ post_date }} Post date.
{{ excerpt }} Excerpt of 15 words.

Options

Option Data type Description
allowMultiple bool Flag that indicates multiple post can be selected or just 1. Default: true
render bool Flag that indicates if plugin should render results. Default: true
clearTemplate bool Flag that indicates if template should be cleared once plugin starts. Default: true
clearTarget bool Flag that indicates if target should be cleared on every selection. Default: true
target string Element that will hold results.
template string HTML template.
templateElement string Element containing the template.
success function Callback function with the selected posts.

Coding Guidelines

The coding is a mix between PSR-2 and Wordpress PHP guidelines., (*24)

License

Post Picker is free software distributed under the terms of the MIT license., (*25)

The Versions

03/02 2018

v2.0.x-dev

2.0.9999999.9999999-dev

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

03/02 2018

v2.0.1

2.0.1.0

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

03/02 2018

v2.0.0

2.0.0.0

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

18/04 2016

v1.0.x-dev

1.0.9999999.9999999-dev

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

19/11 2015

v1.0.2

1.0.2.0

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

02/11 2015

v1.0.1

1.0.1.0

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

29/10 2015

dev-master

9999999-dev

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on

29/10 2015

v1.0.0

1.0.0.0

Wordpress Post Picker Add-on for Wordpress Plugin and Theme templates.

  Sources   Download

MIT

The Requires

 

wordpress picker post add-on