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' => '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,
),
),
array(
'field_id' => 'image_upload',
'type' => 'image',
'title' => __( 'Image Upload', 'admin-page-framework-loader' ),
'attributes' => array(
'preview' => array(
'style' => 'max-width: 200px;',
),
),
)
);
// Customize the sorting algorithm of the terms of a custom column.
add_filter( 'get_terms', array( $this, 'replyToSortCustomColumn' ), 10, 3 );
}
/*
* ( optional ) modify the columns of the term listing table
*/
public function sortable_columns_APF_TaxonomyField( $aColumn ) { // sortable_column_{instantiated class name}
return array(
'custom' => 'custom',
)
+ $aColumn;
}
public function columns_APF_TaxonomyField( $aColumn ) { // column_{instantiated class name}
unset( $aColumn['description'] );
return array(
'cb' => $aColumn['cb'],
'thumbnail' => __( 'Thumbnail', 'admin-page-framework-loader' ),
'custom' => __( 'Custom Column', 'admin-page-framework-loader' ),
)
+ $aColumn;
}
/*
* ( optional ) output the stored option to the custom column
*/
public function cell_APF_TaxonomyField( $sCellHTML, $sColumnSlug, $iTermID ) { // cell_{instantiated class name}
if ( ! $iTermID || $sColumnSlug != 'thumbnail' ) { return $sCellHTML; }
$aOptions = get_option( 'APF_TaxonomyField', array() ); // by default the class name is the option key.
return isset( $aOptions[ $iTermID ][ 'image_upload' ] ) && $aOptions[ $iTermID ][ 'image_upload' ]
? ""
: $sCellHTML;
}
public function cell_APF_TaxonomyField_custom( $sCellHTML, $iTermID ) { // cell_{instantiated class name}_{cell slug}
// Using AdminPageFramework::getOption() is another way to retrieve an option value.
return AdminPageFramework::getOption( 'APF_TaxonomyField', array( $iTermID, 'text_field' ) );
}
/*
* ( optional ) Use this method to insert your custom text.
*/
public function do_APF_TaxonomyField() { // do_{instantiated class name}
?>
do_{instantiated class name} hook.', 'admin-page-framework-loader' ) ?>
term_id, 'text_field' ) ); $_sTextFieldB = AdminPageFramework::getOption( $_sClassName, array( $oTermB->term_id, 'text_field' ) ); return isset( $_GET['order'] ) && 'asc' == $_GET['order'] ? strnatcmp( $_sTextFieldA, $_sTextFieldB ) : strnatcmp( $_sTextFieldB, $_sTextFieldA ); } /* * ( optional ) Use this method to validate submitted option values. */ public function validation_APF_TaxonomyField( $aNewOptions, $aOldOptions ) { // Do something to compare the values. return $aNewOptions; } } new APF_TaxonomyField( 'apf_sample_taxonomy' // taxonomy slug );