/**
         * My History Content
         * @since 0.1
         * @version 1.2
         */
        public function my_history_screen()
        {
            global $bp;
            $mycred_types = mycred_get_types();
            $type = 'mycred_default';
            if (isset($_REQUEST['show-ctype']) && array_key_exists($_REQUEST['show-ctype'], $mycred_types)) {
                $type = $_REQUEST['show-ctype'];
            }
            $args = array('user_id' => bp_displayed_user_id(), 'number' => apply_filters('mycred_bp_history_num_to_show', $this->buddypress['history_num']), 'ctype' => $type);
            if (isset($_GET['paged']) && $_GET['paged'] != '') {
                $args['paged'] = $_GET['paged'];
            }
            if (isset($bp->canonical_stack['action']) && $bp->canonical_stack['action'] != $this->buddypress['history_url']) {
                $args['time'] = $bp->canonical_stack['action'];
            }
            $log = new myCRED_Query_Log($args);
            unset($log->headers['column-username']);
            ob_start();
            if (count($mycred_types) > 1) {
                ?>
<form action="" id="mycred-sort-cred-history-form" method="get" style="display: block; height: 48px; float: right;"><label>Show:</label> <?php 
                mycred_types_select_from_dropdown('show-ctype', 'mycred-select-type', $type);
                ?>
 <input type="submit" class="btn btn-large btn-primary button button-large button-primary" value="<?php 
                _e('Go', 'mycred');
                ?>
" /></form>
<?php 
            }
            ?>
<style type="text/css">
.pagination-links { float: right; }
.tablenav { vertical-align: middle; }
</style>
<div class="wrap" id="myCRED-wrap">

	<?php 
            $log->mobile_support();
            ?>

	<form method="get" action="">
		<div class="tablenav top clear clearfix">

			<?php 
            if ($log->have_entries() && $log->max_num_pages > 1) {
                $log->navigation('top');
            }
            ?>

		</div>

		<?php 
            $log->display();
            ?>

		<div class="tablenav bottom clear clearfix">

			<?php 
            if ($log->have_entries() && $log->max_num_pages > 1) {
                $log->navigation('bottom');
            }
            ?>

		</div>

	</form>
</div>
<?php 
            $log->reset_query();
            $output = ob_get_contents();
            ob_end_clean();
            echo apply_filters('mycred_bp_history_page', $output, $this);
        }
