コード例 #1
0
$tax_name = array('accessories', 'Accessories', 'Accessories');
// Labels for the Accessories taxonomy
$tax_labels = array('name' => sprintf(_x('%s', 'taxonomy general name', 'cuztom'), $tax_name[2]), 'singular_name' => sprintf(_x('%s', 'taxonomy singular name', 'cuztom'), $tax_name[1]), 'search_items' => sprintf(__('Search %s', 'cuztom'), $tax_name[2]), 'all_items' => sprintf(__('All %s', 'cuztom'), $tax_name[2]), 'parent_item' => sprintf(__('Parent %s', 'cuztom'), $tax_name[1]), 'parent_item_colon' => sprintf(__('Parent %s:', 'cuztom'), $tax_name[1]), 'edit_item' => sprintf(__('Edit %s', 'cuztom'), $tax_name[1]), 'update_item' => sprintf(__('Update %s', 'cuztom'), $tax_name[1]), 'add_new_item' => sprintf(__('Add New %s', 'cuztom'), $tax_name[1]), 'new_item_name' => sprintf(__('New %s Name', 'cuztom'), $tax_name[1]), 'menu_name' => sprintf(__('%s', 'cuztom'), $tax_name[2]));
// Arguments for the accessories taxonomy
$args = array('hierarchical' => false);
// Register the taxnomy Accessories
$taxonomy = register_cuztom_taxonomy($tax_name, $post_name, $args, $tax_labels);
// This is the data that we are adding to the accessories taxonomy. We are adding the
// max amount and an image for the accessories.
$taxonomy->add_term_meta(array(array('name' => 'max_amount', 'label' => 'Max Amount', 'description' => 'Max amount of this accessory type that can go on one board.', 'type' => 'text'), array('name' => 'accessory_image', 'label' => 'An Image of the accessory', 'description' => 'Please select a image for the accessory.', 'type' => 'image')));
// Fonts Taxonomy with labels
$tax_name = array('fonts', 'Fonts', 'Fonts');
$tax_labels = array('name' => sprintf(_x('%s', 'taxonomy general name', 'cuztom'), $tax_name[2]), 'singular_name' => sprintf(_x('%s', 'taxonomy singular name', 'cuztom'), $tax_name[1]), 'search_items' => sprintf(__('Search %s', 'cuztom'), $tax_name[2]), 'all_items' => sprintf(__('All %s', 'cuztom'), $tax_name[2]), 'parent_item' => sprintf(__('Parent %s', 'cuztom'), $tax_name[1]), 'parent_item_colon' => sprintf(__('Parent %s:', 'cuztom'), $tax_name[1]), 'edit_item' => sprintf(__('Edit %s', 'cuztom'), $tax_name[1]), 'update_item' => sprintf(__('Update %s', 'cuztom'), $tax_name[1]), 'add_new_item' => sprintf(__('Add New %s', 'cuztom'), $tax_name[1]), 'new_item_name' => sprintf(__('New %s Name', 'cuztom'), $tax_name[1]), 'menu_name' => sprintf(__('%s', 'cuztom'), $tax_name[2]));
// The argments for registering the font taxonomy
$args = array('hierarchical' => false);
$taxonomy = register_cuztom_taxonomy($tax_name, $post_name, $args, $tax_labels);
// This is the data that we are adding for the field.
$fields = array(array('name' => 'max_board_amount', 'label' => 'Maximum Amount of Boards', 'description' => 'This is the maximum amount of boards that the user can select.', 'type' => 'text'), array('name' => 'board_price_1', 'label' => 'Price for 1 board', 'type' => 'text'), array('name' => 'board_price_2', 'label' => 'Price for 2 boards', 'type' => 'text'), array('name' => 'board_price_3', 'label' => 'Price for 3 boards', 'type' => 'text'), array('name' => 'board_price_4', 'label' => 'Price for 4 boards', 'type' => 'text'), array('name' => 'board_price_5', 'label' => 'Price for 5 boards', 'type' => 'text'), array('name' => 'fonts', 'label' => 'Fonts', 'description' => 'Select the supported font styles.', 'type' => 'term_checkboxes', 'args' => array('taxonomy' => 'fonts'), 'options' => array('hide_empty' => false)), array('name' => 'max_character_count', 'label' => 'Maximum Character Count', 'description' => 'This is the maximum amount of characters that can be used on a text board.', 'type' => 'text'), array('name' => 'accessory_types', 'label' => 'Accessory Types', 'description' => 'Select the accessory types that this board supports.', 'type' => 'term_checkboxes', 'args' => array('taxonomy' => 'accessories'), 'options' => array('hide_empty' => false)));
// Create Metabox
$post_type->add_meta_box('meta_builder', 'Builder Data', $fields, 'normal', 'high');
// Board Builder Hooks
function boardBuilderHTML()
{
    $shortcodeHTML = '';
    ob_start();
    include MG_VIEWS . '/boardBuilder.php';
    $shortcodeHTML .= ob_get_clean();
    var_dump($shortcodeHTML);
    die;
    return $shortcodeHTML;
}
コード例 #2
0
<?php

