Created
July 5, 2017 06:53
-
-
Save endymion1818/7bd88eebb4a8896a98b7ab8396847a7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Origin\Theme\Metaboxes; | |
class PageMetaBox extends \Origin\Framework\Objects\Metabox | |
{ | |
/** | |
* A unique id/key for this Meta box. | |
* | |
* @var string | |
*/ | |
protected $unique = 'page-metabox'; | |
/** | |
* The "name" or "title" of the Meta box. | |
* | |
* @var string | |
*/ | |
protected $title = 'Page'; | |
/** | |
* The post types for this Meta box. | |
* | |
* @var array | |
*/ | |
protected $postTypes = ['page', 'locations']; | |
/** | |
* Register fields for this Meta box. | |
* | |
* @return array | |
*/ | |
protected function fields() | |
{ | |
return [ | |
'main_cta' => [ | |
'label' => 'Main CTA button', | |
'description' => 'Appears directly below the banner', | |
'type' => 'group', | |
'fields' => [ | |
'maincta_link' => [ | |
'label' => 'Button Link', | |
'type' => 'select', | |
'choices' => origin_get_pages([], false, '-- links to page --') | |
], | |
'maincta_text' => [ | |
'label' => 'Button Text', | |
'type' => 'text', | |
] | |
] | |
], | |
'contentarea' => [ | |
'label' => 'Content Area', | |
'type' => 'repeater', | |
'fields' => [ | |
'contentarea_colour' => [ | |
'label' => 'Content Area Colour', | |
'type' => 'select', | |
'choices' => [ | |
'' => 'Select color...', | |
'band--tall' => 'White', | |
'band--primary' => 'Orange (primary brand colour)', | |
'band--secondary' => 'Dark Orange (secondary brand colour)', | |
'band--lightgray' => 'Light gray', | |
'band--darkgray' => 'Dark gray', | |
] | |
], | |
'contentarea_type' => [ | |
'label' => 'What type should this Content Area be?', | |
'type' => 'select', | |
'choices' => [ | |
'' => 'Please choose ...', | |
'content' => 'Content', | |
'priceguarantee' => 'Price Guarantee (widget area)', | |
'video' => 'Video', | |
'testimonials' => 'Testimonials', | |
'howitworks' => 'How it Works', | |
'news' => 'Recent News', | |
'resources' => 'Resources' | |
] | |
], | |
'content' => [ | |
'label' => 'Content for Area - only displays if \'content\' is selected above', | |
'type' => 'editor', | |
], | |
'video' => [ | |
'label' => 'Video - please enter a video url', | |
'type' => 'text', | |
] | |
] | |
] | |
]; | |
} | |
/** | |
* Allow filtering for where the metabox displays. | |
* | |
* @return boolean execute filter | |
*/ | |
public function __construct() | |
{ | |
add_filter("origin_metabox_conditional_display_{$this->unique}", [$this, 'display']); | |
parent::__construct(); | |
} | |
/** | |
* Conditional display of the current metabox. Return true to | |
* display the metabox, and return false to hide the metabox. | |
* | |
* @return boolean | |
*/ | |
public function display() | |
{ | |
// check if currentpage is a Sabai page.. | |
return get_the_ID() !== get_option(is_sabai()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment