addSettingFields(
array(
'field_id' => 'text_field',
'type' => 'text',
'title' => __( 'Text Input', 'admin-page-framework-loader' ),
'description' => __( 'The description for the field.', 'admin-page-framework-loader' ),
'help' => 'This is help text.',
'help_aside' => 'This is additional help text which goes to the side bar of the help pane.',
),
array(
'field_id' => 'text_field_repeatable',
'type' => 'text',
'title' => __( 'Text Repeatable', 'admin-page-framework-loader' ),
'repeatable' => true
),
array(
'field_id' => 'image_upload',
'type' => 'image',
'title' => __( 'Image Upload', 'admin-page-framework-loader' ),
'attributes' => array(
'preview' => array(
'style' => 'max-width: 200px;',
),
),
)
);
$this->addSettingSections(
array(
'section_id' => 'term_section',
'title' => __( 'Section', 'admin-page-framework-loader' ),
)
);
$this->addSettingFields(
'term_section', // section ID
array(
'field_id' => 'textarea_field',
'type' => 'textarea',
'title' => __( 'Text Area', 'admin-page-framework-loader' ),
'description' => __( 'The description for the field.', 'admin-page-framework-loader' ),
'help' => __( 'This a text area input field, which is larger than the text input field.', 'admin-page-framework-loader' ),
'default' => __( 'This is a default text value.', 'admin-page-framework-loader' ),
'attributes' => array(
'cols' => 40,
),
)
);
}
/**
* ( optional ) modify the columns of the term listing table
*
* @callback sortable_column_{instantiated class name}
*/
public function sortable_columns_APF_TermMeta( $aColumn ) {
return array(
'custom' => 'custom',
)
+ $aColumn;
}
/**
*
* @callback column_{instantiated class name}
*/
public function columns_APF_TermMeta( $aColumn ) {
unset( $aColumn[ 'description' ] );
// in term.php this method is also called but the `cb` element does not exist
$_aCheckBox = isset( $aColumn[ 'cb' ] )
? array( 'cb' => $aColumn[ 'cb' ] )
: array();
return $_aCheckBox
+ array(
'thumbnail' => __( 'Thumbnail', 'admin-page-framework-loader' ),
'custom' => __( 'Custom Column', 'admin-page-framework-loader' ),
)
+ $aColumn;
}
/**
* (optional) output the stored option to the custom column
*
* @callback cell_{instantiated class name}
*/
public function cell_APF_TermMeta( $sCellHTML, $sColumnSlug, $iTermID ) {
if ( ! $iTermID || $sColumnSlug !== 'thumbnail' ) {
return $sCellHTML;
}
$_sImageURL = get_term_meta( $iTermID, 'image_upload', true );
return $_sImageURL
? ""
: $sCellHTML;
}
/**
*
* @callback cell_{instantiated class name}_{cell slug}
*/
public function cell_APF_TermMeta_custom( $sCellHTML, $iTermID ) {
return get_term_meta( $iTermID, 'text_field', true );
}
/**
* ( optional ) Use this method to insert your custom text.
*
* @callback do_{instantiated class name}
*/
public function do_APF_TermMeta() {
?>
do_{instantiated class name} hook.', 'admin-page-framework-loader' ) ?>