/**
  * Hooks
  */
 private function hooks()
 {
     // frontend only
     if (!is_admin()) {
         // breadcrumbs
         $breadcrumbs = new Breadcrumbs();
         add_action('wp', array($breadcrumbs, 'handleHooks'));
         // setup shortcode on frontend
         $shortcode = new Shortcode();
         $shortcode->setup();
     }
     // setup product link
     $productLink = new MetaBox();
     $productLink->add_hooks();
 }
예제 #2
0
    public function addMetaboxModal()
    {
        require $this->templateHandler->getView('metabox/repeater-start');
        parent::display();
        require $this->templateHandler->getView('metabox/repeater-end');
        if (self::$initialized === false) {
            ?>
            <script>var d3AdminUtil_repeaterFields = [];</script>
        <?php 
            self::$initialized = true;
        }
        ?>
<script>
            d3AdminUtil_repeaterFields.push('<?php 
        echo esc_attr($this->configData->name);
        ?>
');
        </script><?php 
    }
예제 #3
0
 protected function create_metabox()
 {
     MetaBox::create(array('fields' => array(array('name' => 'Test field', 'description' => 'Some description'))));
 }
<?php

namespace NV\Plugins;

MetaBox::init();
/**
 * Class MetaBoxBuilder
 *
 * Used to automatically generate complete WordPress admin widgets, including HTML
 * and automatic population, validation, and saving.
 *
 * You can utilize this in just two steps…
 *
 * Step 1: Register your settings using /NV/Plugins/MetaBox/MetaBoxBuilder::register_setting()
 * Step 2: Register your metabox using /NV/Plugins/MetaBox/MetaBoxBuilder::build_metabox() as the callback.
 *
 * Everything else is handled for you! Alternatively, you can define your own template file and fetch the
 * form field using get_field()
 *
 * @package NV\Plugins\Widgets
 */
class MetaBox
{
    /**
     * Initialize globals and magic hooks.
     */
    public static function init()
    {
        global $NOUVEAU;
        // Register a global to manage metabox registrations
        $NOUVEAU['MetaBoxes'] = array();
예제 #5
0
 /**
  * Constructor. Set up the properties.
  *
  * @param PostType $post_type Post type model.
  * @param MetaBox  $meta_box  Meta box model.
  */
 public function __construct(PostType $post_type, MetaBox $meta_box)
 {
     $this->post_type = $post_type->get_post_type();
     $this->meta_key = $meta_box->get_meta_key();
 }
예제 #6
0
<?php

$websiteOptions = new customPostType('websiteoptions', 'Website Options', 'Website Options', array('title', 'page-attributes'));
$mainOptions = new MetaBox('mainoptions', 'Main Options', 'websiteoptions');
$mainOptions->addField(array('title' => 'Time interval for home page slider', 'name' => 'timeinterval', 'type' => MetaBox::TEXT_FIELD));
<?php

$homeSlider = new customPostType('homeslider', 'Home Page Slider', 'Home Page Slider', array('title', 'page-attributes'));
$sliderContent = new MetaBox('slidercontent', 'Slider Content', 'homeslider');
$sliderContent->addField(array('title' => 'Background Image', 'name' => 'background', 'type' => MetaBox::MEDIA_FIELD));
$sliderContent->addField(array('title' => 'Background Image', 'name' => 'position', 'type' => MetaBox::SELECT_FIELD, 'values' => ['left' => 'left', 'center' => 'center', 'right' => 'right']));
$sliderContent->addField(array('title' => 'Text Color (Hex Number, only code.)', 'name' => 'color', 'type' => MetaBox::TEXT_FIELD));
$sliderContent->addField(array('title' => 'Title', 'name' => 'title', 'type' => MetaBox::TEXT_FIELD));
$sliderContent->addField(array('title' => 'Title Font', 'name' => 'titlefont', 'type' => MetaBox::TEXT_FIELD));
$sliderContent->addField(array('title' => 'Text Overlay', 'name' => 'textOverlay', 'type' => MetaBox::WP_EDITOR));
$sliderContent->addField(array('title' => 'TextFont', 'name' => 'textfont', 'type' => MetaBox::TEXT_FIELD));
예제 #8
0
 /**
  * STEP 2: REGISTER YOUR SETTINGS…
  * 
  * Register your settings here with MetaBox::register_setting(). Once registered, saving is handled for you and you
  * have access to functions that can automatically generate metaboxes and/or fields.
  * 
  * Examples are provided below. The register_setting() method takes 3 arguments…
  * 
  * $meta_key    Required. String. The database key the data will be saved under & the id and name attributes for form elements.
  * $box_id      Required. String. The id/slug of the meta box that this setting should be associated with.
  * $args        Optional. Array.  Additional customization of your setting as an associative array. Options include…
  * 
  *   'label'        The visible text to use for the form elements <label>
  *   'type'         The type of form field to use with this setting. Valid values include: text, textarea, select, radio, checkbox, hidden
  *   'placeholder'  Text to use as the form elements HTML5 placeholder attribute.
  *   'value'        The default value or selection for the form element.
  *   'list'         An associative array of items to include in radio, checkbox, and select elements, in 'value' => 'Display Text' format
  *   'howto'        Help text to display beneath the form element.
  *   'save'         Whether or not the setting should be automagically saved by the plugin.
  *   'serialize'    Serialize the setting under this key instead of storing separately.
  * 
  * Note: The order of registration controls the order of display.
  */
 public static function register_settings()
 {
     // * * * * * * * * * * * * * * * * * * * * * * *
     // AUTOMAGIC META BOX
     // * * * * * * * * * * * * * * * * * * * * * * *
     MetaBox::register_setting('_nv_example_meta_field', 'magic-meta-box', array('label' => __('Example Field', 'nvLangScope'), 'placeholder' => __('Enter a value…', 'nvLangScope')));
     MetaBox::register_setting('_nv_example_meta_checkboxes', 'magic-meta-box', array('type' => 'checkbox', 'label' => __('Example Checklist', 'nvLangScope'), 'list' => array('cb1' => __('Item 1', 'nvLangScope'), 'cb2' => __('Item 2', 'nvLangScope'), 'cb3' => __('Item 3', 'nvLangScope'))));
     MetaBox::register_setting('_nv_example_meta_radio', 'magic-meta-box', array('type' => 'radio', 'label' => __('Example Radio List', 'nvLangScope'), 'list' => array('radio1' => __('Item 1', 'nvLangScope'), 'radio2' => __('Item 2', 'nvLangScope'), 'radio3' => __('Item 3', 'nvLangScope')), 'value' => 'radio1'));
     MetaBox::register_setting('example_serialized_checkbox', 'magic-meta-box', array('type' => 'checkbox', 'label' => __('Example single checkbox', 'nvLangScope'), 'serialize' => '_nv_example_serialized'));
     MetaBox::register_setting('example_serialized_textarea', 'magic-meta-box', array('type' => 'textarea', 'label' => __('Example Textarea', 'nvLangScope'), 'placeholder' => __('Your text goes here!', 'nvLangScope'), 'howto' => __('You can add a paragraph of help text below any setting.', 'nvLangScope'), 'serialize' => '_nv_example_serialized'));
     // * * * * * * * * * * * * * * * * * * * * * * *
     // CUSTOM (HAND-CRAFTED) META BOX
     // * * * * * * * * * * * * * * * * * * * * * * *
     MetaBox::register_setting('_nv_example_meta_field2', 'custom-meta-box', array('label' => __('Example Field', 'nvLangScope'), 'placeholder' => __('Enter a value…', 'nvLangScope')));
     MetaBox::register_setting('_nv_example_meta_dropdown', 'custom-meta-box', array('type' => 'select', 'label' => __('Example Dropdown', 'nvLangScope'), 'list' => array('' => __('-- Select One --', 'nvLangScope'), '1' => __('Option 1', 'nvLangScope'), '2' => __('Option 2', 'nvLangScope'))));
 }
function create_new_meta_boxes()
{
    $vimeo_metabox = new MetaBox();
    $vimeo_metabox->id = "vimeo_box";
    //
    $vimeo_metabox->title = "Vimeo Box";
    //Box Title
    $vimeo_metabox->page = array('post', 'page');
    //Section to attach metbox to (page, post or custom)
    $vimeo_metabox->context = 'side';
    $vimeo_metabox->priority = 'high';
    $vimeo_metabox->prefix = 'mf_';
    $vimeo_metabox->fields = array(array('name' => 'Vimeo Video', 'id' => $vimeo_metabox->prefix . 'vimeo', 'type' => 'wide-text', 'desc' => "<p>Place Vimeo Video ID here (digits on the end of the URL)</p>"));
    $admin_metabox = new MetaBox();
    $admin_metabox->id = "admin_box";
    //
    $admin_metabox->title = "Admin Box";
    //Box Title
    $admin_metabox->page = array('post', 'page');
    //Section to attach metbox to (page, post or custom)
    $admin_metabox->context = 'side';
    $admin_metabox->priority = 'high';
    $admin_metabox->prefix = 'mf_';
    $admin_metabox->fields = array(array('name' => 'Remove Date', 'id' => $admin_metabox->prefix . 'date_display', 'type' => 'checkbox', 'options' => "Do not display date on this page"));
    add_action('admin_menu', $admin_metabox->add());
    add_action('admin_menu', $vimeo_metabox->add());
}
function create_new_meta_boxes()
{
    $redirect_metabox = new MetaBox();
    $redirect_metabox->id = "redirect";
    //
    $redirect_metabox->title = "Redirect this page?";
    //Box Title
    $redirect_metabox->page = 'page';
    //Section to attach metbox to (page, post or custom)
    $redirect_metabox->context = 'side';
    $redirect_metabox->priority = 'high';
    $redirect_metabox->prefix = 'mf_';
    $redirect_metabox->fields = array(array('name' => 'URL', 'id' => $redirect_metabox->prefix . 'redirect_url', 'type' => 'wide-text', 'desc' => "<p>Enter the URL you would like this page to redirect to</p>"));
    $books_metabox = new MetaBox();
    $books_metabox->id = "book_details";
    //
    $books_metabox->title = "Book Details";
    //Box Title
    $books_metabox->page = array('Books');
    //Section to attach metbox to (page, post or custom)
    $books_metabox->context = 'side';
    $books_metabox->priority = 'high';
    $books_metabox->prefix = 'mf_';
    $books_metabox->fields = array(array('name' => 'Author', 'id' => $books_metabox->prefix . 'author', 'type' => 'wide-text'), array('name' => 'Publisher', 'id' => $books_metabox->prefix . 'publisher', 'type' => 'wide-text'), array('name' => 'ISBN', 'id' => $books_metabox->prefix . 'ISBN', 'type' => 'wide-text'));
    //fb::log($books_metabox->connect_to_post_type('Events'));
    $team_metabox = new MetaBox();
    $team_metabox->id = "team_details";
    //
    $team_metabox->title = "Team Details";
    //Box Title
    $team_metabox->page = array('People');
    //Section to attach metbox to (page, post or custom)
    $team_metabox->context = 'side';
    $team_metabox->priority = 'high';
    $team_metabox->prefix = 'mf_';
    $team_metabox->fields = array(array('name' => 'Job Title', 'id' => $team_metabox->prefix . 'job_title', 'type' => 'wide-text'), array('name' => 'eMail', 'id' => $team_metabox->prefix . 'email', 'type' => 'wide-text'));
    $program_metabox = new MetaBox();
    $program_metabox->id = "program_meta";
    //
    $program_metabox->title = "Program Meta";
    //Box Title
    $program_metabox->page = array('Program');
    //Section to attach metbox to (page, post or custom)
    $program_metabox->context = 'side';
    $program_metabox->priority = 'high';
    $program_metabox->prefix = 'mf_SALF_meta_';
    $program_metabox->fields = array(array('name' => 'Date', 'desc' => "<p>Enter in the format DD/MM/YYY</p>", 'id' => $program_metabox->prefix . 'date', 'type' => 'date'), array('name' => 'Time', 'desc' => "<p>Enter in the format 00:00</p>", 'id' => $program_metabox->prefix . 'time', 'type' => 'wide-text'), array('name' => 'Price', 'id' => $program_metabox->prefix . 'price', 'type' => 'text'), array('name' => 'Venue', 'id' => $program_metabox->prefix . 'venue', 'type' => 'select2', 'options' => $program_metabox->connect_to_post_type('Venues')), array('name' => 'Event Type', 'id' => $program_metabox->prefix . 'type', 'type' => 'select2', 'options' => $program_metabox->connect_to_post_type('Events')), array('name' => 'EventBrite', 'desc' => '<p>Enter Eventbrite Link</p>', 'id' => $program_metabox->prefix . 'eventbrite', 'type' => 'wide-text'), array('name' => 'Concession', 'desc' => '<p>Enter Concession Link</p>', 'id' => $program_metabox->prefix . 'concession', 'type' => 'wide-text'));
    $google_metabox = new MetaBox();
    $google_metabox->id = "program_maps";
    //
    $google_metabox->title = "Address and Map";
    //Box Title
    $google_metabox->page = array('Venues');
    //Section to attach metbox to (page, post or custom)
    $google_metabox->context = 'normal';
    $google_metabox->priority = 'high';
    $google_metabox->prefix = 'mf_SALF_maps_meta_';
    $google_metabox->fields = array(array('name' => 'Google Map', 'id' => $google_metabox->prefix . 'map', 'type' => 'wide-text', 'desc' => '<p>Enter Google Maps Share URL</p>'), array('name' => 'Address 1', 'id' => $google_metabox->prefix . 'address1', 'type' => 'text'), array('name' => 'Address 2', 'id' => $google_metabox->prefix . 'address2', 'type' => 'text'), array('name' => 'Address 3', 'id' => $google_metabox->prefix . 'address3', 'type' => 'text'), array('name' => 'Address 4', 'id' => $google_metabox->prefix . 'address4', 'type' => 'text'), array('name' => 'Post Code', 'id' => $google_metabox->prefix . 'postcode', 'type' => 'text'));
    add_action('admin_menu', $google_metabox->add());
    add_action('admin_menu', $program_metabox->add());
    add_action('admin_menu', $books_metabox->add());
    add_action('admin_menu', $team_metabox->add());
    add_action('admin_menu', $redirect_metabox->add());
}