oont-contents/plugins/pre-orders-for-woocommerce/includes/codestar-framework/samples/metabox-options.php
2025-02-08 15:10:23 +01:00

297 lines
6.2 KiB
PHP

<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
//
// Metabox of the PAGE
// Set a unique slug-like ID
//
$prefix_page_opts = '_prefix_page_options';
//
// Create a metabox
//
CSF::createMetabox( $prefix_page_opts, array(
'title' => 'Custom Page Options',
'post_type' => 'page',
'show_restore' => true,
) );
//
// Create a section
//
CSF::createSection( $prefix_page_opts, array(
'title' => 'Overview',
'icon' => 'fas fa-rocket',
'fields' => array(
//
// A text field
//
array(
'id' => 'opt-text',
'type' => 'text',
'title' => 'Text',
),
array(
'id' => 'opt-textarea',
'type' => 'textarea',
'title' => 'Textarea',
'help' => 'The help text of the field.',
),
array(
'id' => 'opt-upload',
'type' => 'upload',
'title' => 'Upload',
),
array(
'id' => 'opt-switcher',
'type' => 'switcher',
'title' => 'Switcher',
'label' => 'The label text of the switcher.',
),
array(
'id' => 'opt-color',
'type' => 'color',
'title' => 'Color',
'default' => '#3498db',
),
array(
'id' => 'opt-checkbox',
'type' => 'checkbox',
'title' => 'Checkbox',
'label' => 'The label text of the checkbox.',
),
array(
'id' => 'opt-radio',
'type' => 'radio',
'title' => 'Radio',
'options' => array(
'yes' => 'Yes, Please.',
'no' => 'No, Thank you.',
),
'default' => 'yes',
),
array(
'id' => 'opt-select',
'type' => 'select',
'title' => 'Select',
'placeholder' => 'Select an option',
'options' => array(
'opt-1' => 'Option 1',
'opt-2' => 'Option 2',
'opt-3' => 'Option 3',
),
),
)
) );
//
// Create a section
//
CSF::createSection( $prefix_page_opts, array(
'title' => 'More Fields',
'icon' => 'fas fa-tint',
'fields' => array(
array(
'id' => 'opt-image-select',
'type' => 'image_select',
'title' => 'Image Select',
'options' => array(
'opt-1' => 'http://codestarframework.com/assets/images/placeholder/100x80-2ecc71.gif',
'opt-2' => 'http://codestarframework.com/assets/images/placeholder/100x80-e74c3c.gif',
'opt-3' => 'http://codestarframework.com/assets/images/placeholder/100x80-ffbc00.gif',
'opt-4' => 'http://codestarframework.com/assets/images/placeholder/100x80-3498db.gif',
'opt-5' => 'http://codestarframework.com/assets/images/placeholder/100x80-555555.gif',
),
'default' => 'opt-1',
),
array(
'id' => 'opt-background',
'type' => 'background',
'title' => 'Background',
),
array(
'type' => 'notice',
'style' => 'success',
'content' => 'A <strong>notice</strong> field with <strong>success</strong> style.',
),
array(
'id' => 'opt-icon',
'type' => 'icon',
'title' => 'Icon',
),
array(
'id' => 'opt-alt-text',
'type' => 'text',
'title' => 'Text',
),
array(
'id' => 'opt-alt-textarea',
'type' => 'textarea',
'title' => 'Textarea',
'subtitle' => 'A textarea with shortcoder.',
'shortcoder' => 'csf_demo_shortcodes',
),
)
) );
//
// Metabox of the POST
// Set a unique slug-like ID
//
$prefix_post_opts = '_prefix_post_options';
//
// Create a metabox
//
CSF::createMetabox( $prefix_post_opts, array(
'title' => 'Custom Post Options',
'post_type' => 'post',
'show_restore' => true,
) );
//
// Create a section
//
CSF::createSection( $prefix_post_opts, array(
'fields' => array(
//
// A text field
//
array(
'id' => 'opt-text',
'type' => 'text',
'title' => 'Text',
),
array(
'id' => 'opt-textarea',
'type' => 'textarea',
'title' => 'Textarea',
'help' => 'The help text of the field.',
),
array(
'id' => 'opt-upload',
'type' => 'upload',
'title' => 'Upload',
),
array(
'id' => 'opt-switcher',
'type' => 'switcher',
'title' => 'Switcher',
'label' => 'The label text of the switcher.',
),
array(
'id' => 'opt-color',
'type' => 'color',
'title' => 'Color',
),
array(
'id' => 'opt-checkbox',
'type' => 'checkbox',
'title' => 'Checkbox',
'label' => 'The label text of the checkbox.',
),
array(
'id' => 'opt-radio',
'type' => 'radio',
'title' => 'Radio',
'options' => array(
'yes' => 'Yes, Please.',
'no' => 'No, Thank you.',
),
'default' => 'yes',
),
array(
'id' => 'opt-select',
'type' => 'select',
'title' => 'Select',
'placeholder' => 'Select an option',
'options' => array(
'opt-1' => 'Option 1',
'opt-2' => 'Option 2',
'opt-3' => 'Option 3',
),
),
)
) );
//
// Metabox of the PAGE and POST both.
// Set a unique slug-like ID
//
$prefix_meta_opts = '_prefix_meta_options';
//
// Create a metabox
//
CSF::createMetabox( $prefix_meta_opts, array(
'title' => 'Custom Options',
'post_type' => array( 'post', 'page' ),
'context' => 'side',
) );
//
// Create a section
//
CSF::createSection( $prefix_meta_opts, array(
'fields' => array(
//
// A text field
//
array(
'id' => 'opt-text',
'type' => 'text',
'title' => 'Text',
),
array(
'id' => 'opt-switcher',
'type' => 'switcher',
'title' => 'Switcher',
'label' => 'The label of the switcher.',
),
array(
'id' => 'opt-color',
'type' => 'color',
'title' => 'Color',
),
array(
'id' => 'opt-select',
'type' => 'select',
'title' => 'Select',
'placeholder' => 'Select an option',
'options' => array(
'opt-1' => 'Option 1',
'opt-2' => 'Option 2',
'opt-3' => 'Option 3',
),
),
)
) );