コード例 #1
0
ファイル: room.php プロジェクト: bulini/booking-wp
/**
 * Define the metabox and field configurations.
 *
 * @param  array $meta_boxes
 * @return array
 */
function cmb_booking_metaboxes(array $meta_boxes)
{
    // Start with an underscore to hide fields from custom fields list
    $prefix = '';
    /**
     * Sample metabox to demonstrate each field type included
     */
    $meta_boxes['booking_metabox'] = array('id' => 'booking_metabox', 'title' => __('Booking Box', 'bookingwp'), 'pages' => array('bookings'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Select Room', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => $prefix . 'room', 'type' => 'select', 'options' => cmb_get_post_options(array('post_type' => 'accommodations', 'numberposts' => 5))), array('name' => __('email', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => $prefix . 'email', 'type' => 'text_medium'), array('name' => 'checkin', 'id' => $prefix . 'checkin', 'type' => 'text_date_timestamp', 'date_format' => 'm/d/Y'), array('name' => 'checkout', 'id' => $prefix . 'checkout', 'type' => 'text_date_timestamp', 'date_format' => 'm/d/Y'), array('name' => __('people', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => $prefix . 'people', 'type' => 'text_small')));
    return $meta_boxes;
}
コード例 #2
0
/**
 * Define the metabox and field configurations.
 *
 * @param  array $meta_boxes
 *
 * @return array
 */
function cmb2_ksprfs_metaboxes(array $meta_boxes)
{
    // Start with an underscore to hide fields from custom fields list
    $prefix = 'ksprfs_';
    global $cmb2_prefix, $meta_boxes;
    $cmb2_prefix = $prefix;
    $meta_boxes['engine_data'] = array('id' => 'engine_data', 'title' => 'Engine Data', 'object_types' => array('engine'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => 'Engine ID', 'desc' => 'The "name" of the engine in the original .cfg file', 'id' => $prefix . 'engine_id', 'type' => 'text', 'attributes' => array('required' => 'required', 'ng-model' => 'rfs.' . $prefix . 'engine_id')), array('name' => 'New Name', 'id' => $prefix . 'engine_name', 'type' => 'text', 'attributes' => array('ng-model' => 'rfs.' . $prefix . 'engine_name')), array('name' => 'Description', 'desc' => 'Override the stock description', 'id' => $prefix . 'engine_desc', 'type' => 'text', 'attributes' => array('ng-model' => 'rfs.' . $prefix . 'engine_desc')), array('name' => 'Mass', 'desc' => 'Mass value in mt', 'id' => $prefix . 'engine_mass', 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('required' => 'required', 'ng-model' => 'rfs.' . $prefix . 'engine_mass', 'min' => 0.001, 'step' => 0.001)), array('name' => 'Extra Mass', 'desc' => 'Additional mass not from an engine', 'id' => $prefix . 'engine_extra_mass', 'default' => 0, 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('ng-model' => 'rfs.' . $prefix . 'engine_extra_mass', 'min' => 0, 'step' => 0.001)), array('name' => 'RCS Nozzles', 'desc' => 'Number of RCS Nozzles', 'id' => $prefix . 'rcs_nozzles', 'type' => 'text_number', 'sanitization_cb' => 'validate_int', 'escape_cb' => 'validate_int', 'attributes' => array('min' => 1, 'step' => 1)), array('name' => 'Tech Level', 'id' => $prefix . 'engine_tech_level', 'type' => 'select', 'options' => array('start' => __('Start', 'cmb'), '1' => __('Basic Rocketry', 'cmb'), '2' => __('General Rocketry', 'cmb'), '3' => __('Advanced Rocketry', 'cmb'), '4' => __('Heavy Rocketry', 'cmb'), '5' => __('Heavier Rocketry', 'cmb'), '6' => __('Very Heavy Rocketry', 'cmb'), '7' => __('Experimental Rocketry', 'cmb'), '8' => __('Experimental Rocketry (for NTRs)', 'cmb'))), array('name' => 'Engine Type', 'id' => $prefix . 'engine_type', 'taxonomy' => 'engine_type', 'type' => 'taxonomy_select'), array('name' => 'Flow Mode', 'desc' => 'Type of resource flow mode the engine will use to find its needed resources', 'id' => $prefix . 'engine_flow', 'type' => 'select', 'options' => array('STACK_PRIORITY_SEARCH' => __('Current Stage Only, Respect Crossfeed', 'cmb'), 'STAGE_PRIORITY_FLOW' => __('All Vessel, Stage Priority', 'cmb'), 'ALL_VESSEL' => __('All Vessel, Ignore Crossfeed', 'cmb'))), array('name' => 'IspSL Multiplier', 'id' => $prefix . 'engine_ispslm', 'default' => 1, 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('min' => 0.5, 'max' => 1.5, 'step' => 0.001)), array('name' => 'IspV Multiplier', 'id' => $prefix . 'engine_ispvm', 'default' => 1, 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('min' => 0.5, 'max' => 1.5, 'step' => 0.001)), array('name' => 'Thrust', 'desc' => 'Thrust value in kN', 'id' => $prefix . 'engine_thrust', 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('min' => 0, 'step' => 0.001)), array('name' => 'Throttle Type', 'desc' => 'By default, engines become more deeply throttleable as the tech level increases.', 'id' => $prefix . 'engine_throttle_type', 'type' => 'select', 'options' => array('full-throttle' => __('Fully Throttleable', 'cmb'), 'use-default' => __('Use Default Throttle', 'cmb'), 'use-default-tech' => __('Use Default Throttle After Tech Level', 'cmb'), 'custom-throttle' => __('Custom Throttle', 'cmb'), 'unthrottleable' => __('Unthrottleable', 'cmb'))), array('name' => 'Minimum Throttle', 'desc' => 'Minimum throttle that can be achieved by this engine (1 = 100%, 0.5 = 50%).', 'id' => $prefix . 'engine_throttle', 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('min' => 0, 'max' => 1, 'step' => 0.01)), array('name' => 'Throttle Tech Level', 'id' => $prefix . 'engine_throttle_tl', 'type' => 'select', 'options' => array('start' => __('Start', 'cmb'), '1' => __('Basic Rocketry', 'cmb'), '2' => __('General Rocketry', 'cmb'), '3' => __('Advanced Rocketry', 'cmb'), '4' => __('Heavy Rocketry', 'cmb'), '5' => __('Heavier Rocketry', 'cmb'), '6' => __('Very Heavy Rocketry', 'cmb'), '7' => __('Experimental Rocketry', 'cmb'), '8' => __('Experimental Rocketry (for NTRs)', 'cmb'))), array('name' => 'Engine Configs', 'desc' => 'Add fuel configs for your engines. First config is default.', 'id' => $prefix . 'engine_configs', 'type' => 'group', 'options' => array('group_title' => __('Config {#}', 'cmb'), 'add_button' => __('Add Config', 'cmb'), 'remove_button' => __('Remove Config', 'cmb')), 'fields' => array(array('name' => 'Fuel Mixture', 'id' => 'config_mixture', 'type' => 'select', 'options' => cmb_get_post_options(array('post_type' => 'mixture', 'posts_per_page' => -1)), 'attributes' => array('required' => 'required')), array('name' => 'Mass Ratio', 'id' => 'config_ratio', 'type' => 'text_number', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float', 'attributes' => array('min' => 0, 'step' => 0.01)), array('name' => 'Config Tech Node', 'desc' => 'Unlock this config only when the tech node is available.', 'id' => 'config_tech_node', 'type' => 'text'), array('name' => 'Thrust Curve', 'id' => 'config_thrust_curve', 'type' => 'select', 'options' => array('-1' => __('Custom', 'cmb'), '0' => __('Stock (no curve)', 'cmb'), '1' => __('Increasing', 'cmb'), '2' => __('Steady', 'cmb'), '3' => __('Steady Dip', 'cmb'), '4' => __('Decreasing', 'cmb'), '5' => __('Decreasing Dip', 'cmb'), '6' => __('Pulse Steady', 'cmb'))), array('name' => 'Custom Thrust Curve', 'desc' => 'Custom thrust curve. Make sure you know how to write proper curves if you use this!', 'id' => 'config_custom_curve', 'type' => 'textarea'))), array('name' => 'ModuleEngineFX', 'desc' => 'Does this engine use ModuleEngineFX?', 'id' => $prefix . 'engine_mefx', 'type' => 'checkbox'), array('name' => 'Extra Patch', 'desc' => 'MM patch added to the part config', 'id' => $prefix . 'engine_patch', 'type' => 'textarea_code'), array('name' => 'Per Config Patch', 'desc' => 'MM patch added to each engine config', 'id' => $prefix . 'engine_config_patch', 'type' => 'textarea_code'), array('name' => 'Full Flow Staged Cycle', 'desc' => 'Does this engine use FFSC?', 'id' => $prefix . 'engine_ffsc', 'type' => 'checkbox'), array('name' => 'Bimodal', 'desc' => 'Is this engine bimodal (i.e. "afterburner")?', 'id' => $prefix . 'engine_bimodal', 'type' => 'checkbox'), array('name' => 'Dedicated', 'desc' => 'Does this engine have a dedicated tank (i.e. SRB)?', 'id' => $prefix . 'engine_dedicated', 'type' => 'checkbox'), array('name' => 'MFT Tank', 'desc' => 'If the engine has an attached tank, set the tank type.', 'id' => $prefix . 'engine_mft', 'type' => 'text_medium'), array('name' => 'MFT Tank Volume', 'desc' => 'If the engine has an attached tank, set the volume in liters.', 'id' => $prefix . 'engine_mft_volume', 'type' => 'text_small', 'sanitization_cb' => 'validate_int', 'escape_cb' => 'validate_int'), array('name' => 'Ignition Mode', 'desc' => 'Check the box to override the derived number of ignitions', 'id' => $prefix . 'engine_ignition_mode', 'type' => 'select', 'options' => array('0' => __('None', 'cmb'), '1' => __('Respect Hypergolic', 'cmb'), '2' => __('Force Ignitions', 'cmb'))), array('name' => 'Ignitions', 'desc' => 'Number of ignitions available to the engine (see above). If >0, that many. If 0, unlimited. If <0, engine will have (current TL - this) ignitions, with a minimum of 1.', 'id' => $prefix . 'engine_ignitions', 'type' => 'text_small', 'sanitization_cb' => 'validate_ignitions', 'escape_cb' => 'validate_ignitions'), array('name' => 'Pressure Fed', 'desc' => 'Is this engine pressure fed?', 'id' => $prefix . 'engine_pressure_fed', 'type' => 'checkbox'), array('name' => 'Override Vectoring', 'desc' => 'Check the box to override existing gimbal', 'id' => $prefix . 'engine_vectoring_override', 'type' => 'checkbox'), array('name' => 'Gimbal Exists', 'desc' => 'Does a gimbal module exist for this engine?', 'id' => $prefix . 'engine_vectoring_exists', 'type' => 'checkbox'), array('name' => 'Vectoring Range', 'desc' => 'Degrees of vectoring for this engine.', 'id' => $prefix . 'engine_vectoring', 'type' => 'text_small', 'sanitization_cb' => 'validate_int', 'escape_cb' => 'validate_int'), array('name' => 'ModuleManager NEEDS', 'id' => $prefix . 'mm_needs', 'type' => 'text'), array('name' => 'ModuleManager HAS', 'id' => $prefix . 'mm_has', 'type' => 'text'), array('name' => 'ModuleManager Duplicate', 'id' => $prefix . 'mm_duplicate', 'type' => 'text')));
    $meta_boxes['mixture_data'] = array('id' => 'mixture_data', 'title' => 'Mixture Data', 'object_types' => array('mixture'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => 'Short Name', 'desc' => 'Abbreviated name', 'id' => $prefix . 'mixture_id', 'type' => 'text'), array('name' => 'Fuel', 'id' => $prefix . 'mixture_fuel', 'type' => 'select', 'options' => cmb_get_post_options(array('post_type' => 'resource', 'posts_per_page' => -1))), array('name' => 'Oxidizer', 'id' => $prefix . 'mixture_oxidizer', 'type' => 'select', 'options' => cmb_get_post_options(array('post_type' => 'resource', 'posts_per_page' => -1), true)), array('name' => 'Thrust Multiplier', 'id' => $prefix . 'mixture_thrust_mult', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'IspV Multiplier', 'id' => $prefix . 'mixture_ispv_mult', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'IspSL Multiplier', 'id' => $prefix . 'mixture_ispsl_mult', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'IspV', 'id' => $prefix . 'mixture_ispv', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'IspSL', 'id' => $prefix . 'mixture_ispsl', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'Fuel Density', 'id' => $prefix . 'mixture_fuel_density', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'Oxidizer Density', 'id' => $prefix . 'mixture_oxidizer_density', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'Typical Mixture Ratio', 'id' => $prefix . 'mixture_typical_mr', 'type' => 'text_small', 'sanitization_cb' => 'validate_float'), array('name' => 'Hypergolic', 'desc' => 'Indicates this mixture is hypergolic.', 'id' => $prefix . 'mixture_hypergolic', 'type' => 'checkbox')));
    $meta_boxes['resource_data'] = array('id' => 'resource_data', 'title' => 'Resource Data', 'object_types' => array('resource'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => 'Density', 'desc' => 'in g/cc', 'id' => $prefix . 'resource_density', 'type' => 'text', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float'), array('name' => 'Flow Mode', 'id' => $prefix . 'resource_flow', 'type' => 'text'), array('name' => 'Transfer Mode', 'id' => $prefix . 'resource_transfer', 'type' => 'text'), array('name' => 'Exists as Stock?', 'id' => $prefix . 'resource_exists', 'type' => 'checkbox'), array('name' => 'Fillable?', 'desc' => 'Is the resource fillable pre-launch?', 'id' => $prefix . 'resource_fillable', 'type' => 'checkbox'), array('name' => 'Utilization', 'desc' => 'Percent of the tank fillable by this resoucre. Values above 100% mean a pressurized/compressed resource.', 'id' => $prefix . 'resource_utilization', 'type' => 'text_small', 'sanitization_cb' => 'validate_percent_over', 'escape_cb' => 'validate_percent_over'), array('name' => 'Boiling Point', 'desc' => 'in degrees Celsius', 'id' => $prefix . 'resource_boiling', 'type' => 'text_small', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float'), array('name' => 'Lossrate', 'id' => $prefix . 'resource_lossrate', 'type' => 'text_small', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float'), array('name' => 'Cryo Tank Lossrate', 'id' => $prefix . 'resource_cryoloss', 'type' => 'text_small', 'sanitization_cb' => 'validate_float', 'escape_cb' => 'validate_float'), array('name' => 'Usage Type', 'id' => $prefix . 'resource_usage_type', 'type' => 'select', 'taxonomy' => 'usage', 'type' => 'taxonomy_multicheck')));
    return $meta_boxes;
}