Exemplo n.º 1
0
<?php

require_once 'post_type.class.php';
require_once 'event_metaboxes.php';
STM_PostType::registerPostType('event', __('Event', STM_DOMAIN), array('menu_icon' => 'dashicons-calendar', 'supports' => array('title', 'editor', 'thumbnail', 'comments'), 'taxonomies' => array('post_tag')));
STM_PostType::addTaxonomy('event_category', __('Categories', STM_DOMAIN), 'event');
STM_PostType::registerPostType('donation', __('Donation', STM_DOMAIN), array('menu_icon' => 'dashicons-download', 'supports' => array('title', 'editor', 'thumbnail', 'excerpt'), 'taxonomies' => array('post_tag')));
STM_PostType::addTaxonomy('donation_category', __('Categories', STM_DOMAIN), 'donation');
STM_PostType::registerPostType('volunteer', __('Volunteer', STM_DOMAIN), array('menu_icon' => 'dashicons-universal-access', 'supports' => array('title', 'thumbnail', 'excerpt'), 'exclude_from_search' => true, 'publicly_queryable' => false));
STM_PostType::registerPostType('testimonial', __('Testimonial', STM_DOMAIN), array('menu_icon' => 'dashicons-testimonial', 'supports' => array('title', 'thumbnail', 'excerpt'), 'exclude_from_search' => true, 'publicly_queryable' => false));
STM_PostType::registerPostType('gallery', __('Gallery Image', STM_DOMAIN), array('menu_icon' => 'dashicons-format-gallery', 'supports' => array('title', 'thumbnail'), 'exclude_from_search' => true, 'publicly_queryable' => false));
STM_PostType::registerPostType('donor', __('Donor', STM_DOMAIN), array('supports' => array('title'), 'exclude_from_search' => true, 'publicly_queryable' => false, 'show_in_menu' => 'edit.php?post_type=donation'));
STM_PostType::addMetaBox('page_options', __('Page Options', STM_DOMAIN), array('page', 'post', 'event', 'donation'), '', '', '', array('fields' => array('separator_page_background' => array('label' => __('Page Background', STM_DOMAIN), 'type' => 'separator'), 'page_bg_image' => array('label' => __('Background Image', STM_DOMAIN), 'type' => 'image'), 'page_bg_position' => array('label' => __('Background Position', STM_DOMAIN), 'type' => 'text'), 'page_bg_repeat' => array('label' => __('Background Repeat', STM_DOMAIN), 'type' => 'select', 'options' => array('repeat' => __('Repeat', STM_DOMAIN), 'no-repeat' => __('No Repeat', STM_DOMAIN), 'repeat-x' => __('Repeat-X', STM_DOMAIN), 'repeat-y' => __('Repeat-Y', STM_DOMAIN))), 'separator_title_box' => array('label' => __('Title Box', STM_DOMAIN), 'type' => 'separator'), 'title' => array('label' => __('Title', STM_DOMAIN), 'type' => 'select', 'options' => array('show' => __('Show', STM_DOMAIN), 'hide' => __('Hide', STM_DOMAIN))), 'title_box_bg_color' => array('label' => __('Background Color', STM_DOMAIN), 'type' => 'color_picker'), 'title_box_font_color' => array('label' => __('Font Color', STM_DOMAIN), 'type' => 'color_picker'), 'title_box_bg_image' => array('label' => __('Background Image', STM_DOMAIN), 'type' => 'select', 'options' => array('none' => __('None', STM_DOMAIN), 'default_1' => __('Default 1', STM_DOMAIN), 'default_2' => __('Default 2', STM_DOMAIN), 'default_3' => __('Default 3', STM_DOMAIN), 'default_4' => __('Default 4', STM_DOMAIN), 'default_5' => __('Default 5', STM_DOMAIN), 'default_6' => __('Default 6', STM_DOMAIN), 'default_7' => __('Default 7', STM_DOMAIN))), 'title_box_custom_bg_image' => array('label' => __('Custom Background Image', STM_DOMAIN), 'type' => 'image'), 'title_box_bg_position' => array('label' => __('Background Position', STM_DOMAIN), 'type' => 'text'), 'title_box_bg_repeat' => array('label' => __('Background Repeat', STM_DOMAIN), 'type' => 'select', 'options' => array('repeat' => __('Repeat', STM_DOMAIN), 'no-repeat' => __('No Repeat', STM_DOMAIN), 'repeat-x' => __('Repeat-X', STM_DOMAIN), 'repeat-y' => __('Repeat-Y', STM_DOMAIN))))));
STM_PostType::addMetaBox('donation_information', __('Donation Information', STM_DOMAIN), array('donation'), '', '', '', array('fields' => array('donation_target' => array('label' => __('Target Amount', STM_DOMAIN), 'type' => 'text'), 'donation_raised' => array('label' => __('Raised Amount', STM_DOMAIN), 'type' => 'text'), 'donation_currency' => array('label' => __('Currency', STM_DOMAIN), 'type' => 'text'), 'donation_donors' => array('label' => __('Donors Count', STM_DOMAIN), 'type' => 'text'))));
STM_PostType::addMetaBox('sidebar_options', __('Sidebar Options', STM_DOMAIN), array('page', 'post'), '', '', '', array('fields' => array('sidebar_position' => array('label' => __('Sidebar Position', STM_DOMAIN), 'type' => 'select', 'options' => array('right' => __('Right', STM_DOMAIN), 'left' => __('Left', STM_DOMAIN), 'none' => __('None', STM_DOMAIN))))));
STM_PostType::addMetaBox('volunteer_info', __('Volunteer Info', STM_DOMAIN), array('volunteer'), '', '', '', array('fields' => array('volunteer_email' => array('label' => __('Email', STM_DOMAIN), 'type' => 'text'), 'volunteer_age' => array('label' => __('Age', STM_DOMAIN), 'type' => 'text'), 'volunteer_city' => array('label' => __('City', STM_DOMAIN), 'type' => 'text'), 'volunteer_phone' => array('label' => __('Phone', STM_DOMAIN), 'type' => 'text'), 'volunteer_major' => array('label' => __('Major', STM_DOMAIN), 'type' => 'text'), 'volunteer_zip' => array('label' => __('ZIP code', STM_DOMAIN), 'type' => 'text'), 'volunteer_facebook' => array('label' => __('Facebook', STM_DOMAIN), 'type' => 'text'), 'volunteer_twitter' => array('label' => __('Twitter', STM_DOMAIN), 'type' => 'text'))));
STM_PostType::addMetaBox('testimonial_info', __('Testimonial Info', STM_DOMAIN), array('testimonial'), '', '', '', array('fields' => array('testimonial_city' => array('label' => __('City', STM_DOMAIN), 'type' => 'text'))));
STM_PostType::addMetaBox('donor_info', __('Donor Info', STM_DOMAIN), array('donor'), '', '', '', array('fields' => array('donor_email' => array('label' => __('Email', STM_DOMAIN), 'type' => 'text'), 'donor_phone' => array('label' => __('Phone', STM_DOMAIN), 'type' => 'text'), 'donor_address' => array('label' => __('Address', STM_DOMAIN), 'type' => 'text'), 'donor_note' => array('label' => __('Additional Note', STM_DOMAIN), 'type' => 'text'), 'donor_amount' => array('label' => __('Amount', STM_DOMAIN), 'type' => 'text'), 'donor_donation' => array('label' => __('Donation', STM_DOMAIN), 'type' => 'text'))));
add_action('admin_menu', 'stm_register_donation_options_menu');
if (!function_exists('stm_register_donation_options_menu')) {
    function stm_register_donation_options_menu()
    {
        add_submenu_page('edit.php?post_type=donation', __('Donation options', STM_DOMAIN), __('Donation options', STM_DOMAIN), 'manage_options', 'donation', 'stm_donation_options');
    }
}
if (!function_exists('donation_options')) {
    function stm_donation_options()
    {
        if (!empty($_POST['donation_options'])) {
            set_theme_mod('donation_options', $_POST['donation_options']);
        }
Text Domain: stm_post_type
Version: 1.1
*/
define('STM_POST_TYPE', 'stm_post_type');
$plugin_path = dirname(__FILE__);
require_once $plugin_path . '/post_type.class.php';
$options = get_option('stm_post_types_options');
$defaultPostTypesOptions = array('teachers' => array('title' => __('Teachers', STM_POST_TYPE), 'plural_title' => __('Teachers', STM_POST_TYPE), 'rewrite' => 'teachers'), 'gallery' => array('title' => __('Gallery', STM_POST_TYPE), 'plural_title' => __('Galleries', STM_POST_TYPE), 'rewrite' => 'gallery'), 'events' => array('title' => __('Events', STM_POST_TYPE), 'plural_title' => __('Events', STM_POST_TYPE), 'rewrite' => 'events'));
$stm_post_types_options = wp_parse_args($options, $defaultPostTypesOptions);
STM_PostType::registerPostType('testimonial', __('Testimonial', STM_POST_TYPE), array('menu_icon' => 'dashicons-testimonial', 'supports' => array('title', 'excerpt', 'thumbnail'), 'exclude_from_search' => true, 'publicly_queryable' => false));
STM_PostType::registerPostType('sidebar', __('Sidebar', STM_POST_TYPE), array('menu_icon' => 'dashicons-schedule', 'supports' => array('title', 'editor'), 'exclude_from_search' => true, 'publicly_queryable' => false));
// Teachers post type
STM_PostType::registerPostType('teachers', $stm_post_types_options['teachers']['title'], array('pluralTitle' => $stm_post_types_options['teachers']['plural_title'], 'menu_icon' => 'dashicons-awards', 'supports' => array('title', 'editor', 'thumbnail', 'comments', 'excerpt'), 'rewrite' => array('slug' => $stm_post_types_options['teachers']['rewrite'])));
// Gallery
STM_PostType::registerPostType('gallery', $stm_post_types_options['gallery']['title'], array('menu_icon' => 'dashicons-images-alt', 'pluralTitle' => $stm_post_types_options['gallery']['plural_title'], 'supports' => array('title', 'thumbnail'), 'rewrite' => array('slug' => $stm_post_types_options['gallery']['rewrite'])));
STM_PostType::addTaxonomy('gallery_category', __('Categories', STM_POST_TYPE), 'gallery');
// Events
STM_PostType::registerPostType('events', $stm_post_types_options['events']['plural_title'], array('menu_icon' => 'dashicons-calendar-alt', 'pluralTitle' => $stm_post_types_options['events']['plural_title'], 'taxonomies' => array('post_tag'), 'supports' => array('title', 'thumbnail', 'editor', 'excerpt', 'revisions'), 'rewrite' => array('slug' => $stm_post_types_options['events']['rewrite'])));
STM_PostType::registerPostType('event_participant', __('Participant', STM_POST_TYPE), array('supports' => array('title', 'excerpt'), 'exclude_from_search' => true, 'publicly_queryable' => false, 'show_in_menu' => 'edit.php?post_type=events'));
// Get experts and list them in dropdown woo products
add_action('admin_init', 'expert_list');
function expert_list()
{
    if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
        $experts = array('no_expert' => 'Choose teacher for course');
        $experts_args = array('post_type' => 'teachers', 'post_status' => 'publish', 'posts_per_page' => -1);
        $experts_query = new WP_Query($experts_args);
        foreach ($experts_query->posts as $expert) {
            $experts[$expert->ID] = $expert->post_title;
        }
        if (!empty($experts)) {
Exemplo n.º 3
0
<?php

/*
Plugin Name: STM Post Type
Plugin URI: http://stylemixthemes.com/
Description: STM Post Type
Author: Stylemix Themes
Author URI: http://stylemixthemes.com/
Text Domain: stm_post_type
Version: 1.0
*/
define('STM_POST_TYPE', 'stm_post_type');
$plugin_path = dirname(__FILE__);
require_once $plugin_path . '/post_type.class.php';
STM_PostType::registerPostType('project', __('Project', STM_POST_TYPE), array('menu_icon' => 'dashicons-building', 'supports' => array('title', 'editor', 'thumbnail', 'comments', 'excerpt')));
STM_PostType::addTaxonomy('project_category', __('Categories', STM_POST_TYPE), 'project');
STM_PostType::registerPostType('service', __('Service', STM_POST_TYPE), array('menu_icon' => 'dashicons-lightbulb', 'supports' => array('title', 'editor', 'thumbnail', 'comments', 'excerpt')));
STM_PostType::registerPostType('testimonial', __('Testimonial', STM_POST_TYPE), array('menu_icon' => 'dashicons-testimonial', 'supports' => array('title', 'thumbnail', 'excerpt'), 'exclude_from_search' => true, 'publicly_queryable' => false));
STM_PostType::registerPostType('sidebar', __('Sidebar', STM_POST_TYPE), array('menu_icon' => 'dashicons-schedule', 'supports' => array('title', 'editor'), 'exclude_from_search' => true, 'publicly_queryable' => false));
STM_PostType::addMetaBox('page_options', __('Page Options', STM_POST_TYPE), array('page', 'post', 'service', 'project', 'product'), '', '', '', array('fields' => array('separator_page_background' => array('label' => __('Page Background', STM_POST_TYPE), 'type' => 'separator'), 'page_bg_image' => array('label' => __('Background Image', STM_POST_TYPE), 'type' => 'image'), 'page_bg_position' => array('label' => __('Background Position', STM_POST_TYPE), 'type' => 'text'), 'page_bg_repeat' => array('label' => __('Background Repeat', STM_POST_TYPE), 'type' => 'select', 'options' => array('repeat' => __('Repeat', STM_POST_TYPE), 'no-repeat' => __('No Repeat', STM_POST_TYPE), 'repeat-x' => __('Repeat-X', STM_POST_TYPE), 'repeat-y' => __('Repeat-Y', STM_POST_TYPE))), 'separator_title_box' => array('label' => __('Title Box', STM_POST_TYPE), 'type' => 'separator'), 'title' => array('label' => __('Title', STM_POST_TYPE), 'type' => 'select', 'options' => array('show' => __('Show', STM_POST_TYPE), 'hide' => __('Hide', STM_POST_TYPE))), 'sub_title' => array('label' => __('Sub Title', STM_POST_TYPE), 'type' => 'text'), 'title_box_bg_color' => array('label' => __('Background Color', STM_POST_TYPE), 'type' => 'color_picker'), 'title_box_font_color' => array('label' => __('Font Color', STM_POST_TYPE), 'type' => 'color_picker'), 'title_box_line_color' => array('label' => __('Line Color', STM_POST_TYPE), 'type' => 'color_picker'), 'title_box_subtitle_font_color' => array('label' => __('Sub Title Font Color', STM_POST_TYPE), 'type' => 'color_picker'), 'title_box_custom_bg_image' => array('label' => __('Custom Background Image', STM_POST_TYPE), 'type' => 'image'), 'title_box_bg_position' => array('label' => __('Background Position', STM_POST_TYPE), 'type' => 'text'), 'title_box_bg_repeat' => array('label' => __('Background Repeat', STM_POST_TYPE), 'type' => 'select', 'options' => array('repeat' => __('Repeat', STM_POST_TYPE), 'no-repeat' => __('No Repeat', STM_POST_TYPE), 'repeat-x' => __('Repeat-X', STM_POST_TYPE), 'repeat-y' => __('Repeat-Y', STM_POST_TYPE))), 'title_box_overlay' => array('label' => __('Overlay', STM_POST_TYPE), 'type' => 'checkbox'), 'title_box_small' => array('label' => __('Small', STM_POST_TYPE), 'type' => 'checkbox'), 'separator_breadcrumbs' => array('label' => __('Breadcrumbs', STM_POST_TYPE), 'type' => 'separator'), 'breadcrumbs' => array('label' => __('Breadcrumbs', STM_POST_TYPE), 'type' => 'select', 'options' => array('show' => __('Show', STM_POST_TYPE), 'hide' => __('Hide', STM_POST_TYPE))), 'breadcrumbs_font_color' => array('label' => __('Breadcrumbs Color', STM_POST_TYPE), 'type' => 'color_picker'), 'separator_title_box_button' => array('label' => __('Title Box Button', STM_POST_TYPE), 'type' => 'separator'), 'title_box_button_text' => array('label' => __('Button Text', STM_POST_TYPE), 'type' => 'text'), 'title_box_button_url' => array('label' => __('Button URL', STM_POST_TYPE), 'type' => 'text'), 'title_box_button_border_color' => array('label' => __('Border Color', STM_POST_TYPE), 'type' => 'color_picker', 'default' => '#ffffff'), 'title_box_button_font_color' => array('label' => __('Font Color', STM_POST_TYPE), 'type' => 'color_picker', 'default' => '#333333'), 'title_box_button_font_color_hover' => array('label' => __('Font Color (hover)', STM_POST_TYPE), 'type' => 'color_picker', 'default' => '#333333'), 'title_box_button_font_arrow_color' => array('label' => __('Arrow Color', STM_POST_TYPE), 'type' => 'color_picker', 'default' => '#ffffff'), 'prev_next_buttons_title_box' => array('label' => __('Prev/Next Buttons', STM_POST_TYPE), 'type' => 'separator'), 'prev_next_buttons' => array('label' => __('Enable', STM_POST_TYPE), 'type' => 'checkbox'), 'prev_next_buttons_border_color' => array('label' => __('Border Color', STM_POST_TYPE), 'type' => 'color_picker', 'default' => '#ffffff'), 'prev_next_buttons_arrow_color_hover' => array('label' => __('Arrow Color (hover)', STM_POST_TYPE), 'type' => 'color_picker', 'default' => '#dac725'))));
STM_PostType::addMetaBox('testimonial_info', __('Testimonial Info', STM_POST_TYPE), array('testimonial'), '', '', '', array('fields' => array('testimonial_company' => array('label' => __('Company', STM_POST_TYPE), 'type' => 'text'), 'testimonial_profession' => array('label' => __('Profession', STM_POST_TYPE), 'type' => 'text'))));
function stm_plugin_styles()
{
    $plugin_url = plugins_url('', __FILE__);
    wp_enqueue_style('admin-styles', $plugin_url . '/assets/css/admin.css', null, null, 'all');
    wp_enqueue_style('wp-color-picker');
    wp_enqueue_script('wp-color-picker');
    wp_enqueue_style('stmcss-datetimepicker', $plugin_url . '/assets/css/jquery.stmdatetimepicker.css', null, null, 'all');
    wp_enqueue_script('stmjs-datetimepicker', $plugin_url . '/assets/js/jquery.stmdatetimepicker.js', array('jquery'), null, true);
    wp_enqueue_media();
}