//Connect CPT
$args = array('has_archive' => true, 'menu_icon' => 'dashicons-smiley', 'supports' => array('title'), 'labels' => array('name' => 'Staff'));
$staff = register_cuztom_post_type('Staff', $args);
$role = register_cuztom_taxonomy('Role', 'staff');
$staff->add_meta_box('staff', 'Employee', array(array('name' => 'image', 'label' => 'Profile image', 'description' => 'Dimensions 300px x 300px', 'type' => 'image'), array('name' => 'title', 'label' => 'Job Title', 'decription' => '', 'type' => 'text'), array('name' => 'email', 'label' => 'Email', 'description' => '', 'type' => 'text'), array('name' => 'phone', 'label' => 'Direct', 'description' => '', 'type' => 'text'), array('name' => 'extension', 'label' => 'Extension', 'description' => '', 'type' => 'text'), array('name' => 'bio', 'label' => 'Bio', 'description' => '', 'type' => 'wysiwyg')));
// Change the ADMIN columns for the edit CPT screen
function change_staff_columns($cols)
{
    $cols = array('cb' => '<input type="checkbox" />', 'title' => __('Name', 'trans'), 'avatar' => __('Profile Image', 'trans'), 'role' => __('Role', 'trans'), 'job' => __('Job Title', 'trans'), 'email' => __('Email', 'trans'), 'date' => __('Date', 'trans'));
    return $cols;
}
add_filter("manage_staff_posts_columns", "change_staff_columns");
// Add content to those ADMIN columns
function custom_staff_columns($column, $post_id)
{
    switch ($column) {
        case "avatar":
            $staff_image_id = get_post_meta($post_id, '_staff_image', true);
            $staff_image_url = wp_get_attachment_image_src($staff_image_id, 'thumbnail', true);
            if (!$staff_image_id) {
                echo '<div style="background-color: #cccccc; width: 150px; height: 150px; border-radius: 50%;"></div>';
            } else {
                echo '<img style="border-radius: 50%;" src=' . $staff_image_url[0] . '>';
            }
            break;
        case "job":
            echo get_post_meta($post_id, '_staff_title', true);
            break;
        case "email":
コード例 #3
0
ファイル: theme-func.php プロジェクト: haimlati82/hp
            $day_name = 'שישי';
            break;
        case 'ש':
            $day_name = 'שבת';
            break;
    }
    $day_name = 'יום ' . $day_name;
    return $day_name;
}
$message = register_cuztom_post_type('Message');
$event = register_cuztom_post_type('Event');
$gym_class = register_cuztom_post_type('Gym Class');
$employee = register_cuztom_post_type('Employee');
$form = register_cuztom_post_type('Form');
$gym_class->add_taxonomy('Class Day');
$page_group = register_cuztom_taxonomy('Page Group', 'page');
function live_stock_value()
{
    $quote = file_get_contents('http://www.google.com/finance/info?q=NYSE:HPQ');
    //Remove CR's from ouput - make it one line
    $json = str_replace("\n", "", $quote);
    //Remove //, [ and ] to build qualified string
    $data = substr($json, 4, strlen($json) - 5);
    //decode JSON data
    $json_output = json_decode($data, true);
    ?>
    <div class="b-wrap js-scale-block">
        <div class="b-exchange">
            <span class="company">Hewlett-Packard</span>
            <span class="price">$<?php 
    echo $json_output['l'];
コード例 #4
0
ファイル: post_meta.php プロジェクト: ankitparsanaa/foodapp
<?php

$post_meta = new Cuztom_Post_Type('block', array('menu_position' => 7, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail')));
$post_meta->add_meta_box('post_meta_box_1', 'post', array(array('name' => 'post_select', 'label' => 'post type', 'description' => 'Select a post type', 'type' => 'select', 'options' => array('content' => 'content', 'testimonial' => 'testimonial', 'blog' => 'blog'))));
$post_meta->add_meta_box('post_meta_box_2', 'slide setting', array(array('name' => 'name_checkbox', 'label' => 'Checkbox', 'description' => 'Checkbox Description', 'type' => 'checkbox', 'default_value' => 'on'), array('name' => 'testimonial', 'label' => 'Number of testimonial', 'description' => 'number of slides to show in the slider', 'type' => 'text')));
$post_meta->add_meta_box('post_meta_box_54', 'Post settings for the front page', array(array('name' => 'bg_color', 'label' => 'background color for block', 'description' => 'bg image', 'type' => 'image')));
$dish = new Cuztom_Post_Type('dish', array('menu_position' => 8, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail', 'comments')));
$dish_cat = register_cuztom_taxonomy('dish_cat ', 'dish');
$dish_cat->add_term_meta(array(array('name' => 'marker_icon', 'label' => 'Dish category Icon', 'description' => 'Upload dish image', 'type' => 'image')));
add_filter("manage_edit-dish_cat_columns", 'takeaway_types_tax_columns');
function takeaway_types_tax_columns($category_columns)
{
    $new_columns = array('cb' => '<input type="checkbox" />', 'name' => __('Name', 'casa'), 'marker' => __('Marker', 'casa'), 'description' => __('Description', 'casa'), 'slug' => __('Slug', 'casa'), 'posts' => __('Items', 'casa'));
    return $new_columns;
}
/*show type taxonomy column*/
add_filter("manage_dish_cat_custom_column", 'takeaway_manage_category_columns', 10, 3);
function takeaway_manage_category_columns($out, $column_name, $cat_id)
{
    $marker = get_option('term_meta_dish_cat_' . $cat_id, '');
    // print_r($marker);
    if (!empty($marker)) {
        $marker_icon = wp_get_attachment_image_src($marker['_marker_icon'], array(32, 32));
    }
    switch ($column_name) {
        case 'marker':
            if (!empty($marker_icon[0])) {
                $out .= '<img src="' . $marker_icon[0] . '" alt="">';
            }
            break;
        default:
コード例 #5
0
<?php

// Courses and Registration CPT
$args = array('has_archive' => true, 'menu_icon' => 'dashicons-welcome-learn-more', 'supports' => array('title'));
$course = register_cuztom_post_type('Course', $args);
$course_type = register_cuztom_taxonomy('Courses type', 'course');
// Add option to enable/disable register button to course
/*$course_type->add_term_meta (
	array(
		array(
			'name'        => 'register_on_off',
			'label'       => 'Register ON/OFF',
			'description' => 'Select to enable registration to this course type.',
			'type'        => 'checkbox'
		)
	)
);*/
$course->add_meta_box('Course Details', 'course_details', array(array('name' => 'register_open', 'label' => 'Registration Open', 'description' => 'Please select this to make registration open for this course.(Default is closed.)', 'type' => 'checkbox', 'default_value' => 'off'), array('name' => 'register_form_id', 'label' => 'Registration Form ID', 'description' => 'Please enter gravity form id.', 'type' => 'text'), array('name' => 'description', 'label' => 'Course Description', 'description' => 'Description of course', 'type' => 'wysiwyg'), array('name' => 'price', 'label' => 'Price', 'description' => 'Example: 899.00', 'type' => 'text'), array('name' => 'course_in_week', 'label' => 'Course no. of days in week', 'description' => 'Enter course no. of days in week', 'type' => 'text'), array('name' => 'duration', 'label' => 'Course Duration', 'description' => 'Enter period when course ends', 'type' => 'text'), array('name' => 'schedule', 'label' => 'Course schedule', 'description' => 'Enter schedule/season', 'type' => 'text'), array('name' => 'end_of_course', 'label' => 'Course End Date', 'description' => 'Enter course end date', 'type' => 'date')));
//Organize admin columns
function course_columns($cols)
{
    $cols = array('cb' => '<input type="checkbox" />', 'title' => __('Title', 'trans'), '_course_details_price' => __('Price', 'trans'), '_course_details_instructor' => __('Instructor', 'trans'), '_course_details_spots' => __('Availability', 'trans'), 'date' => __('Date', 'trans'));
    return $cols;
}
add_filter("manage_course_posts_columns", "course_columns");
コード例 #6
0
<?php

//Timeline CPT
$args = array('has_archive' => true, 'menu_icon' => 'dashicons-archive', 'supports' => array('title', 'thumbnail', 'editor', 'excerpt'), 'rewrite' => array('slug' => 'timeline'), 'show_ui' => true);
$timeline = register_cuztom_post_type('Timeline', $args);
$list = register_cuztom_taxonomy('List', 'timeline');
$list->add_term_meta(array(array('name' => 'image', 'label' => 'Featured Image', 'description' => '', 'type' => 'image'), array('name' => 'headline', 'label' => 'Featured Headline', 'description' => '', 'type' => 'text'), array('name' => 'icon', 'label' => 'Icon', 'description' => 'Go to <a href="https://fortawesome.github.io/Font-Awesome/icons/">Font Awesome</a>, chose a font and copy and paste snippet into text box. <br>For example: <b style="color: red;">fa-trophy</b>', 'type' => 'text'), array('name' => 'color', 'label' => 'Background Colour', 'description' => 'Pick a colour for the background of the timeline icon.', 'type' => 'color')));
$timeline->add_meta_box('timeline', 'timeline', array(array('name' => 'pubdate', 'label' => 'Date', 'description' => 'Enter date/year', 'type' => 'text')));
// Change the ADMIN columns for the edit CPT screen
function change_timeline_columns($cols)
{
    $cols = array('cb' => '<input type="checkbox" />', 'title' => __('Title', 'trans'), 'image' => __('Featured Image', 'trans'), 'list' => __('List', 'trans'), 'excerpt' => __('Excerpt', 'trans'), 'date' => __('Date', 'trans'));
    return $cols;
}
add_filter("manage_timeline_posts_columns", "change_timeline_columns");
// Add content to those ADMIN columns
function custom_timeline_columns($column, $post_id)
{
    switch ($column) {
        case "excerpt":
            echo wp_trim_words(get_the_excerpt(), 20, '...');
            break;
        case "image":
            if (has_post_thumbnail()) {
                echo the_post_thumbnail('thumbnail');
            } else {
                echo '<div style="background-color: #cccccc; width: 150px; height: 150px;"></div>';
            }
            break;
        case "list":
            echo get_the_term_list($post_id, 'list', '', ', ', '');
コード例 #7
0
        $title = 'Add Name';
    }
    return $title;
}
add_filter('enter_title_here', 'change_default_title');
/*-----------------------------------------------------------------------------------*/
/*	  custom meta box of service section 
/*-----------------------------------------------------------------------------------*/
$service = register_cuztom_post_type('service', array('supports' => array('title', 'editor'), 'show_names' => false, 'menu_icon' => 'dashicons-id'));
$service->add_meta_box('service_setting_id', 'Service Section Settings', array(array('name' => 'icon', 'label' => 'Icon', 'description' => 'Write icon class - "li_star, li_lab, li_world" <a target="_blank" href="https://github.com/fontello/linecons.font">Click Here</a>', 'type' => 'text'), array('name' => 'learn_more', 'label' => 'Edit Learn More', 'description' => '', 'type' => 'text', 'default_value' => 'Learn More'), array('name' => 'animation', 'label' => 'Animation', 'description' => 'Write the class here like "from-bottom delay-200"', 'type' => 'text', 'default_value' => 'from-bottom delay-200')));
/*-----------------------------------------------------------------------------------*/
/*	  portfolio custom post type with  metabox
/*-----------------------------------------------------------------------------------*/
$gallery = register_cuztom_post_type('gallery', array('menu_icon' => 'dashicons-analytics', 'rewrite' => array('slug' => 'galleries', 'with_front' => false), 'supports' => array('title', 'thumbnail')));
$gallery->add_meta_box('gallery_setting_id', 'gallery Section Settings', array(array('name' => 'caption', 'label' => 'Caption', 'description' => 'Write Image Caption', 'type' => 'textarea')));
$gallery = register_cuztom_taxonomy('filter_menu', array('gallery'), array('hierarchical' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true));
/*-----------------------------------------------------------------------------------*/
/*	  causes custom post type with  metabox
/*-----------------------------------------------------------------------------------*/
$causes = register_cuztom_post_type('causes', array('menu_icon' => 'dashicons-migrate', 'rewrite' => array('slug' => 'causes', 'with_front' => false), 'supports' => array('title', 'thumbnail', 'editor')));
$causes->add_meta_box('causes_setting_id', 'Causes Section Settings', array(array('name' => 'donation_currency_symbol', 'label' => 'Currency Symbol', 'description' => 'Add your Currency Symbol', 'default_value' => '$', 'type' => 'text'), array('name' => 'donation_goal', 'label' => 'Donation goal', 'description' => 'How much is the donation goal for this cause.', 'type' => 'text'), array('name' => 'donation_manual', 'label' => 'Donate manually', 'description' => 'Write manual ammount, that will add with current ammount', 'type' => 'text'), array('name' => 'donation_paypal', 'label' => 'PayPal', 'description' => 'Write Your PayPal Id.', 'type' => 'text'), array('name' => 'bank_transfer_manual', 'label' => 'Direct Bank Transfer', 'description' => 'Trasfer money to the following bank account (Write the bank account info)', 'type' => 'textarea'), array('name' => 'chaque_payment', 'label' => 'Check Payment', 'description' => 'Send chaque to the following address. (Writer the address)', 'type' => 'textarea'), array('name' => 'menual_payment_link', 'label' => 'Custom URL/WooCommerce Product link', 'description' => "<b style=\"color: red;\">If PayPal Donate field blank, This custom link will work. Paste woocommerce product link</b>", 'type' => 'text')));
/*-----------------------------------------------------------------------------------*/
/*	custom post type of event with meta box 
/*-----------------------------------------------------------------------------------*/
$event = register_cuztom_post_type('event', array('menu_icon' => 'dashicons-art', 'rewrite' => array('slug' => 'events', 'with_front' => false), 'supports' => array('title', 'thumbnail', 'editor')));
$event->add_meta_box('events_setting_id', 'Events Section Settings', array(array('name' => 'event_time', 'label' => 'Event Start', 'description' => 'When event will start', 'type' => 'time'), array('name' => 'event_time_end', 'label' => 'Event End', 'description' => 'When event will end', 'type' => 'time'), array('name' => 'event_date', 'label' => 'Event Date', 'description' => 'Event starting date', 'type' => 'date'), array('name' => 'event_timezone', 'label' => 'Event Timezone', 'description' => 'Write Time zone', 'type' => 'text'), array('name' => 'event_place', 'label' => 'Event Place', 'description' => 'Where event will held', 'type' => 'textarea'), array('name' => 'event_place_map', 'label' => 'Map', 'description' => 'write longitude & latitude with coma. <a target="_blank" href="http://www.gps-coordinates.net/">Click here</a> for help.', 'type' => 'text')));
/*-----------------------------------------------------------------------------------*/
/*	post formate meta box 
/*-----------------------------------------------------------------------------------*/
$posts = new Cuztom_Post_Type('post');
$posts->add_meta_box('post-meta-quote', 'Page Head', array(array('name' => 'speaker', 'label' => 'Who said that', 'description' => 'Write the name of speaker name', 'type' => 'text')));
コード例 #8
0
<?php

//Connect CPT
$args = array('has_archive' => true, 'menu_icon' => 'dashicons-carrot', 'supports' => array('title'), 'labels' => array('name' => 'Recipe for Change'));
$chef = register_cuztom_post_type('Recipe', $args);
$cat = register_cuztom_taxonomy('Category', 'recipe');
$sponsors = register_cuztom_taxonomy('Sponsors', 'recipe');
$sponsors->add_term_meta(array(array('name' => 'image', 'label' => 'Image', 'description' => 'Dimensions 300px x 300px', 'type' => 'image'), array('name' => 'link', 'label' => 'Sponsor Link', 'decription' => '', 'type' => 'text'), array('name' => 'tier', 'label' => 'Sponsor Tier', 'description' => '', 'type' => 'select', 'options' => array('value1' => 'Title', 'value2' => 'Gold', 'value3' => 'Silver', 'value4' => 'Bronze', 'value5' => 'Green', 'value6' => 'Year'), 'default_value' => 'value6')));
$chef->add_meta_box('chef', 'Recipe for Change', array(array('name' => 'image', 'label' => 'Image', 'description' => 'Dimensions 300px x 300px', 'type' => 'image'), array('name' => 'restaurant', 'label' => 'Name', 'decription' => '', 'type' => 'text'), array('name' => 'website', 'label' => 'Website Address', 'decription' => '', 'type' => 'text'), array('name' => 'description', 'label' => 'Description', 'description' => 'This can be used as either a description of Beverage company or Chef Bio', 'type' => 'wysiwyg'), array('name' => 'menu', 'label' => 'Menu <i>(Optional)</i>', 'description' => '', 'type' => 'wysiwyg')));