/**
 * Campaign Configuration
 *
 * Hook into EDD Download Information and add a bit more stuff.
 * These are all things that can be updated while the campaign runs/before
 * being published.
 *
 * @since Astoundify Crowdfunding 0.1-alpha
 *
 * @return void
 */
function _atcf_metabox_campaign_info()
{
    global $post, $edd_options, $wp_locale;
    /** Verification Field */
    wp_nonce_field('cf', 'cf-save');
    $campaign = atcf_get_campaign($post);
    $end_date = $campaign->end_date();
    if (!$end_date && !$campaign->is_endless()) {
        $min = isset($edd_options['atcf_campaign_length_min']) ? $edd_options['atcf_campaign_length_min'] : 14;
        $max = isset($edd_options['atcf_campaign_length_max']) ? $edd_options['atcf_campaign_length_max'] : 48;
        $start = apply_filters('atcf_shortcode_submit_field_length_start', round(($min + $max) / 2));
        $end_date = date('Y-m-d h:i:s', time() + $start * 86400);
    }
    $jj = mysql2date('d', $end_date);
    $mm = mysql2date('m', $end_date);
    $aa = mysql2date('Y', $end_date);
    $hh = mysql2date('H', $end_date);
    $mn = mysql2date('i', $end_date);
    $ss = mysql2date('s', $end_date);
    do_action('atcf_metabox_campaign_info_before', $campaign);
    $types = atcf_campaign_types();
    ?>
	<p>
		<label for="_campaign_featured">
			<input type="checkbox" name="_campaign_featured" id="_campaign_featured" value="1" <?php 
    checked(1, $campaign->featured());
    ?>
 />
			<?php 
    _e('Featured campaign', 'atcf');
    ?>
		</label>
	</p>

	<p>
		<label for="_campaign_physical">
			<input type="checkbox" name="_campaign_physical" id="_campaign_physical" value="1" <?php 
    checked(1, $campaign->needs_shipping());
    ?>
 />
			<?php 
    _e('Collect shipping information on checkout', 'atcf');
    ?>
		</label>
	</p>

	<p>
		<strong><?php 
    _e('Funding Type:', 'atcf');
    ?>
</strong>
	</p>

	<p>
		<?php 
    foreach (atcf_campaign_types_active() as $key => $desc) {
        ?>
		<label for="campaign_type[<?php 
        echo esc_attr($key);
        ?>
]"><input type="radio" name="campaign_type" id="campaign_type[<?php 
        echo esc_attr($key);
        ?>
]" value="<?php 
        echo esc_attr($key);
        ?>
" <?php 
        checked($key, $campaign->type());
        ?>
 /> <strong><?php 
        echo $types[$key]['title'];
        ?>
</strong> &mdash; <?php 
        echo $types[$key]['description'];
        ?>
</label><br />
		<?php 
    }
    ?>
	</p>

	<p>
		<?php 
    $goal_args = array('name' => 'campaign_goal', 'value' => esc_attr(edd_format_amount(edd_sanitize_amount($campaign->goal(false)))), 'class' => 'edd-price-field');
    if ('before' == edd_get_option('currency_position', 'before')) {
        echo edd_currency_filter('');
        echo EDD()->html->text($goal_args);
    } else {
        echo EDD()->html->text($goal_args);
        echo edd_currency_filter('');
    }
    ?>
	</p>
	<p>
		<label for="campaign_location"><strong><?php 
    _e('Location:', 'atcf');
    ?>
</strong></label><br />
		<input type="text" name="campaign_location" id="campaign_location" value="<?php 
    echo esc_attr($campaign->location());
    ?>
" class="regular-text" />
	</p>

	<p>
		<label for="campaign_author"><strong><?php 
    _e('Author:', 'atcf');
    ?>
</strong></label><br />
		<input type="text" name="campaign_author" id="campaign_author" value="<?php 
    echo esc_attr($campaign->author());
    ?>
" class="regular-text" />
	</p>

	<p>
		<label for="campaign_email"><strong><?php 
    _e('Contact Email:', 'atcf');
    ?>
</strong></label><br />
		<input type="text" name="campaign_contact_email" id="campaign_contact_email" value="<?php 
    echo esc_attr($campaign->contact_email());
    ?>
" class="regular-text" />
	</p>

	<style>#end-aa { width: 3.4em } #end-jj, #end-hh, #end-mn { width: 2em; }</style>

	<p>
		<strong><?php 
    _e('End Date:', 'atcf');
    ?>
</strong><br />

		<select id="end-mm" name="end-mm">
			<?php 
    for ($i = 1; $i < 13; $i = $i + 1) {
        $monthnum = zeroise($i, 2);
        ?>
				<option value="<?php 
        echo $monthnum;
        ?>
" <?php 
        selected($monthnum, $mm);
        ?>
>
				<?php 
        printf('%1$s-%2$s', $monthnum, $wp_locale->get_month_abbrev($wp_locale->get_month($i)));
        ?>
				</option>
			<?php 
    }
    ?>
		</select>

		<input type="text" id="end-jj" name="end-jj" value="<?php 
    echo esc_attr($jj);
    ?>
" size="2" maxlength="2" autocomplete="off" />,
		<input type="text" id="end-aa" name="end-aa" value="<?php 
    echo esc_attr($aa);
    ?>
