PHP Class APF_Demo_CustomFieldType_Select2

Since: 3.8.6
Show file Open project: michaeluno/admin-page-framework

Public Properties

Property Type Description
$oFactory
$sClassName
$sPageSlug
$sTabSlug

Public Methods

Method Description
__construct ( $oFactory, $sPageSlug )
createTerm ( $aQueries, $aFieldset ) : array Returns the created item with the format of select2 AJAX response data strucute.
getPosts ( $aQueries, $aFieldset ) : array Retrieves and return posts with the array structure of select2 AJAX format.
getTerms ( $aQueries, $aFieldset ) : array
replyToDoTab ( )
replyToLoadTab ( $oAdminPage ) Triggered when the tab starts loading.
validate ( $aInputs, $aOldInputs, $oAdminPage, $aSubmitInfo )

Method Details

__construct() public method

public __construct ( $oFactory, $sPageSlug )

createTerm() public static method

Structure of Response Array

It must be an associative array with the element keys of id and text, and optionally error/ array( 'id' => 223, 'text' => 'WordPress' ) array( 'error' => 'Something went wrong' )
public static createTerm ( $aQueries, $aFieldset ) : array
return array

getPosts() public static method

Structure of Response Array

It must be an associative array with the element keys of results and pagination. In the results element must be a numerically index array holding an array with the kes of id and text. The pagination element can be optional and shouold be an array holding an element named more which accepts a boolean value. array( 'results' => array( array( 'id' => 223, 'text' => 'Title of 223' ), array( 'id' => 665, 'text' => 'Title of 665' ), array( 'id' => 9355, 'text' => 'Title of 9355' ), ... ), 'pagination' => array( 'more' => true, // (boolean) or false - whether the next paginated item exists or not. ) ) Or the pagination element can be omitted. array( 'results' => array( array( 'id' => 223, 'text' => 'Title of 223' ), array( 'id' => 665, 'text' => 'Title of 665' ), array( 'id' => 9355, 'text' => 'Title of 9355' ), ... ), )
See also: https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
See also: https://select2.github.io/examples.html#data-ajax
public static getPosts ( $aQueries, $aFieldset ) : array
return array

getTerms() public static method

public static getTerms ( $aQueries, $aFieldset ) : array
return array An array holding the search result of taxonomy terms.

replyToDoTab() public method

public replyToDoTab ( )

replyToLoadTab() public method

Triggered when the tab starts loading.
public replyToLoadTab ( $oAdminPage )

validate() public method

public validate ( $aInputs, $aOldInputs, $oAdminPage, $aSubmitInfo )

Property Details

$oFactory public property

public $oFactory

$sClassName public property

public $sClassName

$sPageSlug public property

public $sPageSlug

$sTabSlug public property

public $sTabSlug