예제 #1
0
/**
 * Define the data to be displayed in each of the custom columns for the Addon post types
 *
 * @since	1.4
 * @param	str		$column_name	The name of the column to display
 * @param	int		$post_id		The current post ID
 * @return
 */
function mdjm_addon_posts_custom_column($column_name, $post_id)
{
    global $post;
    switch ($column_name) {
        // Category
        case 'addon_category':
            echo get_the_term_list($post_id, 'addon-category', '', ', ', '');
            break;
            // Availability
        // Availability
        case 'availability':
            $output = array();
            if (!mdjm_addon_is_restricted_by_date($post_id)) {
                $output[] = __('Always', 'mobile-dj-manager');
            } else {
                $availability = mdjm_get_addon_months_available($post_id);
                if (!$availability) {
                    $output[] = __('Always', 'mobile-dj-manager');
                } else {
                    $i = 0;
                    foreach ($availability as $month) {
                        $output[] = mdjm_month_num_to_name($availability[$i]);
                        $i++;
                    }
                }
            }
            echo implode(', ', $output);
            break;
            // Event Types
        // Event Types
        case 'event_types':
            $output = array();
            $event_label = mdjm_get_label_singular();
            $event_types = mdjm_get_addon_event_types($post_id);
            if (in_array('all', $event_types)) {
                $output[] = sprintf(__('All %s Types', 'mobile-dj-manager'), $event_label);
            } else {
                foreach ($event_types as $event_type) {
                    $term = get_term($event_type, 'event-types');
                    if (!empty($term)) {
                        $output[] = $term->name;
                    }
                }
            }
            echo implode(', ', $output);
            break;
            // Employees
        // Employees
        case 'employees':
            $employees = mdjm_get_employees_with_addon($post_id);
            $output = array();
            if (in_array('all', $employees)) {
                $output[] = __('All Employees', 'mobile-dj-manager');
            } else {
                foreach ($employees as $employee) {
                    if ('all' == $employee) {
                        continue;
                    }
                    $output[] = '<a href="' . get_edit_user_link($employee) . '">' . mdjm_get_employee_display_name($employee) . '</a>';
                }
            }
            echo implode('<br />', $output);
            break;
            // Price
        // Price
        case 'price':
            if (mdjm_addon_has_variable_prices($post_id)) {
                $range = mdjm_get_addon_price_range($post_id);
                echo mdjm_currency_filter(mdjm_format_amount($range['low']));
                echo ' &mdash; ';
                echo mdjm_currency_filter(mdjm_format_amount($range['high']));
            } else {
                echo mdjm_currency_filter(mdjm_format_amount(mdjm_get_addon_price($post_id)));
            }
            break;
            // Usage
        // Usage
        case 'usage':
            $packages = mdjm_count_packages_with_addon($post_id);
            $events = mdjm_count_events_with_addon($post_id);
            echo $packages . _n(' Package', ' Packages', $packages, 'mobile-dj-manager') . '<br />';
            echo $events . ' ' . _n(mdjm_get_label_singular(), mdjm_get_label_plural(), $events, 'mobile-dj-manager');
            break;
    }
    // switch
}
/**
 * Whether or not an addon is available for the event date.
 *
 * @since	1.4
 * @param	int		$addon_id		The addon ID.
 * @param	str		$event_date		The event date.
 * @return	bool	True if the addon is available for the event date, or false if not.
 */
function mdjm_addon_is_available_for_event_date($addon_id, $event_date = '')
{
    if (empty($event_date)) {
        return true;
    }
    if (!mdjm_addon_is_restricted_by_date($addon_id)) {
        return true;
    }
    $event_months = mdjm_get_addon_months_available($addon_id);
    $event_month = date('n', strtotime($event_date));
    if (in_array($event_month, $event_months)) {
        return true;
    }
    return false;
}
예제 #3
0
/**
 * Output the addon availability availability period row
 *
 * @since	1.4
 * @param	int		$post		The WP_Post object.
 * @return	str
 */
function mdjm_addon_metabox_availability_period_row($post)
{
    $restricted = mdjm_addon_is_restricted_by_date($post->ID);
    $class = $restricted ? '' : ' class="mdjm-hidden"';
    ?>
    <div class="mdjm_field_wrap mdjm_form_fields">
        <div id="addon-date-restrict">
        	 <p><?php 
    echo MDJM()->html->checkbox(array('name' => '_addon_restrict_date', 'current' => $restricted));
    ?>
            <label for="_addon_restrict_date"><?php 
    _e('Select if this add-on is only available during certain months of the year', 'mobile-dj-manager');
    ?>
</label></p>
        </div>
        
        <div id="mdjm-addon-month-selection"<?php 
    echo $class;
    ?>
>
        	 <p><label for="_addon_months"><?php 
    _e('Select the months this add-on is available', 'mobile-dj-manager');
    ?>
</label><br />
                <?php 
    echo MDJM()->html->month_dropdown(array('name' => '_addon_months', 'selected' => mdjm_get_addon_months_available($post->ID), 'fullname' => true, 'multiple' => true, 'chosen' => true, 'placeholder' => __('Select Months', 'mobile-dj-manager')));
    ?>
</p>
        </div>
    </div>

    <?php 
}