" size="4" maxlength="4" autocomplete="off" /> @
		<input type="text" id="end-hh" name="end-hh" value="<?php 
    echo esc_attr($hh);
    ?>
" size="2" maxlength="2" autocomplete="off" /> :
		<input type="text" id="end-mn" name="end-mn" value="<?php 
    echo esc_attr($mn);
    ?>
" size="2" maxlength="2" autocomplete="off" />
		<input type="hidden" id="end-ss" name="end-ss" value="<?php 
    echo esc_attr($ss);
    ?>
" />
		<input type="hidden" id="campaign_end_date" name="campaign_end_date" value="1" />
	</p>

	<p>
		<label for="campaign_endless">
			<input type="checkbox" name="campaign_endless" id="campaign_endless" value="1" <?php 
    checked(1, $campaign->is_endless());
    ?>
> <?php 
    printf(__('This %s never ends', 'atcf'), strtolower(edd_get_label_singular()));
    ?>
		</label>
	</p>
<?php 
    do_action('atcf_metabox_campaign_info_after', $campaign);
}
示例#2
0
function wpo_field_submit()
{
    global $edd_options;
    $min = isset($edd_options['atcf_campaign_length_min']) ? $edd_options['atcf_campaign_length_min'] : 14;
    $max = isset($edd_options['atcf_campaign_length_max']) ? $edd_options['atcf_campaign_length_max'] : 48;
    return array('campaign_heading' => array('label' => __('Campaign Information', TEXTDOMAIN), 'type' => 'heading', 'default' => null, 'editable' => true, 'priority' => 2), 'title' => array('label' => __('Title', TEXTDOMAIN), 'default' => null, 'type' => 'text', 'editable' => false, 'placeholder' => null, 'required' => true, 'priority' => 4), 'goal' => array('label' => sprintf(__('Goal (%s)', TEXTDOMAIN), edd_currency_filter('')), 'default' => null, 'type' => 'text', 'editable' => false, 'placeholder' => edd_format_amount(800), 'required' => true, 'priority' => 6), 'length' => array('label' => __('Length', TEXTDOMAIN), 'default' => floor(($min + $max) / 2), 'type' => 'number', 'editable' => false, 'placeholder' => null, 'min' => $min, 'max' => $max, 'step' => 1, 'priority' => 8), 'type' => array('label' => __('Funding Type', TEXTDOMAIN), 'default' => atcf_campaign_type_default(), 'type' => 'radio', 'options' => atcf_campaign_types_active(), 'editable' => false, 'placeholder' => null, 'required' => true, 'priority' => 10), 'category' => array('label' => __('Categories', TEXTDOMAIN), 'default' => null, 'type' => 'term_checklist', 'editable' => true, 'placeholder' => null, 'priority' => 12), 'tag' => array('label' => __('Tags', TEXTDOMAIN), 'default' => null, 'type' => 'term_checklist', 'editable' => true, 'placeholder' => null, 'priority' => 14), 'image' => array('label' => __('Featured Image', TEXTDOMAIN), 'default' => null, 'type' => 'featured_image', 'editable' => true, 'placeholder' => null, 'priority' => 16), 'video' => array('label' => __('Featured Video URL', TEXTDOMAIN), 'default' => null, 'type' => 'text', 'editable' => true, 'placeholder' => null, 'priority' => 18), 'description' => array('label' => __('Description', TEXTDOMAIN), 'default' => null, 'type' => 'wp_editor', 'editable' => true, 'placeholder' => null, 'required' => true, 'priority' => 20), 'updates' => array('label' => __('Updates', TEXTDOMAIN), 'default' => null, 'type' => 'wp_editor', 'editable' => 'only', 'placeholder' => null, 'priority' => 22), 'excerpt' => array('label' => __('Excerpt', TEXTDOMAIN), 'default' => null, 'type' => 'textarea', 'editable' => true, 'placeholder' => null, 'priority' => 24), 'backer_rewards_heading' => array('label' => __('Backer Rewards', TEXTDOMAIN), 'type' => 'heading', 'default' => null, 'editable' => true, 'priority' => 26), 'physical' => array('label' => __('Collect shipping information on checkout.', TEXTDOMAIN), 'default' => null, 'type' => 'checkbox', 'editable' => true, 'placeholder' => null, 'priority' => 28), 'norewards' => array('label' => __('No rewards, donations only.', TEXTDOMAIN), 'default' => null, 'type' => 'checkbox', 'editable' => false, 'placeholder' => null, 'priority' => 30), 'rewards' => array('label' => null, 'type' => 'rewards', 'required' => false, 'default' => null, 'editable' => true, 'priority' => 32), 'info_heading' => array('label' => __('Your Information', TEXTDOMAIN), 'type' => 'heading', 'default' => null, 'editable' => true, 'priority' => 34), 'contact_email' => array('label' => __('Contact Email', TEXTDOMAIN), 'default' => null, 'type' => 'text', 'editable' => true, 'placeholder' => null, 'required' => true, 'priority' => 36), 'organization' => array('label' => __('Name/Organization', TEXTDOMAIN), 'default' => null, 'type' => 'text', 'editable' => true, 'placeholder' => null, 'priority' => 38), 'location' => array('label' => __('Location', TEXTDOMAIN), 'default' => null, 'type' => 'text', 'editable' => true, 'placeholder' => null, 'priority' => 40));
}