/** * Get content from 'attribute/$attribute.html' * * @param string $attribute Attribute name * * @return string html */ function mbb_get_attribute_content($attribute, $replace = '') { $attribute = str_replace('_', '-', $attribute); $url = MBB_INC_URL . "attributes/{$attribute}.html"; $content = @file_get_contents($url); $content = str_replace('##key_value##', $replace, $content); $labels = Meta_Box_Attribute::$labels; $label = array_key_exists($replace, $labels) ? $labels[$replace] : str_title($replace); $content = str_replace('##key_value_label##', $label, $content); $content = str_replace('<label>Attributes</label>', '<label><strong>Custom Attributes</strong>. See <a href="http://www.metabox.io/docs/meta-box-builder#custom-attributes">here</a> for more detail. </label>', $content); return $content; }
/** * Generate Input Content * @param string $name Name of the input * @param string $label Label of the input * @param array $attrs Other attributes * @param string $type input type * @return string html */ public static function input($name, $label = null, $attrs = array(), $type = 'text') { // Turn key => value array to key="value" html output $attrs = self::build_attributes($attrs); // If label is not defined $label = $label != null ? $label : $name; // Because field name is not Capitalized, so we have to convert it if (array_key_exists($label, self::$labels)) { $label = self::$labels[$label]; } else { $label = str_title($label); } $classes = $type !== 'checkbox' ? 'form-control' : ''; $br = $type !== 'checkbox' ? '<br>' : ''; $output = ' <label for="{{field.id}}_' . $name . '">' . $label . $br . ' <input type="' . $type . '" ng-model="field.' . $name . '" id="{{field.id}}_' . $name . '" class="' . $classes . '"' . $attrs . ' /> </label> '; return $output; }
public static function show() { if (!self::visible()) { return; } ?> <div class="meta-box-sortables"> <div class="postbox closed"> <div class="handlediv" title="Click to toggle"> <br></div> <h3 class="hndle ui-sortable-handle">Include Exclude <span class="label">Extension</span></h3> <div class="inside"> <dl class="extension" id="meta-box-include-exclude"> <dt class="howto"></dt> <dd> <dl> <dt class="one-half"><label for="meta-includeexclude-type">Include / Exclude</label></dt> <dd class="one-half"> <select id="meta-includeexclude-type" ng-model="meta.includeexclude.type" ng-init="meta.includeexclude.type = meta.includeexclude.type || 'off'"> <option value="off">Off (Always Show)</option> <option value="include">Include</option> <option value="exclude">Exclude</option> </select> </dd> </dl> <div ng-hide="meta.includeexclude.type=='off' || meta.includeexclude.type==''"> <dl> <dt class="one-half"><label for="meta-includeexclude-relation">Relation</label></dt> <dd class="one-half"> <select id="meta-includeexclude-relation" ng-model="meta.includeexclude.relation" ng-init="meta.includeexclude.relation = meta.includeexclude.relation || 'OR'"> <option value="AND">AND</option> <option value="OR">OR</option> </select> </dd> </dl> <div class="clear clearfix"></div> <dl> <dt class="one-half"><label for="meta-includeexclude-id">Post IDs</label></dt> <dd class="one-half"> <textarea id="meta-includeexclude-id" rows="3" ng-model="meta.includeexclude.ID" placeholder="Enter post IDs, comma separated"></textarea> </dd> </dl> <dl> <dt class="one-half"><label for="meta-includeexclude-parent">Parents</label></dt> <dd class="one-half"> <textarea rows="3" id="meta-includeexclude-parent" ng-model="meta.includeexclude.parent" placeholder="Enter parent IDs, comma separated"></textarea> </dd> </dl> <dl> <dt class="one-half"><label for="meta-includeexclude-slug">Slugs</label></dt> <dd class="one-half"> <textarea rows="3" id="meta-includeexclude-slug" ng-model="meta.includeexclude.slug" placeholder="Enter post slugs, comma separated"></textarea> </dd> </dl> <?php if (!empty($templates)) { ?> <dl> <dt class"one-half"><label for="meta-includeexclude-template">Page Template</label></dt> <dd> <select id="meta-includeexclude-template" ng-model="meta.includeexclude.template" class="form-control" multiple> <?php foreach ($templates as $file => $name) { ?> <option value="<?php echo $file; ?> "><?php echo $name; ?> </option> <?php } ?> </select> </dd> </dl> <?php } ?> <?php if (!empty($term_taxonomies)) { foreach ($term_taxonomies as $name => $terms) { ?> <dl> <dt class"one-half"><label for="meta-includeexclude-<?php echo $name; ?> "><?php echo str_title($name); ?> </label></dt> <dd> <select id="meta-includeexclude-<?php echo $name; ?> " ng-model="meta.includeexclude.<?php echo $name; ?> " class="form-control" multiple> <?php foreach ($terms as $id => $term_name) { ?> <option value="<?php echo $id; ?> "><?php echo $term_name; ?> </option> <?php } ?> </select> </dd> </dl> <?php } } ?> <dl> <dt class="one-half"><label for="meta-includeexclude-custom">Custom Conditional Callback</label></dt> <dd class="one-half"> <input type="text" id="meta-includeexclude-custom" ng-model="meta.includeexclude.custom" placeholder="Enter callback function" /> </dd> </dl> </div> </dd> </dl> </div> </div><!--.postbox-closed--> </div><!--.meta-box-sortables--> <?php }
_e('Context', 'meta-box'); ?> </dt> <dd> <ul class="builder-grid"> <?php $contexts = array('normal', 'advanced', 'side'); foreach ($contexts as $context) { ?> <li class="builder-col"> <label> <input type="radio" ng-model="meta.context" name="context" value="<?php echo $context; ?> "> <?php echo str_title($context); ?> </label> </li> <?php } ?> </ul> </dd> </dl> <dl> <dt class="howto"><?php _e('Post types', 'meta-box'); ?>
public static function show() { if (!self::visible()) { return; } ?> <div class="meta-box-sortables"> <div class="postbox closed"> <div class="handlediv" title="Click to toggle"> <br></div> <h3 class="hndle ui-sortable-handle">Show / Hide <span class="label">Extension</span></h3> <div class="inside"> <dl class="extension" id="meta-box-show-hide"> <dt></dt> <dd> <dl> <dt class="one-half"><label for="meta-showhide-type">Show / Hide</label></dt> <dd class="one-half"> <select id="meta-showhide-type" ng-model="meta.showhide.type" ng-init="meta.showhide.type = meta.showhide.type || 'off'"> <option value="off">Off (Always Show)</option> <option value="show">Show</option> <option value="hide">Hide</option> </select> </dd> </dl> <div ng-hide="meta.showhide.type=='off' || meta.showhide.type==''"> <dl> <dt class="one-half"><label for="meta-showhide-relation">Relation</label></dt> <dd class="one-half"> <select id="meta-showhide-relation" ng-model="meta.showhide.relation" ng-init="meta.showhide.relation = meta.showhide.relation || 'OR'"> <option value="AND">AND</option> <option value="OR">OR</option> </select> </dd> </dl> <div class="clear clearfix"></div> <?php $templates = mbb_get_page_templates(); if (!empty($templates)) { ?> <dl> <dt class"one-half"><label for="meta-showhide-template">Page Template</label></dt> <dd> <select id="meta-showhide-template" ng-model="meta.showhide.template" class="form-control" multiple> <?php foreach ($templates as $file => $name) { ?> <option value="<?php echo $file; ?> "><?php echo $name; ?> </option> <?php } ?> </select> </dd> </dl> <?php } ?> <?php $post_formats = mbb_get_post_formats(); if (!empty($post_formats)) { ?> <dl> <dt class"one-half"><label for="meta-showhide-post_format">Post Format</label></dt> <dd> <select id="meta-showhide-post_format" ng-model="meta.showhide.post_format" class="form-control" multiple> <?php foreach ($post_formats as $format) { ?> <option value="<?php echo $format; ?> "><?php echo str_title($format); ?> </option> <?php } ?> </select> </dd> </dl> <?php } ?> <?php $term_taxonomies = mbb_get_terms(); if (!empty($term_taxonomies)) { foreach ($term_taxonomies as $name => $terms) { ?> <dl> <dt class"one-half"><label for="meta-showhide-<?php echo $name; ?> "><?php echo str_title($name); ?> </label></dt> <dd> <select id="meta-showhide-<?php echo $name; ?> " ng-model="meta.showhide.<?php echo $name; ?> " class="form-control" multiple> <?php foreach ($terms as $id => $term_name) { ?> <option value="<?php echo $id; ?> "><?php echo $term_name; ?> </option> <?php } ?> </select> </dd> </dl> <?php } } ?> </div> </dd> </dl> </div> </div><!--.postbox-closed--> </div><!--.meta-box-sortables--> <?php }