File: /www/wwwroot/biographybirthday.com/wp-content/themes/bio/metabox/metabox.php
<?php
/**
* Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory)
*
* Be sure to replace all instances of 'yourprefix_' with your project's prefix.
* http://nacin.com/2010/05/11/in-wordpress-prefix-everything/
*
* @category marriedBiography
* @package marriedBiography
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* @link https://github.com/WebDevStudios/CMB2
*/
// initilizing metabox
if ( file_exists( get_template_directory() . '/metabox/init.php' ) ) {
require_once get_template_directory() . '/metabox/init.php';
} elseif ( file_exists( get_template_directory() . '/metabox/init.php' ) ) {
require_once get_template_directory() . '/metabox/init.php';
}
/**
* Hook in and add metabox.
*/
function biography_gender_select_options() {
// return a standard options array for gender
return array(
'' => __( 'Undefined', 'gossip' ),
'Male' => __( 'Male', 'gossip' ),
'Female' => __( 'Female', 'gossip' ),
);
}
/**
* select for month
*/
function biography_date_select_options() {
// return a standard options array for gender
return array(
'' => __('None', 'gossip'),
'January' => __( 'January', 'gossip' ),
'February' => __( 'February', 'gossip' ),
'March' => __( 'March', 'gossip' ),
'April' => __( 'April', 'gossip' ),
'May' => __( 'May', 'gossip' ),
'June' => __( 'June', 'gossip' ),
'July' => __( 'July', 'gossip' ),
'August' => __( 'August', 'gossip' ),
'September' => __( 'September', 'gossip' ),
'October' => __( 'October', 'gossip' ),
'November' => __( 'November', 'gossip' ),
'December' => __( 'December', 'gossip' ),
);
}
function biography_marital_select_options() {
// return a standard options array for marital status
return array(
'not_identified' => __( 'Not Identifed', 'gossip' ),
'married' => __( 'Married', 'gossip' ),
'single' => __( 'Single', 'gossip' ),
'divorce' => __( 'Divorced', 'gossip' ),
'in-relation' => __( 'In Relation', 'gossip' ),
'widow' => __( 'Widow', 'gossip' ),
);
}
function biography_affair_select_options() {
// return a standard options array for marital status
return array(
'not_identified' => __( 'Not Identifed', 'gossip' ),
'1' => __( 'Yes', 'gossip' ),
'0' => __( 'No', 'gossip' ),
);
}
function biography_lesbian_gay_select_options() {
// return a standard options array for marital status
return array(
'not_identified' => __( 'Not Identifed', 'gossip' ),
'1' => __( 'Yes', 'gossip' ),
'0' => __( 'No', 'gossip' ),
);
}
// sanitize optional year and month field
function sanitizeInput($string) {
return ereg_replace("[^0-9]", "", $string);
}
add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' );
function yourprefix_register_demo_metabox() {
$prefix = 'bio_';
$cmb_demo = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => esc_html__( 'Celebrity Profile', 'gossip' ),
'object_types' => array( 'post', ), // Post type
) );
$cmb_demo->add_field( array(
'name' => 'Photos',
'desc' => '',
'id' => $prefix . 'photos',
'type' => 'file_list',
// 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
// 'query_args' => array( 'type' => 'image' ), // Only images attachment
// Optional, override default text strings
'text' => array(
'add_upload_files_text' => 'Add or Upload Files', // default: "Add or Upload Files"
'remove_image_text' => 'Remove Image', // default: "Remove Image"
'file_text' => 'File', // default: "File:"
'file_download_text' => 'Download', // default: "Download"
'remove_text' => 'Remove', // default: "Remove"
),
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'First Name', 'gossip' ),
'id' => $prefix . 'first_name',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Last Name', 'gossip' ),
'id' => $prefix . 'last_name',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Gender', 'gossip' ),
'id' => $prefix . 'gender',
'type' => 'select',
'default' => '',
'options_cb' => 'biography_gender_select_options',
) );
// $days[] = 'Select';
// for($k = 1; $k <= 31; $k++){
// $digit = str_pad($k,2,'0',STR_PAD_LEFT);
// $days[$digit] = $digit;
// }
//
// $months[] = 'Select';
// for($k = 1; $k <= 12; $k++){
// $digit = str_pad($k,2,'0',STR_PAD_LEFT);
// $months[$digit] = $digit;
// }
//
// $years[] = 'Select';
// for($k = 1900; $k <= date('Y'); $k++){
// $years[$k] = $k;
// }
$cmb_demo->add_field( array(
'name' => esc_html__( 'Date of Birth', 'gossip' ),
'id' => $prefix . 'dob',
'type' => 'text_date',
'date_format' => 'Y-m-d'
) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Birth Year', 'gossip' ),
// 'id' => $prefix . 'birth_year',
// 'type' => 'select',
// 'options' => $years
// ) );
//
//
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Birth Month', 'gossip' ),
// 'id' => $prefix . 'birth_month',
// 'type' => 'select',
// 'options'=> $months
// ) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Birth Day', 'gossip' ),
// 'id' => $prefix . 'birth_day',
// 'type' => 'select',
// 'options' => $days
// ) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Horoscope', 'gossip' ),
// 'id' => $prefix . 'horoscope',
// 'type' => 'text_medium',
// ) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Net Worth', 'gossip' ),
'id' => $prefix . 'fact_net-worth',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Salary', 'gossip' ),
'id' => $prefix . 'fact_salary',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Height (in inches )', 'gossip' ),
'id' => $prefix . 'height',
'type' => 'text_medium',
'attributes' => array(
'type' => 'number',
),
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Weight (in kg )', 'gossip' ),
'id' => $prefix . 'weight',
'type' => 'text_medium',
'attributes' => array(
'type' => 'number',
),
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Marital Status', 'mbiography' ),
'id' => $prefix . 'maritalstatus',
'type' => 'select',
'default' => 'not_identified',
'options_cb' => 'biography_marital_select_options',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Married Date', 'gossip' ),
'id' => $prefix . 'married_date',
'type' => 'text_date',
'date_format' => 'Y-m-d'
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Country', 'gossip' ),
'id' => $prefix . 'country',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'City', 'gossip' ),
'id' => $prefix . 'city',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Birth Place', 'gossip' ),
'id' => $prefix . 'fact_birth-place',
'type' => 'text_medium',
) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Death Year', 'gossip' ),
// 'id' => $prefix . 'death_year',
// 'type' => 'select',
// 'options' => $years
// ) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Date of Death', 'gossip' ),
'id' => $prefix . 'dod',
'type' => 'text_date',
'date_format' => 'Y-m-d'
) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Death Month', 'gossip' ),
// 'id' => $prefix . 'death_month',
// 'type' => 'select',
// 'options' => $months
// ) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Death Day', 'gossip' ),
// 'id' => $prefix . 'death_day',
// 'type' => 'select',
// 'options' => $days
// ) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Nationality', 'gossip' ),
'id' => $prefix . 'fact_nationality',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Ethnicity', 'gossip' ),
'id' => $prefix . 'fact_ethnicity',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Profession', 'gossip' ),
'id' => $prefix . 'profession',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Religion', 'gossip' ),
'id' => $prefix . 'fact_religion',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Education', 'gossip' ),
'id' => $prefix . 'fact_education',
'type' => 'text_medium',
) ); $cmb_demo->add_field( array(
'name' => esc_html__( 'Eye Color', 'gossip' ),
'id' => $prefix . 'fact_eye-color',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Hair Color', 'gossip' ),
'id' => $prefix . 'fact_hair-color',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Body Size', 'gossip' ),
'id' => $prefix . 'fact_body-size',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Father', 'gossip' ),
'id' => $prefix . 'fact_father',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Mother', 'gossip' ),
'id' => $prefix . 'fact_mother',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Sibling', 'gossip' ),
'id' => $prefix . 'fact_sibling',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Kids', 'gossip' ),
'id' => $prefix . 'fact_kids',
'type' => 'text_medium',
) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Status', 'gossip' ),
// 'id' => $prefix . 'fact_status',
// 'type' => 'text_medium',
// ) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Dating With', 'gossip' ),
'id' => $prefix . 'fact_dating',
'type' => 'text_medium',
) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Married Year', 'gossip' ),
// 'id' => $prefix . 'married_year',
// 'type' => 'select',
// 'options' => $years
// ) );
//
//
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Married Month', 'gossip' ),
// 'id' => $prefix . 'married_month',
// 'type' => 'select',
// 'options'=> $months
// ) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Married Day', 'gossip' ),
// 'id' => $prefix . 'married_day',
// 'type' => 'select',
// 'options' => $days
// ) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Married With', 'gossip' ),
// 'id' => $prefix . 'fact_married',
// 'type' => 'text_medium',
// ) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Husband', 'gossip' ),
'id' => $prefix . 'fact_husband',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Wife', 'gossip' ),
'id' => $prefix . 'fact_wife',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Break Up With', 'gossip' ),
'id' => $prefix . 'fact_break-up',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Divorce With', 'gossip' ),
'id' => $prefix . 'fact_divorce',
'type' => 'text_medium',
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Gay / Lesbian', 'gossip' ),
'id' => $prefix . 'gay_lesbian',
'type' => 'text_medium',
) );
// $cmb_demo->add_field( array(
// 'name' => 'Facts',
// 'desc' => 'Facts',
// 'type' => 'title',
// 'id' => 'facts'
// ) );
// $cmb_demo->add_field( array(
// 'name' => esc_html__( 'Age', 'gossip' ),
// 'id' => $prefix . 'fact_age',
// 'type' => 'text_medium',
// ) );
// $cmb_demo->add_field( array(
// 'name' => 'Photos',
// 'desc' => 'Photos for the post',
// 'type' => 'title',
// 'id' => 'photos'
// ) );
$cmb_demo->add_field( array(
'name' => 'Social Media',
'desc' => 'Social Media',
'type' => 'title',
'id' => 'social'
) );
$social_medias = array(
'facebook' => 'Facebook',
'twitter' => 'Twitter',
// 'google' => 'Google+',
'youtube' =>'Youtube',
'instagram' => 'Instagram',
// 'vevo' => 'Vevo',
// 'itunes' => 'iTunes',
'personal-web' => 'Personal Web',
'imdb' => 'IMDB',
'wiki' => 'Wiki'
);
foreach($social_medias as $key=>$social){
$cmb_demo->add_field( array(
'name' => esc_html__( $social, 'gossip' ),
'id' => $prefix . 'social_'.$key,
'type' => 'text_medium',
) );
}
$cmb_demo->add_field( array(
'name' => esc_html__( 'Quotes (seperate by ;)', 'gossip' ),
'id' => $prefix . 'quotes',
'type' => 'textarea',
));
}