Example #2
0
        /**
         * Gateway Settings
         * Included first when the gateway is activated.
         * @since 1.2
         * @version 1.2
         */
        public function gateway_settings()
        {
            global $org_options;
            $exchange_message = sprintf(__('How many %s is 1 %s worth?', 'mycred'), $this->core->plural(), $org_options['currency_symbol']);
            $mycred_types = mycred_get_types();
            ?>

<?php 
            if ($this->update) {
                ?>
<h2 style="color: green;"><?php 
                _e('Gateways Settings Successfully Updated', 'mycred');
                ?>
</h2>
<?php 
            }
            ?>
<form method="post" action="<?php 
            echo $_SERVER['REQUEST_URI'];
            ?>
#mycred-gate">
	<?php 
            do_action('mycred_espresso_before_prefs');
            ?>

	<table width="99%" border="0" cellspacing="5" cellpadding="5">
		<tr>
			<td valign="top">
				<h4><?php 
            _e('Labels', 'mycred');
            ?>
</h4>
				<ul>
					<li>
						<label for="mycred-prefs-gateway-labels"><?php 
            _e('Gateway Title', 'mycred');
            ?>
</label>
						<input type="text" name="mycred_prefs[labels][gateway]" id="mycred-prefs-gateway-labels" size="30" value="<?php 
            echo $this->prefs['labels']['gateway'];
            ?>
" /><br />
						<span class="description"><?php 
            _e('Title to show on Payment page', 'mycred');
            ?>
.</span>
					</li>
					<li>
						<label for="mycred-prefs-payment-labels"><?php 
            _e('Payment Type', 'mycred');
            ?>
</label>
						<input type="text" name="mycred_prefs[labels][payment]" id="mycred-prefs-payment-labels" size="30" value="<?php 
            echo $this->prefs['labels']['payment'];
            ?>
" /><br />
						<span class="description"><?php 
            _e('Title to show on receipts and logs', 'mycred');
            ?>
.</span>
					</li>
					<li>
						<label for="mycred-prefs-button-labels"><?php 
            _e('Button Label', 'mycred');
            ?>
</label>
						<input type="text" name="mycred_prefs[labels][button]" id="mycred-prefs-button-labels" size="30" value="<?php 
            echo $this->prefs['labels']['button'];
            ?>
" /><br />
						<span class="description"><?php 
            _e('Pay Button', 'mycred');
            ?>
</span>
					</li>
				</ul>
				<?php 
            if (count($mycred_types) > 1) {
                ?>

				<ul>
					<li>
						<label for="mycred-prefs-payment-type"><?php 
                _e('Point Type', 'mycred');
                ?>
</label>
						<?php 
                mycred_types_select_from_dropdown('mycred_prefs[type]', 'mycred-prefs-payment-type', $this->prefs['type']);
                ?>

					</li>
				</ul>
				<?php 
            } else {
                ?>

				<input type="hidden" name="mycred_prefs[type]" id="mycred-prefs-payment-type" value="mycred_default" />
				<?php 
            }
            ?>

				<h4><?php 
            _e('Price', 'mycred');
            ?>
</h4>
				<ul>
					<li id="mycred-event-exchange-box">
						<label for="mycred-prefs-price-x-rate"><?php 
            _e('Exchange Rate', 'mycred');
            ?>
</label>
						<input type="text" name="mycred_prefs[rate]" id="mycred-prefs-price-x-rate" size="30" value="<?php 
            echo $this->prefs['rate'];
            ?>
" /><br />
						<span class="description"><?php 
            echo $exchange_message;
            ?>
</span>
					</li>
					<li>
						<p><strong><?php 
            _e('Important!', 'mycred');
            ?>
</strong></p>
						<ol>
							<li><?php 
            _e('You can disable purchases using this gateway by adding a custom Event Meta: <code>mycred_no_sale</code>', 'mycred');
            ?>
</li>
							<li><?php 
            _e('Users must be logged in to use this gateway!', 'mycred');
            ?>
</li>
						</ol>
					</li>
					<li id="mycred-event-profit-sharing">
						<label for="mycred-prefs-profit-share"><?php 
            _e('Profit Sharing', 'mycred');
            ?>
</label>
						<input type="text" name="mycred_prefs[share]" id="mycred-prefs-profit-share" size="5" value="<?php 
            echo $this->prefs['share'];
            ?>
" /> %<br />
						<span class="description"><?php 
            _e('Option to share sales with the product owner. Use zero to disable.', 'mycred');
            ?>
</span>
					</li>
				</ul>
				<h4><?php 
            _e('Log', 'mycred');
            ?>
</h4>
				<ul>
					<li>
						<label for="mycred-prefs-log"><?php 
            _e('Log Entry', 'mycred');
            ?>
</label>
						<input type="text" name="mycred_prefs[log]" id="mycred-prefs-log" size="30" value="<?php 
            echo $this->prefs['log'];
            ?>
" /><br />
						<span class="description"><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
					</li>
				</ul>
			</td>
			<td valign="top">
				<h4><?php 
            _e('Templates', 'mycred');
            ?>
</h4>
				<ul>
					<li>
						<label for="mycred-prefs-message-solvent"><?php 
            _e('Solvent users', 'mycred');
            ?>
</label>
						<textarea name="mycred_prefs[messages][solvent]" id="mycred-prefs-message-solvent" style="width: 90%; max-width: 90%; min-height: 90px;"><?php 
            echo stripslashes($this->prefs['messages']['solvent']);
            ?>
</textarea><br />
						<span class="description"><?php 
            _e('Message to show users on the payment page before they are charged. Leave empty to hide.', 'mycred');
            ?>
<br /><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
					</li>
					<li>
						<label for="mycred-prefs-message-insolvent"><?php 
            _e('Insolvent users', 'mycred');
            ?>
</label>
						<textarea name="mycred_prefs[messages][insolvent]" id="mycred-prefs-message-solvent" style="width: 90%; max-width: 90%; min-height: 90px;"><?php 
            echo stripslashes($this->prefs['messages']['insolvent']);
            ?>
</textarea><br />
						<span class="description"><?php 
            _e('Message to show users who do not have enough points to pay.', 'mycred');
            ?>
<br /><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
					</li>
					<li>
						<label for="mycred-prefs-message-insolvent"><?php 
            _e('Visitors', 'mycred');
            ?>
</label>
						<textarea name="mycred_prefs[messages][visitors]" id="mycred-prefs-message-visitors" style="width: 90%; max-width: 90%; min-height: 90px;"><?php 
            echo stripslashes($this->prefs['messages']['visitors']);
            ?>
</textarea><br />
						<span class="description"><?php 
            _e('Message to show visitors (users not logged in) on the payment page.', 'mycred');
            ?>
<br /><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
					</li>
				</ul>
			</td>
		</tr>
	</table>
	<?php 
            do_action('mycred_espresso_after_prefs');
            ?>

	<input type="hidden" name="mycred-gateway-action" value="update-settings" />
	<input type="hidden" name="mycred-gateway-token" value="<?php 
            echo wp_create_nonce('mycred-espresso-update');
            ?>
" />
	<p><input class="button-primary" type="submit" name="Submit" value="<?php 
            _e('Update Settings', 'mycred');
            ?>
" /></p>
</form>
<?php 
        }
        /**
         * Getway Settings
         * @since 1.3
         * @version 1.3
         */
        function mysettings()
        {
            global $page, $action;
            $gateway_link = admin_url('edit.php?post_type=' . EM_POST_TYPE_EVENT . '&page=events-manager-options#bookings');
            if ($this->prefs['setup'] == 'multi') {
                $box = 'display: block;';
            } else {
                $box = 'display: none;';
            }
            $exchange_message = sprintf(__('How many %s is 1 %s worth?', 'mycred'), $this->core->plural(), em_get_currency_symbol());
            $mycred_types = mycred_get_types();
            do_action('mycred_em_before_settings', $this);
            ?>

<h4><?php 
            _e('Setup', 'mycred');
            ?>
</h4>
<table class="form-table">
	<?php 
            if (count($mycred_types) > 1) {
                ?>

	<tr>
		<th scope="row"><?php 
                _e('Point Type', 'mycred');
                ?>
</th>
		<td>
			<?php 
                mycred_types_select_from_dropdown('mycred_gateway[type]', 'mycred-gateway-type', $this->prefs['type']);
                ?>

		</td>
	</tr>
	<?php 
            } else {
                ?>

	<input type="hidden" name="mycred_gateway[type]" value="mycred_default" />
	<?php 
            }
            ?>

	<tr>
		<th scope="row"><?php 
            _e('Payments', 'mycred');
            ?>
</th>
		<td>
			<input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-off" value="off"<?php 
            checked($this->prefs['setup'], 'off');
            ?>
 /> <label for="mycred-gateway-setup-off"><?php 
            echo $this->core->template_tags_general(__('Disabled - Users CAN NOT pay for tickets using %plural%.', 'mycred'));
            ?>
</label><br />
			<input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-single" value="single"<?php 
            checked($this->prefs['setup'], 'single');
            ?>
 /> <label for="mycred-gateway-setup-single"><?php 
            echo $this->core->template_tags_general(__('Single - Users can ONLY pay for tickets using %plural%.', 'mycred'));
            ?>
</label><br />
			<input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-multi" value="multi"<?php 
            checked($this->prefs['setup'], 'multi');
            ?>
 /> <label for="mycred-gateway-setup-multi"><?php 
            echo $this->core->template_tags_general(__('Multi - Users can pay for tickets using other gateways or %plural%.', 'mycred'));
            ?>
</label>
		</td>
	</tr>
	<tr>
		<th scope="row"><?php 
            _e('Refunds', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[refund]" type="text" id="mycred-gateway-log-refund" value="<?php 
            echo $this->prefs['refund'];
            ?>
" size="5" /> %<br />
			<span class="description"><?php 
            _e('The percentage of the paid amount to refund if a user cancels their booking. Use zero for no refunds. No refunds are given to "Rejected" bookings!', 'mycred');
            ?>
</span>
		</td>
	</tr>
	<tr>
		<th scope="row"><?php 
            _e('Profit Sharing', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[share]" type="text" id="mycred-gateway-profit-sharing" value="<?php 
            echo $this->prefs['share'];
            ?>
" size="5" /> %<br />
			<span class="description"><?php 
            _e('Option to share sales with the product owner. Use zero to disable.', 'mycred');
            ?>
</span>
		</td>
	</tr>
</table>
<table class="form-table" id="mycred-exchange-rate" style="<?php 
            echo $box;
            ?>
">
	<tr>
		<th scope="row"><?php 
            _e('Exchange Rate', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[rate]" type="text" id="mycred-gateway-rate" size="6" value="<?php 
            echo $this->prefs['rate'];
            ?>
" /><br />
			<span class="description"><?php 
            echo $exchange_message;
            ?>
</span>
		</td>
	</tr>
</table>
<h4><?php 
            _e('Log Templates', 'mycred');
            ?>
</h4>
<table class="form-table">
	<tr>
		<th scope="row"><?php 
            _e('Purchases', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[log][purchase]" type="text" id="mycred-gateway-log-purchase" style="width: 95%;" value="<?php 
            echo $this->prefs['log']['purchase'];
            ?>
" size="45" /><br />
			<span class="description"><?php 
            echo $this->core->available_template_tags(array('general', 'post'));
            ?>
></span>
		</td>
	</tr>
	<tr>
		<th scope="row"><?php 
            _e('Refunds', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[log][refund]" type="text" id="mycred-gateway-log-refund" style="width: 95%;" value="<?php 
            echo $this->prefs['log']['refund'];
            ?>
" size="45" /><br />
			<span class="description"><?php 
            echo $this->core->available_template_tags(array('general', 'post'));
            ?>
</span>
		</td>
	</tr>
</table>
<script type="text/javascript">
jQuery(function($){
	$('input[name="mycred_gateway[setup]"]').change(function(){
		if ( $(this).val() == 'multi' ) {
			$('#mycred-exchange-rate').show();
		}
		else {
			$('#mycred-exchange-rate').hide();
		}
	});
});
</script>
<h4><?php 
            _e('Labels', 'mycred');
            ?>
</h4>
<table class="form-table">
	<tr valign="top">
		<th scope="row"><?php 
            _e('Payment Link Label', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[labels][link]" type="text" id="mycred-gateway-labels-link" style="width: 95%" value="<?php 
            echo $this->prefs['labels']['link'];
            ?>
" size="45" /><br />
			<span class="description"><?php 
            _e('The payment link shows / hides the payment form under "My Bookings". No HTML allowed.', 'mycred');
            ?>
</span>
		</td>
	</tr>
	<tr valign="top">
		<th scope="row"><?php 
            _e('Payment Header', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[labels][header]" type="text" id="mycred-gateway-labels-header" style="width: 95%" value="<?php 
            echo $this->prefs['labels']['header'];
            ?>
" size="45" /><br />
			<span class="description"><?php 
            _e('Shown on top of the payment form. No HTML allowed.', 'mycred');
            ?>
</span>
		</td>
	</tr>
	<tr valign="top">
		<th scope="row"><?php 
            _e('Button Label', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[labels][button]" type="text" id="mycred-gateway-labels-button" style="width: 95%" value="<?php 
            echo $this->prefs['labels']['button'];
            ?>
" size="45" /><br />
			<span class="description"><?php 
            _e('The button label for payments. No HTML allowed!', 'mycred');
            ?>
</span>
		</td>
	</tr>
	<tr valign="top">
		<th scope="row"><?php 
            _e('Cart & Checkout Cost', 'mycred');
            ?>
</th>
		<td>
			<input name="mycred_gateway[labels][checkout]" type="text" id="mycred-gateway-labels-button" style="width: 95%" value="<?php 
            echo $this->prefs['labels']['checkout'];
            ?>
" size="45" /><br />
			<span class="description"><?php 
            echo $this->core->template_tags_general(__('Label for cost in %plural%', 'mycred'));
            ?>
</span><br /><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
		</td>
	</tr>
</table>
<h4><?php 
            _e('Messages', 'mycred');
            ?>
</h4>
<table class='form-table'>
	<tr valign="top">
		<th scope="row"><?php 
            _e('Successful Payments', 'mycred');
            ?>
</th>
		<td>
			<input type="text" name="mycred_gateway[messages][success]" id="mycred-gateway-messages-success" style="width: 95%;" value="<?php 
            echo stripslashes($this->prefs['messages']['success']);
            ?>
" /><br />
			<span class="description"><?php 
            _e('No HTML allowed!', 'mycred');
            ?>
<br /><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
		</td>
	</tr>
	<tr valign="top">
		<th scope="row"><?php 
            _e('Insufficient Funds', 'mycred');
            ?>
</th>
		<td>
			<input type="text" name="mycred_gateway[messages][error]" id="mycred-gateway-messages-error" style="width: 95%;" value="<?php 
            echo stripslashes($this->prefs['messages']['error']);
            ?>
" /><br />
			<span class="description"><?php 
            _e('No HTML allowed!', 'mycred');
            ?>
<br /><?php 
            echo $this->core->available_template_tags(array('general'));
            ?>
</span>
		</td>
	</tr>
</table>
<?php 
            do_action('mycred_em_after_settings', $this);
        }
        /**
         * Settings Page
         * @since 0.1
         * @version 1.3
         */
        public function after_general_settings($mycred)
        {
            $sell_content = $this->sell_content;
            if (!isset($sell_content['defaults']['expire'])) {
                $sell_content['defaults']['expire'] = 0;
            }
            $before = $this->core->before;
            $after = $this->core->after;
            $payees = array('none' => __('No Payout. Just charge.'), 'author' => __('Pay Content Author.'));
            $available_payees = apply_filters('mycred_sell_content_payees', $payees, $sell_content);
            ?>

<h4><div class="icon icon-active"></div><?php 
            _e('Sell Content', 'mycred');
            ?>
</h4>
<div class="body" style="display:none;">
	<label class="subheader" for="<?php 
            echo $this->field_id('post_types');
            ?>
"><?php 
            _e('Post Types', 'mycred');
            ?>
</label>
	<ol id="myCRED-buy-postypes">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('post_types');
            ?>
" id="<?php 
            echo $this->field_id('post_types');
            ?>
" value="<?php 
            echo $sell_content['post_types'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Comma separated list of post types that can be sold.', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<?php 
            if (count($this->point_types) > 1) {
                ?>
	<label class="subheader" for="<?php 
                echo $this->field_id('type');
                ?>
"><?php 
                _e('Point Type', 'mycred');
                ?>
</label>
	<ol id="myCRED-buy-point-type">
		<li>
			<?php 
                mycred_types_select_from_dropdown($this->field_name('type'), $this->field_name('type'), $sell_content['type']);
                ?>

		</li>
	</ol>
	<?php 
            } else {
                ?>

	<input type="hidden" name="<?php 
                echo $this->field_name('type');
                ?>
" id="<?php 
                echo $this->field_name('type');
                ?>
" value="mycred_default" />
	<?php 
            }
            ?>

	<label class="subheader"><?php 
            _e('Payments', 'mycred');
            ?>
</label>
	<ol id="myCRED-buy-payments">
<?php 
            if (!empty($available_payees)) {
                foreach ($available_payees as $key => $description) {
                    ?>

		<li>
			<input type="radio" name="<?php 
                    echo $this->field_name('pay');
                    ?>
" id="<?php 
                    echo $this->field_id(array('pay' => $key));
                    ?>
" <?php 
                    checked($sell_content['pay'], $key);
                    ?>
 value="<?php 
                    echo $key;
                    ?>
" />
			<label for="<?php 
                    echo $this->field_id(array('pay' => $key));
                    ?>
"><?php 
                    echo $description;
                    ?>
</label>
		</li>
<?php 
                    if ($key == 'author') {
                        ?>

		<li>
			<label for="<?php 
                        echo $this->field_id('pay_percent');
                        ?>
"><?php 
                        _e('Percentage to pay Author', 'mycred');
                        ?>
</label>
			<div class="h2"><input type="text" size="5" maxlength="3" name="<?php 
                        echo $this->field_name('pay_percent');
                        ?>
" id="<?php 
                        echo $this->field_id('pay_percent');
                        ?>
" value="<?php 
                        echo $sell_content['pay_percent'];
                        ?>
" /> %</div>
			<span class="description"><?php 
                        _e('Percentage of the price to pay the author. Can not be zero and is ignored if authors are not paid.', 'mycred');
                        ?>
</span>
		</li>
<?php 
                    }
                }
            }
            ?>

	</ol>
	<label class="subheader"><?php 
            _e('Defaults', 'mycred');
            ?>
</label>
	<ol id="myCRED-buy-defaults">
		<li>
			<label for="<?php 
            echo $this->field_id(array('defaults' => 'price'));
            ?>
"><?php 
            _e('Price', 'mycred');
            ?>
</label>
			<div class="h2"><?php 
            echo $before;
            ?>
 <input type="text" name="<?php 
            echo $this->field_name(array('defaults' => 'price'));
            ?>
" id="<?php 
            echo $this->field_id(array('defaults' => 'price'));
            ?>
" value="<?php 
            echo $sell_content['defaults']['price'];
            ?>
" size="8" /> <?php 
            echo $after;
            ?>
</div>
		</li>
		<li>
			<input type="checkbox" name="<?php 
            echo $this->field_name(array('defaults' => 'overwrite_price'));
            ?>
" id="<?php 
            echo $this->field_id(array('defaults' => 'overwrite_price'));
            ?>
" <?php 
            checked($sell_content['defaults']['overwrite_price'], 1);
            ?>
 value="1" />
			<label for="<?php 
            echo $this->field_id(array('defaults' => 'overwrite_price'));
            ?>
"><?php 
            _e('Allow authors to change price.', 'mycred');
            ?>
</label>
		</li>
		<li class="empty">&nbsp;</li>
		<li>
			<label for="<?php 
            echo $this->field_id(array('defaults' => 'button_label'));
            ?>
"><?php 
            _e('Button Label', 'mycred');
            ?>
</label>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name(array('defaults' => 'button_label'));
            ?>
" id="<?php 
            echo $this->field_id(array('defaults' => 'button_label'));
            ?>
" value="<?php 
            echo $sell_content['defaults']['button_label'];
            ?>
" size="12" /></div>
		</li>
		<li>
			<input type="checkbox" name="<?php 
            echo $this->field_name(array('defaults' => 'overwrite_buttonlabel'));
            ?>
" id="<?php 
            echo $this->field_id(array('defaults' => 'overwrite_buttonlabel'));
            ?>
" <?php 
            checked($sell_content['defaults']['overwrite_buttonlabel'], 1);
            ?>
 value="1" />
			<label for="<?php 
            echo $this->field_id(array('defaults' => 'overwrite_buttonlabel'));
            ?>
"><?php 
            _e('Allow authors to change button label.', 'mycred');
            ?>
</label>
		</li>
		<li class="empty">&nbsp;</li>
		<li>
			<label for="<?php 
            echo $this->field_id(array('defaults' => 'expire'));
            ?>
"><?php 
            _e('Purchases expire after', 'mycred');
            ?>
</label>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name(array('defaults' => 'expire'));
            ?>
" id="<?php 
            echo $this->field_id(array('defaults' => 'expire'));
            ?>
" value="<?php 
            echo $sell_content['defaults']['expire'];
            ?>
" size="6" /> <?php 
            echo $this->exp_title;
            ?>
</div>
			<span class="description"><?php 
            _e('Use zero for permanent sales.', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id(array('templates' => 'visitors'));
            ?>
"><?php 
            _e('Templates', 'mycred');
            ?>
</label>
	<ol id="myCRED-buy-template-visitors">
		<li>
			<p><strong><?php 
            _e('For Visitors', 'mycred');
            ?>
</strong></p>
<?php 
            $id = str_replace('-', '', $this->field_id(array('templates' => 'visitors')));
            wp_editor($sell_content['templates']['visitors'], $id, array('textarea_name' => $this->field_name(array('templates' => 'visitors')), 'textarea_rows' => 6));
            ?>
			<span class="description"><?php 
            _e('Do <strong>not</strong> use the %buy_button% in this template as a user must be logged in to buy content!', 'mycred');
            ?>
<br />
			<?php 
            echo $this->core->available_template_tags(array('general', 'post'), '%price%');
            ?>
</span>
		</li>
		<li class="empty">&nbsp;</li>
		<li>
			<p><strong><?php 
            _e('For Members', 'mycred');
            ?>
</strong></p>
<?php 
            $id = str_replace('-', '', $this->field_id(array('templates' => 'members')));
            wp_editor($sell_content['templates']['members'], $id, array('textarea_name' => $this->field_name(array('templates' => 'members')), 'textarea_rows' => 6));
            ?>
			<span class="description"><?php 
            _e('Your template must contain the %buy_button% tag for purchases to work!', 'mycred');
            ?>
<br />
			<?php 
            echo $this->core->available_template_tags(array('general', 'post'), '%buy_button%, %price%');
            ?>
</span>
		</li>
		<li class="empty">&nbsp;</li>
		<li>
			<p><strong><?php 
            _e('For members that can not afford to buy', 'mycred');
            ?>
</strong></p>
<?php 
            $id = str_replace('-', '', $this->field_id(array('templates' => 'cantafford')));
            wp_editor($sell_content['templates']['cantafford'], $id, array('textarea_name' => $this->field_name(array('templates' => 'cantafford')), 'textarea_rows' => 6));
            ?>
			<span class="description"><?php 
            _e('Your template must contain the %buy_button% tag for purchases to work!', 'mycred');
            ?>
<br />
			<?php 
            echo $this->core->available_template_tags(array('general', 'post'), '%buy_button%, %price%');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id(array('logs' => 'buy'));
            ?>
"><?php 
            _e('Log template for Purchases', 'mycred');
            ?>
</label>
	<ol id="myCRED-buy-template-purchase">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name(array('logs' => 'buy'));
            ?>
" id="<?php 
            echo $this->field_id(array('logs' => 'buy'));
            ?>
" value="<?php 
            echo $sell_content['logs']['buy'];
            ?>
" class="long" /></div>
			<?php 
            echo $this->core->available_template_tags(array('general', 'post'));
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id(array('logs' => 'sell'));
            ?>
"><?php 
            _e('Log template for Sales', 'mycred');
            ?>
</label>
	<ol id="myCRED-buy-template-sale">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name(array('logs' => 'sell'));
            ?>
" id="<?php 
            echo $this->field_id(array('logs' => 'sell'));
            ?>
" value="<?php 
            echo $sell_content['logs']['sell'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            echo $this->core->available_template_tags(array('general', 'post'));
            ?>
</span>
		</li>
	</ol>
</div>
<?php 
        }
        /**
         * Metabox: Coupon Setup
         * @since 1.4
         * @version 1.1
         */
        public function metabox_coupon_setup($post)
        {
            global $mycred;
            $value = get_post_meta($post->ID, 'value', true);
            if (empty($value)) {
                $value = 1;
            }
            $expires = get_post_meta($post->ID, 'expires', true);
            $set_type = get_post_meta($post->ID, 'type', true);
            ?>

<style type="text/css">
table { width: 100%; }
table th { width: 20%; text-align: right; }
table th label { padding-right: 12px; }
table td { width: 80%; padding-bottom: 6px; }
table td textarea { width: 95%; }
#submitdiv .misc-pub-curtime, #submitdiv #visibility, #submitdiv #misc-publishing-actions { display: none; }
#submitdiv #minor-publishing-actions { padding-bottom: 10px; }
<?php 
            if ($post->post_status == 'publish') {
                ?>
#submitdiv #minor-publishing-actions { padding: 0 0 0 0; }
<?php 
            }
            ?>
</style>
<input type="hidden" name="mycred-coupon-nonce" value="<?php 
            echo wp_create_nonce('update-mycred-coupon');
            ?>
" />
<table class="table wide-fat">
	<tbody>
		<tr valign="top">
			<th scope="row"><label for="mycred-coupon-value"><?php 
            _e('Value', 'mycred');
            ?>
</label></th>
			<td>
				<input type="text" name="mycred_coupon[value]" id="mycred-coupon-value" value="<?php 
            echo $mycred->number($value);
            ?>
" /><br />
				<span class="description"><?php 
            echo $mycred->template_tags_general(__('The amount of %plural% this coupon is worth.', 'mycred'));
            ?>
</span>
			</td>
		</tr>
		<tr valign="top">
			<th scope="row"><label for="mycred-coupon-value"><?php 
            _e('Point Type', 'mycred');
            ?>
</label></th>
			<td>
				<?php 
            if (count($this->point_types) > 1) {
                ?>

					<?php 
                mycred_types_select_from_dropdown('mycred_coupon[type]', 'mycred-coupon-type', $set_type);
                ?>
<br />
					<span class="description"><?php 
                _e('Select the point type that this coupon is applied.', 'mycred');
                ?>
</span>

				<?php 
            } else {
                ?>

					<?php 
                echo $this->core->plural();
                ?>

				<?php 
            }
            ?>
			</td>
		</tr>
		<tr valign="top">
			<th scope="row"><label for="mycred-coupon-value"><?php 
            _e('Expire', 'mycred');
            ?>
</label></th>
			<td>
				<input type="text" name="mycred_coupon[expires]" id="mycred-coupon-expire" value="<?php 
            echo $expires;
            ?>
" placeholder="YYYY-MM-DD" /><br />
				<span class="description"><?php 
            _e('Optional date when this coupon expires. Expired coupons will be trashed.', 'mycred');
            ?>
</span>
			</td>
		</tr>
	</tbody>
</table>
	<?php 
            do_action('mycred_coupon_after_setup', $post);
            ?>

<?php 
        }
Example #6
0
        /**
         * Outputs the options form on admin
         */
        function form($instance)
        {
            // Defaults
            $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Leaderboard', 'mycred');
            $type = isset($instance['type']) ? $instance['type'] : 'mycred_default';
            $based_on = isset($instance['based_on']) ? esc_attr($instance['based_on']) : 'balance';
            $number = isset($instance['number']) ? abs($instance['number']) : 5;
            $show_visitors = isset($instance['show_visitors']) ? $instance['show_visitors'] : 0;
            $text = isset($instance['text']) ? esc_attr($instance['text']) : '#%position% %user_profile_link% %cred_f%';
            $offset = isset($instance['offset']) ? esc_attr($instance['offset']) : 0;
            $order = isset($instance['order']) ? esc_attr($instance['order']) : 'DESC';
            $current = isset($instance['current']) ? $instance['current'] : 0;
            $mycred = mycred($type);
            $mycred_types = mycred_get_types();
            ?>

		<p class="myCRED-widget-field">
			<label for="<?php 
            echo esc_attr($this->get_field_id('title'));
            ?>
"><?php 
            _e('Title', 'mycred');
            ?>
:</label>
			<input class="widefat" id="<?php 
            echo esc_attr($this->get_field_id('title'));
            ?>
" name="<?php 
            echo esc_attr($this->get_field_name('title'));
            ?>
" type="text" value="<?php 
            echo esc_attr($title);
            ?>
" />
		</p>
		
		<?php 
            if (count($mycred_types) > 1) {
                ?>
		<p class="myCRED-widget-field">
			<label for="<?php 
                echo esc_attr($this->get_field_id('type'));
                ?>
"><?php 
                _e('Point Type', 'mycred');
                ?>
:</label>
			<?php 
                mycred_types_select_from_dropdown($this->get_field_name('type'), $this->get_field_id('type'), $type);
                ?>
		</p>
		<?php 
            } else {
                ?>
			<?php 
                mycred_types_select_from_dropdown($this->get_field_name('type'), $this->get_field_id('type'), $type);
                ?>
		<?php 
            }
            ?>

		<p class="myCRED-widget-field">
			<label for="<?php 
            echo esc_attr($this->get_field_id('based_on'));
            ?>
"><?php 
            _e('Based On', 'mycred');
            ?>
:</label>
			<input class="widefat" id="<?php 
            echo esc_attr($this->get_field_id('based_on'));
            ?>
" name="<?php 
            echo esc_attr($this->get_field_name('based_on'));
            ?>
" type="text" value="<?php 
            echo esc_attr($based_on);
            ?>
" />
			<small><?php 
            _e('Use "balance" to base the leaderboard on your users current balances or use a specific reference.', 'mycred');
            ?>
 <a href="http://codex.mycred.me/reference-guide/log-references/" target="_blank"><?php 
            _e('Reference Guide', 'mycred');
            ?>
</a></small>
		</p>

		<p class="myCRED-widget-field">
			<input type="checkbox" name="<?php 
            echo esc_attr($this->get_field_name('show_visitors'));
            ?>
" id="<?php 
            echo esc_attr($this->get_field_id('show_visitors'));
            ?>
" value="1"<?php 
            checked($show_visitors, 1);
            ?>
 class="checkbox" /> 
			<label for="<?php 
            echo esc_attr($this->get_field_id('show_visitors'));
            ?>
"><?php 
            _e('Visible to non-members', 'mycred');
            ?>
</label>
		</p>
		<p class="myCRED-widget-field">
			<label for="<?php 
            echo esc_attr($this->get_field_id('number'));
            ?>
"><?php 
            _e('Number of users', 'mycred');
            ?>
:</label>
			<input id="<?php 
            echo esc_attr($this->get_field_id('number'));
            ?>
" name="<?php 
            echo esc_attr($this->get_field_name('number'));
            ?>
" type="text" value="<?php 
            echo $number;
            ?>
" size="3" class="align-right" />
		</p>
		<p class="myCRED-widget-field">
			<label for="<?php 
            echo esc_attr($this->get_field_id('text'));
            ?>
"><?php 
            _e('Row layout', 'mycred');
            ?>
:</label>
			<textarea class="widefat" name="<?php 
            echo esc_attr($this->get_field_name('text'));
            ?>
" id="<?php 
            echo esc_attr($this->get_field_id('text'));
            ?>
" rows="3"><?php 
            echo esc_attr($text);
            ?>
</textarea>
			<small><?php 
            echo $mycred->available_template_tags(array('general', 'widget'));
            ?>
</small>
		</p>
		<p class="myCRED-widget-field">
			<label for="<?php 
            echo esc_attr($this->get_field_id('offset'));
            ?>
"><?php 
            _e('Offset', 'mycred');
            ?>
:</label>
			<input id="<?php 
            echo esc_attr($this->get_field_id('offset'));
            ?>
" name="<?php 
            echo esc_attr($this->get_field_name('offset'));
            ?>
" type="text" value="<?php 
            echo $offset;
            ?>
" size="3" class="align-right" /><br />
			<small><?php 
            _e('Optional offset of order. Use zero to return the first in the list.', 'mycred');
            ?>
</small>
		</p>
		<p class="myCRED-widget-field">
			<label for="<?php 
            echo esc_attr($this->get_field_id('order'));
            ?>
"><?php 
            _e('Order', 'mycred');
            ?>
:</label> 
			<select name="<?php 
            echo esc_attr($this->get_field_name('order'));
            ?>
" id="<?php 
            echo esc_attr($this->get_field_id('order'));
            ?>
">
				<?php 
            $options = array('ASC' => __('Ascending', 'mycred'), 'DESC' => __('Descending', 'mycred'));
            foreach ($options as $value => $label) {
                echo '<option value="' . $value . '"';
                if ($order == $value) {
                    echo ' selected="selected"';
                }
                echo '>' . $label . '</option>';
            }
            ?>

			</select>
		</p>
		<p class="myCRED-widget-field">
			<input type="checkbox" name="<?php 
            echo esc_attr($this->get_field_name('current'));
            ?>
" id="<?php 
            echo esc_attr($this->get_field_id('current'));
            ?>
" value="1"<?php 
            checked($current, 1);
            ?>
 class="checkbox" /> 
			<label for="<?php 
            echo esc_attr($this->get_field_id('current'));
            ?>
"><?php 
            _e('Append current users position', 'mycred');
            ?>
</label><br />
			<small><?php 
            _e('If the current user is not in this leaderboard, you can select to append them at the end with their current position.', 'mycred');
            ?>
</small>
		</p>
<?php 
        }
    function mycred_wpecom_gateway_settings()
    {
        global $wpdb, $mycred_wpecom_settings;
        if (!isset($mycred_wpecom_settings['type'])) {
            $type = 'mycred_default';
        } else {
            $type = $mycred_wpecom_settings['type'];
        }
        $mycred = mycred($type);
        // Get current currency
        $currency_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A);
        $selected_currency = esc_attr(get_option('currency_type'));
        foreach ($currency_data as $currency) {
            if ($selected_currency != $currency['id']) {
                continue;
            } else {
                if (!empty($currency['symbol_html'])) {
                    $selected_currency = $currency['symbol_html'];
                } else {
                    $selected_currency = $currency['code'];
                }
                break;
            }
        }
        $output = '
		<tr>
			<td colspan="2"><strong>' . __('General', 'mycred') . '</strong></td>
		</tr>
		<tr>
			<td width="150">' . __('Log Template for Payments', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[log]" value="' . esc_attr($mycred_wpecom_settings['log']) . '" style="width:50%;" /><br /><span class="description">' . $mycred->available_template_tags(array('general'), '%order_id%') . '</span></td>
		</tr>';
        $mycred_types = mycred_get_types();
        if (count($mycred_types) == 1) {
            $output .= '<input type="hidden" name="mycred_gateway[type]" value="mycred_default" />';
        } else {
            $output .= '
		<tr>
			<td width="150">' . __('Point Type', 'mycred') . '</td>
			<td>' . mycred_types_select_from_dropdown('mycred_gateway[type]', 'mycred-point-type', $type, true) . '</td>
		</tr>';
        }
        $output .= '
		<tr>
			<td width="150">' . __('Exchange Rate', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[rate]" value="' . esc_attr($mycred_wpecom_settings['rate']) . '" style="width:50px;" /><br /><span class="description">' . sprintf(__('How much is 1 %s worth in %s', 'mycred'), $selected_currency, $mycred->plural()) . '</span></td>
		</tr>
		<tr>
			<td colspan="2"><strong>' . __('Profit Sharing', 'mycred') . '</strong></td>
		</tr>
		<tr>
			<td width="150">' . __('Payout', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[share]" value="' . esc_attr($mycred_wpecom_settings['share']) . '" style="width:50px;" /> %<br /><span class="description">' . __('Option to share sales with the product owner. Use zero to disable.', 'mycred') . '</span></td>
		</tr>
		<tr>
			<td width="150">' . __('Log Template', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[share_log]" value="' . esc_attr($mycred_wpecom_settings['share_log']) . '" style="width:50%;" /><br /><span class="description">' . $mycred->available_template_tags(array('general', 'post')) . '</span></td>
		</tr>
		<tr>
			<td colspan="2"><strong>' . __('Messages', 'mycred') . '</strong></td>
		</tr>
		<tr>
			<td width="150">' . __('Instructions', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[message]" value="' . esc_attr($mycred_wpecom_settings['message']) . '" style="width:50%;" /><br /><span class="description">' . __('Optional instructions to show users when selecting this gateway. Leave empty to hide.', 'mycred') . '</span></td>
		</tr>
		<tr>
			<td width="150">' . __('Visitors', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[visitor]" value="' . esc_attr($mycred_wpecom_settings['visitor']) . '" style="width:50%;" /><br /><span class="description">' . __('Message to show visitors who are not logged in.', 'mycred') . '</span></td>
		</tr>
		<tr>
			<td width="150">' . __('Insufficient Funds', 'mycred') . '</td>
			<td><input type="text" name="mycred_gateway[low_funds]" value="' . esc_attr($mycred_wpecom_settings['low_funds']) . '" style="width:50%;" /><br /><span class="description">' . $mycred->template_tags_general(__('Message to show when users does not have enough %plural% to pay using this gateway.', 'mycred')) . '</span></td>
		</tr>';
        return apply_filters('mycred_wpecom_settings', $output);
    }
Example #8
0
        /**
         * Rank Settings Metabox
         * @since 1.1
         * @version 1.1
         */
        public function rank_settings($post)
        {
            // Get type
            $type = get_post_meta($post->ID, 'ctype', true);
            if ($type == '') {
                $type = 'mycred_default';
                update_post_meta($post->ID, 'ctype', $type);
            }
            // If a custom type has been requested via the URL
            if (isset($_REQUEST['ctype']) && !empty($_REQUEST['ctype'])) {
                $type = sanitize_text_field($_REQUEST['ctype']);
            }
            // Load the appropriate type object
            $mycred = $this->core;
            if ($type != 'mycred_default') {
                $mycred = mycred($type);
            }
            // Get min and max setting for this rank
            $min = get_post_meta($post->ID, 'mycred_rank_min', true);
            $max = get_post_meta($post->ID, 'mycred_rank_max', true);
            ?>
<style type="text/css">
#submitdiv .misc-pub-curtime { display: none; }
#mycred_rank_settings .inside { margin: 0; padding: 0; clear: both; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper { float: none; clear: both; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper .box { width: 48%; float: left; margin: 0; padding: 0; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper .box .wrap { padding: 12px; margin: 0; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper .border { border-right: 1px solid #ddd; margin-right: -1px; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper p { margin: 0 0 0 0; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper ul li strong { display: inline-block; width: 60%; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper label { font-weight: bold; display: block; }
#mycred_rank_settings .inside #mycred-rank-setup-wrapper input[type="text"], 
#mycred_rank_settings .inside #mycred-rank-setup-wrapper select { min-width: 60%; margin-bottom: 12px; }
</style>
<div id="mycred-rank-setup-wrapper">
	<div class="box border">
		<div class="wrap">
			<p>
				<label for="mycred-rank-min"><?php 
            echo $mycred->template_tags_general(__('Minimum %plural% to reach this rank', 'mycred'));
            ?>
:</label>
				<input type="text" name="mycred_rank[min]" id="mycred-rank-min" value="<?php 
            echo $min;
            ?>
" />
			</p>
			<p>
				<label for="mycred-rank-max"><?php 
            echo $mycred->template_tags_general(__('Maximum %plural% to be included in this rank', 'mycred'));
            ?>
:</label>
				<input type="text" name="mycred_rank[max]" id="mycred-rank-max" value="<?php 
            echo $max;
            ?>
" />
			</p>

			<?php 
            if (count($this->point_types) > 1) {
                ?>

			<p>
				<label for="mycred-rank-point-type"><?php 
                _e('Point Type', 'mycred');
                ?>
</label>
				<?php 
                mycred_types_select_from_dropdown('mycred_rank[ctype]', 'mycred-rank-point-type', $type);
                ?>
			</p>

			<?php 
            } else {
                ?>

			<input type="hidden" name="mycred_rank[ctype]" value="mycred_default" />

			<?php 
            }
            ?>

			<?php 
            do_action('mycred_rank_after_req', $post, $this->core);
            ?>

		</div>
	</div>
	<div class="box">
		<div class="wrap">
			<p><?php 
            _e('All Published Ranks', 'mycred');
            ?>
:</p>
<?php 
            // Get all published ranks for this type
            $all = mycred_get_ranks('publish', '-1', 'DESC', $type);
            if (!empty($all)) {
                echo '<ul>';
                foreach ($all as $rank_id => $rank) {
                    $_min = get_post_meta($rank_id, 'mycred_rank_min', true);
                    if (empty($_min) && (int) $_min !== 0) {
                        $_min = __('Not Set', 'mycred');
                    }
                    $_max = get_post_meta($rank_id, 'mycred_rank_max', true);
                    if (empty($_max)) {
                        $_max = __('Not Set', 'mycred');
                    }
                    echo '<li><strong>' . $rank->post_title . '</strong> ' . $_min . ' - ' . $_max . '</li>';
                }
                echo '</ul>';
            } else {
                echo '<p>' . __('No Ranks found', 'mycred') . '.</p>';
            }
            ?>

			<input type="hidden" name="mycred_rank[token]" value="<?php 
            echo wp_create_nonce('mycred-edit-rank' . $post->ID);
            ?>
" />
		</div>
	</div>
	<div class="clear clearfix"></div>
</div>
<?php 
        }
        /**
         * Badge Preferences Metabox
         * @version 1.1
         */
        public function metabox_badge_requirements($post)
        {
            $requirements = mycred_get_badge_requirements($post->ID, true);
            $references = mycred_get_all_references();
            $default_image = get_post_meta($post->ID, 'default_image', true);
            $main_image = get_post_meta($post->ID, 'main_image', true);
            $sums = array('count' => __('Time(s)', 'mycred'), 'sum' => __('In total', 'mycred'));
            ?>

<style type="text/css">
#mycred-remove-badge-connections { float: right; }
#mycred-badge-actions { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid #ccc; }
<?php 
            if ($post->post_status != 'publish') {
                ?>
#minor-publishing-actions { padding-bottom: 12px; }
<?php 
            } else {
                ?>
#minor-publishing-actions { display: none; }
<?php 
            }
            ?>
#misc-publishing-actions { display: none; display: none !important; }
table#setup-badge-reqs { width: 100%; }
table#setup-badge-reqs tr.bodered-row td { padding-bottom: 12px; border-bottom: 1px solid #dedede; }
table#setup-badge-reqs tr.badge-requires td { padding-top: 12px; }
table#setup-badge-reqs td.level { width: 15%; color: #aaa; }
table#setup-badge-reqs td.type { width: 20%; }
table#setup-badge-reqs td.for { width: 5%; }
table#setup-badge-reqs td.reference { width: auto; }
table#setup-badge-reqs td.amount { width: 10%; }
table#setup-badge-reqs td.sum { width: 10%; }
#setup-badge-reqs td label { display: block; margin-bottom: 4px; font-weight: bold; }
p.actions { text-align: right; }
#mycred_badge_images .inside, #mycred_badge_images .inside p { margin: 0; padding: 0; }
#image-wrapper { float: none; clear: both; min-height: 100px; }
#image-wrapper #main-image { border-bottom: none; }
#setup-badge-reqs div.inner-box { float: none; clear: both; min-height: 50px; margin: 0; padding: 0; }
#setup-badge-reqs div.inner-box .thumb { display: block; width: <?php 
            echo MYCRED_BADGE_WIDTH;
            ?>
px; height: <?php 
            echo MYCRED_BADGE_HEIGHT;
            ?>
px; padding: 12px; overflow: hidden; }
#setup-badge-reqs div.inner-box .thumb img { max-width: <?php 
            echo MYCRED_BADGE_WIDTH;
            ?>
px; height: auto; margin: 0 auto; }
</style>
<script type="text/javascript">
jQuery(function($) {
	$( '#postimagediv h3.hndle span' ).empty().text( '<?php 
            echo esc_js(esc_attr__('Badge Image', 'mycred'));
            ?>
' );
	$( '#postimagediv div.inside p a' ).attr( 'title', '<?php 
            echo esc_js(esc_attr__('Set badge image', 'mycred'));
            ?>
' ).empty().text( '<?php 
            echo esc_js(esc_attr__('Set badge image', 'mycred'));
            ?>
' );
});
</script>
<table class="table" style="width: 100%;" id="setup-badge-reqs">

	<?php 
            do_action('mycred_edit_badge_before_req', $post);
            ?>

	<tr class="bodered-row">
		<td class="level"><div class="inner-box"><div class="thumb"><?php 
            if ($default_image != '') {
                echo '<img src="' . $default_image . '" alt="" />';
            }
            ?>
</div></div></td>
		<td colspan="5">
			<label><?php 
            _e('Default Image', 'mycred');
            ?>
</label>
			<input type="text" name="mycred_badge[default_image]" placeholder="<?php 
            _e('image url', 'mycred');
            ?>
" id="mycred-default-image-url" class="regular-text" size="30" value="<?php 
            echo $default_image;
            ?>
" /> 
			<input type="button" data-target="default-image" id="mycred-add-default-image" class="button button-primary mycred-badge-load-image" value="<?php 
            _e('Add Image', 'mycred');
            ?>
" />
			<p><span class="description"><?php 
            _e('Optional image to show when a user has not yet earned this badge.', 'mycred');
            ?>
</span></p>
		</td>
	</tr>
<?php 
            foreach ($requirements as $row => $needs) {
                // First row
                if ($row == 0) {
                    if (!isset($needs['by'])) {
                        $needs = array('type' => '', 'reference' => '', 'amount' => '', 'by' => '');
                    }
                    ?>
	<tr class="badge-requires" id="badge-requirement-<?php 
                    echo $row;
                    ?>
">
		<td class="level"><?php 
                    printf(__('Level %d', 'mycred'), $row + 1);
                    ?>
</td>
		<td class="type">
			<?php 
                    if (count($this->point_types) == 1) {
                        echo $this->core->plural();
                    }
                    ?>
			<?php 
                    mycred_types_select_from_dropdown('mycred_badge[req][' . $row . '][type]', 'default-badge-req-type', $needs['type']);
                    ?>
		</td>
		<td class="for"><?php 
                    _e('for', 'mycred');
                    ?>
</td>
		<td class="reference">
			<select name="mycred_badge[req][<?php 
                    echo $row;
                    ?>
][reference]" id="default-badge-req-reference"><?php 
                    foreach ($references as $ref => $label) {
                        echo '<option value="' . $ref . '"';
                        if ($needs['reference'] == $ref) {
                            echo ' selected="selected"';
                        }
                        echo '>' . $label . '</option>';
                    }
                    ?>
</select>
		</td>
		<td class="amount">
			<input type="text" size="8" name="mycred_badge[req][<?php 
                    echo $row;
                    ?>
][amount]" id="default-badge-req-amount" value="<?php 
                    echo $needs['amount'];
                    ?>
" />
		</td>
		<td class="sum">
			<select name="mycred_badge[req][<?php 
                    echo $row;
                    ?>
][by]" id="default-badge-req-by"><?php 
                    foreach ($sums as $sum => $label) {
                        echo '<option value="' . $sum . '"';
                        if ($needs['by'] == $sum) {
                            echo ' selected="selected"';
                        }
                        echo '>' . $label . '</option>';
                    }
                    ?>
</select>
		</td>
	</tr>
	<tr class="bodered-row">
		<td class="level"><div class="inner-box"><div class="thumb"><?php 
                    if ($main_image != '') {
                        echo '<img src="' . $main_image . '" alt="" />';
                    }
                    ?>
</div></div></td>
		<td colspan="5">
			<label><?php 
                    _e('Main Image', 'mycred');
                    ?>
</label>
			<input type="text" name="mycred_badge[images][<?php 
                    echo $row;
                    ?>
]" placeholder="<?php 
                    _e('image url', 'mycred');
                    ?>
" id="mycred-badge-level<?php 
                    echo $row;
                    ?>
" class="regular-text" size="30" value="<?php 
                    echo $main_image;
                    ?>
" /> 
			<input type="button" data-target="mycred-badge-level<?php 
                    echo $row;
                    ?>
" data-row="<?php 
                    echo $row;
                    ?>
" class="button button-primary mycred-badge-load-image" value="<?php 
                    _e('Add Image', 'mycred');
                    ?>
" />
		</td>
	</tr>
<?php 
                } else {
                    $default = $requirements[0];
                    $level_image = get_post_meta($post->ID, 'level_image' . $row, true);
                    ?>
	<tr class="badge-requires" id="badge-requirement-<?php 
                    echo $row;
                    ?>
">
		<td class="level">
			<div><?php 
                    printf(__('Level %d', 'mycred'), $row + 1);
                    ?>
</div>
		</td>
		<td class="type">
			<div><?php 
                    echo $this->point_types[$default['type']];
                    ?>
</div>
		</td>
		<td class="for"><?php 
                    _e('for', 'mycred');
                    ?>
</td>
		<td class="reference"><div><?php 
                    echo $references[$default['reference']];
                    ?>
</div></td>
		<td class="amount">
			<input type="text" size="8" name="mycred_badge[req][<?php 
                    echo $row;
                    ?>
][amount]" value="<?php 
                    echo $needs['amount'];
                    ?>
" />
		</td>
		<td class="sum"><div><?php 
                    echo $sums[$default['by']];
                    ?>
</div></td>
	</tr>
	<tr class="bodered-row" id="mycred-badge-image<?php 
                    echo $row;
                    ?>
">
		<td class="level"><div class="inner-box"><div class="thumb"><?php 
                    if ($level_image != '') {
                        echo '<img src="' . $level_image . '" alt="" />';
                    }
                    ?>
</div></div></td>
		<td colspan="5">
			<label><?php 
                    _e('Badge Image', 'mycred');
                    ?>
</label>
			<input type="text" name="mycred_badge[images][<?php 
                    echo $row;
                    ?>
]" placeholder="<?php 
                    _e('image url', 'mycred');
                    ?>
" id="mycred-badge-level<?php 
                    echo $row;
                    ?>
" class="regular-text" size="30" value="<?php 
                    echo $level_image;
                    ?>
" /> 
			<input type="button" data-target="mycred-badge-level<?php 
                    echo $row;
                    ?>
" data-row="<?php 
                    echo $row;
                    ?>
" class="button button-primary mycred-badge-load-image" value="<?php 
                    _e('Add Image', 'mycred');
                    ?>
" />
			<p><span class="description"><?php 
                    _e('Leave empty if you do not want to assign a custom image for this level.', 'mycred');
                    ?>
</span><button class="button button-secondary button-small pull-right remove-this-row"><?php 
                    _e('Remove this level', 'mycred');
                    ?>
</button></p>
		</td>
	</tr>
<?php 
                }
            }
            ?>

	<?php 
            do_action('mycred_edit_badge_after_req', $post);
            ?>

</table>
<p><button id="add-mycred-badge-level" class="pull-right button button-secondary"><?php 
            _e('Add Level', 'mycred');
            ?>
</button></p>
<script type="text/javascript">
(function($) {

	$( 'select#default-badge-req-type' ).change(function(){
	
		$( 'td.type div' ).empty().text( $(this).find( ':selected' ).text() );
	
	});

	$( '#default-badge-req-reference' ).change(function(){
	
		$( 'td.reference div' ).empty().text( $(this).find( ':selected' ).text() );
	
	});

	$( 'select#default-badge-req-by' ).change(function(){
	
		$( 'td.sum div' ).empty().text( $(this).find( ':selected' ).text() );
	
	});

	var custom_uploader;

	var rows = <?php 
            echo count($requirements);
            ?>
;

	$( 'table#setup-badge-reqs' ).on( 'click', 'button.remove-this-row', function(){

		var trrow = $(this).parent().parent().parent();
		trrow.prev().remove();
		trrow.remove();
		rows = rows-1;

	});

	$( '#add-mycred-badge-level' ).on( 'click', function(e){
		e.preventDefault();

		var badgetype   = $( '#default-badge-req-type' );
		var badgeref    = $( '#default-badge-req-reference' ).find( ':selected' ).text();
		var badgeamount = $( '#default-badge-req-amount' );
		var badgeby     = $( '#default-badge-req-by' ).find( ':selected' ).text();

		var reqtemplate = '<tr class="badge-requires" id="badge-requirement-' + rows + '"><td class="level"><?php 
            echo esc_js(esc_attr__('Level', 'mycred'));
            ?>
 ' + ( rows + 1 ) + '</td><td class="type"><div>' + badgetype.find( ':selected' ).text() + '</div></td><td class="for"><?php 
            echo esc_js(esc_attr__('for', 'mycred'));
            ?>
</td><td class="reference"><div>' + badgeref + '</div></td><td class="amount"><input type="text" size="8" name="mycred_badge[req][' + rows + '][amount]" value="" /></td><td class="sum"><div>' + badgeby + '</div></td></tr><tr class="bodered-row"><td class="level"><div class="inner-box"><div class="thumb"></div></div></td><td colspan="5"><label><?php 
            echo esc_js(esc_attr__('Badge Image', 'mycred'));
            ?>
</label><input type="text" name="mycred_badge[images][' + rows + ']" placeholder="<?php 
            echo esc_js(esc_attr__('image url', 'mycred'));
            ?>
" id="mycred-badge-level' + rows + '" class="regular-text" size="30" value="" />&nbsp;<input type="button" data-target="mycred-badge-level' + rows + '" data-row="' + rows + '" class="button button-primary mycred-badge-load-image" value="<?php 
            echo esc_js(esc_attr__('Add Image', 'mycred'));
            ?>
" /><p><span class="description"><?php 
            echo esc_js(esc_attr__('Leave empty if you do not want to assign a custom image for this level.', 'mycred'));
            ?>
</span><br /><button class="button button-secondary button-small pull-right remove-this-row"><?php 
            echo esc_js(esc_attr__('Remove this level', 'mycred'));
            ?>
</button></p></td></tr>';

		$( 'table#setup-badge-reqs' ).append( reqtemplate );
		rows = rows+1;

	});

	$( 'table#setup-badge-reqs' ).on( 'click', '.mycred-badge-load-image', function(e){
		e.preventDefault();

		var imagerow = $(this).attr( 'data-target' );
		var button = $(this);

		//Extend the wp.media object
		custom_uploader = wp.media.frames.file_frame = wp.media({
			title    : '<?php 
            echo esc_js(esc_attr__('Badge Image', 'mycred'));
            ?>
',
			button   : {
				text     : '<?php 
            echo esc_js(esc_attr__('Use as Badge', 'mycred'));
            ?>
'
			},
			multiple : false
		});

		//When a file is selected, grab the URL and set it as the text field's value
		custom_uploader.on( 'select', function(){
			attachment = custom_uploader.state().get('selection').first().toJSON();
			if ( attachment.url != '' ) {
				console.log( attachment );
				button.prev().val( attachment.url );
				button.parent().prev().find( 'div.thumb' ).empty().append( "<img class='show-selected-image' src='" + attachment.url + "' alt='' />" );
			}
		});

		//Open the uploader dialog
		custom_uploader.open();

	});

})( jQuery );
</script>
<div class="clear clearfix"></div>
<?php 
        }
Example #10
0
            /**
             * myCRED Gateway Settings
             * @since 1.1
             * @version 1.3
             */
            function gateway_settings_box($settings)
            {
                global $mp;
                $settings = get_option('mp_settings');
                $mycred = mycred();
                $name = mycred_label(true);
                $settings['gateways']['mycred'] = shortcode_atts(array('name' => $name . ' ' . $mycred->template_tags_general(__('%_singular% Balance', 'mycred')), 'logo' => $this->method_button_img_url, 'type' => 'mycred_default', 'log_template' => __('Payment for Order: #%order_id%', 'mycred'), 'exchange' => 1, 'profit_share_percent' => 0, 'profit_share_log' => __('Product Sale: %post_title%', 'mycred'), 'instructions' => __('Pay using your account balance.', 'mycred'), 'confirmation' => __('TOTAL amount has been deducted from your account. Your current balance is: %balance_f%', 'mycred'), 'lowfunds' => __('Insufficient funds.', 'mycred'), 'visitors' => __('You must be logged in to pay with %_plural%. Please <a href="%login_url_here%">login</a>.', 'mycred'), 'email' => $settings['email']['new_order_txt']), isset($settings['gateways']['mycred']) ? $settings['gateways']['mycred'] : array());
                ?>

<div id="mp_mycred_payments" class="postbox mp-pages-msgs">
	<h3 class="handle"><span><?php 
                echo $name . ' ' . __('Settings', 'mycred');
                ?>
</span></h3>
	<div class="inside">
		<span class="description"><?php 
                echo sprintf(__('Let your users pay for items in their shopping cart using their %s Account. Note! This gateway requires your users to be logged in when making a purchase!', 'mycred'), $name);
                ?>
</span>
		<table class="form-table">
			<tr>
				<th scope="row"><label for="mycred-method-name"><?php 
                _e('Method Name', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                _e('Enter a public name for this payment method that is displayed to users - No HTML', 'mycred');
                ?>
</span>
					<p><input value="<?php 
                echo esc_attr($settings['gateways']['mycred']['name']);
                ?>
" style="width: 100%;" name="mp[gateways][mycred][name]" id="mycred-method-name" type="text" /></p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-method-logo"><?php 
                _e('Gateway Logo URL', 'mycred');
                ?>
</label></th>
				<td>
					<p><input value="<?php 
                echo esc_attr($settings['gateways']['mycred']['logo']);
                ?>
" style="width: 100%;" name="mp[gateways][mycred][logo]" id="mycred-method-logo" type="text" /></p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-method-type"><?php 
                _e('Point Type', 'mycred');
                ?>
</label></th>
				<td>
					<?php 
                mycred_types_select_from_dropdown('mp[gateways][mycred][type]', 'mycred-method-type', $settings['gateways']['mycred']['type']);
                ?>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-log-template"><?php 
                _e('Log Template', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general'), '%order_id%, %order_link%');
                ?>
</span>
					<p><input value="<?php 
                echo esc_attr($settings['gateways']['mycred']['log_template']);
                ?>
" style="width: 100%;" name="mp[gateways][mycred][log_template]" id="mycred-log-template" type="text" /></p>
				</td>
			</tr>
<?php 
                // Exchange rate
                if ($this->use_exchange()) {
                    $exchange_desc = __('How much is 1 %_singular% worth in %currency%?', 'mycred');
                    $exchange_desc = $mycred->template_tags_general($exchange_desc);
                    $exchange_desc = str_replace('%currency%', $settings['currency'], $exchange_desc);
                    ?>

			<tr>
				<th scope="row"><label for="mycred-exchange-rate"><?php 
                    _e('Exchange Rate', 'mycred');
                    ?>
</label></th>
				<td>
					<span class="description"><?php 
                    echo $exchange_desc;
                    ?>
</span>
					<p><input value="<?php 
                    echo esc_attr($settings['gateways']['mycred']['exchange']);
                    ?>
" size="8" name="mp[gateways][mycred][exchange]" id="mycred-exchange-rate" type="text" /></p>
				</td>
			</tr>
<?php 
                }
                ?>

			<tr>
				<td colspan="2"><h4><?php 
                _e('Profit Sharing', 'mycred');
                ?>
</h4></td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-profit-sharing"><?php 
                _e('Percentage', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                _e('Option to share sales with the product owner. Use zero to disable.', 'mycred');
                ?>
</span>
					<p><input value="<?php 
                echo esc_attr($settings['gateways']['mycred']['profit_share_percent']);
                ?>
" size="8" name="mp[gateways][mycred][profit_share_percent]" id="mycred-profit-sharing" type="text" /> %</p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-profit-sharing-log"><?php 
                _e('Log Template', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general', 'post'));
                ?>
</span>
					<p><input value="<?php 
                echo esc_attr($settings['gateways']['mycred']['profit_share_log']);
                ?>
" style="width: 100%;" name="mp[gateways][mycred][profit_share_log]" id="mycred-profit-sharing-log" type="text" /></p>
				</td>
			</tr>
			<tr>
				<td colspan="2"><h4><?php 
                _e('Messages', 'mycred');
                ?>
</h4></td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-lowfunds"><?php 
                _e('Insufficient Funds', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                _e('Message to show when the user can not use this gateway.', 'mycred');
                ?>
</span>
					<p><input type="text" name="mp[gateways][mycred][lowfunds]" id="mycred-lowfunds" style="width: 100%;" value="<?php 
                echo esc_attr($settings['gateways']['mycred']['lowfunds']);
                ?>
"><br />
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general'));
                ?>
</span></p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-visitors"><?php 
                _e('Visitors', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                _e('Message to show to buyers that are not logged in.', 'mycred');
                ?>
</span>
					<p><input type="text" name="mp[gateways][mycred][visitors]" id="mycred-visitors" style="width: 100%;" value="<?php 
                echo esc_attr($settings['gateways']['mycred']['visitors']);
                ?>
"><br />
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general'));
                ?>
</span></p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-instructions"><?php 
                _e('User Instructions', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                _e('Information to show users before payment.', 'mycred');
                ?>
</span>
					<p><?php 
                wp_editor($settings['gateways']['mycred']['instructions'], 'mycred-instructions', array('textarea_name' => 'mp[gateways][mycred][instructions]'));
                ?>
<br />
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general'), '%balance% or %balance_f%');
                ?>
</span></p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-confirmation"><?php 
                _e('Confirmation Information', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                _e('Information to display on the order confirmation page. - HTML allowed', 'mycred');
                ?>
</span>
					<p><?php 
                wp_editor($settings['gateways']['mycred']['confirmation'], 'mycred-confirmation', array('textarea_name' => 'mp[gateways][mycred][confirmation]'));
                ?>
<br />
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general'), '%balance% or %balance_f%');
                ?>
</span></p>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="mycred-email"><?php 
                _e('Order Confirmation Email', 'mycred');
                ?>
</label></th>
				<td>
					<span class="description"><?php 
                echo sprintf(__('This is the email text to send to those who have made %s checkouts. It overrides the default order checkout email. These codes will be replaced with order details: CUSTOMERNAME, ORDERID, ORDERINFO, SHIPPINGINFO, PAYMENTINFO, TOTAL, TRACKINGURL. No HTML allowed.', 'mycred'), $name);
                ?>
</span>
					<p><textarea id="mycred-email" name="mp[gateways][mycred][email]" class="mp_emails_txt"><?php 
                echo esc_textarea($settings['gateways']['mycred']['email']);
                ?>
</textarea></p>
					<span class="description"><?php 
                echo $mycred->available_template_tags(array('general'), '%balance% or %balance_f%');
                ?>
</span>
				</td>
			</tr>
		</table>
	</div>
</div>
<?php 
            }
Example #11
0
        /**
         * greet function.
         */
        function greet()
        {
            global $wpdb, $mycred;
            $actions = array('' => __('Select what to import', 'mycred'), 'log' => __('Log Entries Only', 'mycred'), 'balance' => __('CubePoints Balances Only', 'mycred'), 'both' => __('Log Entries and Balances', 'mycred'));
            $action = 'admin.php?import=mycred_import_cp&step=1';
            $mycred_types = mycred_get_types();
            echo '<div class="narrow">';
            echo '<p>' . __('Import CubePoints log entries and / or balances.', 'mycred') . '</p>';
            ?>

<form id="import-setup" method="post" action="<?php 
            echo esc_attr(wp_nonce_url($action, 'import-upload'));
            ?>
">
	<table class="form-table">
		<tbody>
			<tr>
				<th>
					<label for="import-action"><?php 
            _e('Import', 'mycred');
            ?>
</label>
				</th>
				<td>
					<select name="action" id="import-action"><?php 
            foreach ($actions as $action => $label) {
                echo '<option value="' . $action . '">' . $label . '</option>';
            }
            ?>
</select><br />
					<span class="description"><?php 
            _e('Warning! Importing CubePoints balances will replace your users myCRED balance!', 'mycred');
            ?>
</span>
				</td>
			</tr>
			<tr>
				<th>
					<label for="import-action"><?php 
            _e('Point Type', 'mycred');
            ?>
</label>
				</th>
				<td>
					<?php 
            if (count($mycred_types) == 1) {
                ?>
					<strong><?php 
                echo $mycred->plural();
                ?>
</strong><input type="hidden" name="type" value="mycred_default" />
					<?php 
            } else {
                ?>
					<?php 
                mycred_types_select_from_dropdown('type', 'mycred-type', 'mycred_default');
                ?>
					<?php 
            }
            ?>
				</td>
			</tr>
		</tbody>
	</table>
	<p class="submit">
		<input type="submit" class="button" value="<?php 
            esc_attr_e('Import Log');
            ?>
" />
	</p>
</form>
<?php 
            echo '</div>';
        }
        /**
         * Metabox: wplms Setup
         * @since 1.4
         * @version 1.0
         */
        public function metabox_wplms_setup($post)
        {
            global $mycred;
            $value = get_post_meta($post->ID, 'value', true);
            if (empty($value)) {
                $value = 1;
            }
            $expires = get_post_meta($post->ID, 'expires', true);
            ?>

<style type="text/css">
table { width: 100%; }
table th { width: 20%; text-align: right; }
table th label { padding-right: 12px; }
table td { width: 80%; padding-bottom: 6px; }
table td textarea { width: 95%; }
</style>
<input type="hidden" name="mycred-wplms-nonce" value="<?php 
            echo wp_create_nonce('update-mycred-wplms');
            ?>
" />
<table class="table wide-fat">
	<tbody>
		<tr valign="top">
			<th scope="row"><label for="mycred-wplms-value"><?php 
            _e('Value', 'wplms-mycred');
            ?>
</label></th>
			<td>
				<input type="text" name="mycred_wplms[value]" id="mycred-wplms-value" value="<?php 
            echo $mycred->number($value);
            ?>
" /><br />
				<span class="description"><?php 
            echo $mycred->template_tags_general(__('The amount of %plural% this wplms is worth.', 'wplms-mycred'));
            ?>
</span>
				<?php 
            if (count($mycred_types) > 1) {
                ?>

					<br /><label for="mycred-wplms-type"><?php 
                _e('Point Type', 'wplms-mycred');
                ?>
</label><br /><?php 
                mycred_types_select_from_dropdown('mycred_wplms[type]', 'mycred-wplms-type', $set_type);
                ?>
					<span class="description"><?php 
                _e('Select the point type that this wplms is applied.', 'wplms-mycred');
                ?>
</span>
				<?php 
            }
            ?>
			</td>
		</tr>
		<tr valign="top">
			<th scope="row"><label for="mycred-wplms-value"><?php 
            _e('Expire', 'wplms-mycred');
            ?>
</label></th>
			<td>
				<input type="text" name="mycred_wplms[expires]" id="mycred-wplms-expire" value="<?php 
            echo $expires;
            ?>
" placeholder="YYYY-MM-DD" /><br />
				<span class="description"><?php 
            _e('Optional date when this wplms points criteria expires. Expired WPLMS points criterias will be trashed.', 'wplms-mycred');
            ?>
</span>
			</td>
		</tr>
	</tbody>
</table>
	<?php 
            do_action('mycred_wplms_after_setup', $post);
            ?>

<?php 
        }
Example #13
0
        /**
         * Badge Preferences Metabox
         * @version 1.0
         */
        public function metabox_badge_requirements($post)
        {
            $requirements = mycred_get_badge_requirements($post->ID, true);
            $types = mycred_get_types();
            $references = mycred_get_all_references();
            $sums = array('count' => __('Time(s)', 'mycred'), 'sum' => __('In total', 'mycred'));
            ?>

<style type="text/css">
#mycred-remove-badge-connections { float: right; }
#mycred-badge-actions { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid #ccc; }
<?php 
            if ($post->post_status != 'publish') {
                ?>
#minor-publishing-actions { padding-bottom: 12px; }
<?php 
            } else {
                ?>
#minor-publishing-actions { display: none; }
<?php 
            }
            ?>
#misc-publishing-actions { display: none; display: none !important; }
table#setup-badge-reqs { width: 100%; }
table#setup-badge-reqs td.type { width: 25%; }
table#setup-badge-reqs td.for { width: 5%; }
table#setup-badge-reqs td.reference { width: 50%; }
table#setup-badge-reqs td.amount { width: 10%; }
table#setup-badge-reqs td.sum { width: 10%; }
p.actions { text-align: right; }
</style>
<script type="text/javascript">
jQuery(function($) {
	$( '#postimagediv h3.hndle span' ).empty().text( '<?php 
            _e('Badge Image', 'mycred');
            ?>
' );
	$( '#postimagediv div.inside p a' ).attr( 'title', '<?php 
            _e('Set badge image', 'mycred');
            ?>
' ).empty().text( '<?php 
            _e('Set badge image', 'mycred');
            ?>
' );
});
</script>
<p>To earn this badge, a user must have received:</p>
<table class="table" style="width: 100%;" id="setup-badge-reqs">

	<?php 
            do_action('mycred_edit_badge_before_req', $post);
            ?>

<?php 
            foreach ($requirements as $row => $needs) {
                if (!isset($needs['by'])) {
                    $needs = array('type' => '', 'reference' => '', 'amount' => '', 'by' => '');
                }
                ?>
	<tr class="badge-requires" id="badge-requirement-<?php 
                echo $row;
                ?>
">
		<td class="type">
			<?php 
                mycred_types_select_from_dropdown('mycred_badge[req][' . $row . '][type]', '', $needs['type']);
                ?>
		</td>
		<td class="for">for</td>
		<td class="reference">
			<select name="mycred_badge[req][<?php 
                echo $row;
                ?>
][reference]" id=""><?php 
                foreach ($references as $ref => $label) {
                    echo '<option value="' . $ref . '"';
                    if ($needs['reference'] == $ref) {
                        echo ' selected="selected"';
                    }
                    echo '>' . $label . '</option>';
                }
                ?>
</select>
		</td>
		<td class="amount">
			<input type="text" size="8" name="mycred_badge[req][<?php 
                echo $row;
                ?>
][amount]" id="" value="<?php 
                echo $needs['amount'];
                ?>
" />
		</td>
		<td class="sum">
			<select name="mycred_badge[req][<?php 
                echo $row;
                ?>
][by]" id=""><?php 
                foreach ($sums as $sum => $label) {
                    echo '<option value="' . $sum . '"';
                    if ($needs['by'] == $sum) {
                        echo ' selected="selected"';
                    }
                    echo '>' . $label . '</option>';
                }
                ?>
</select>
		</td>
	</tr>
<?php 
            }
            ?>

	<?php 
            do_action('mycred_edit_badge_after_req', $post);
            ?>

</table>
<?php 
        }