/** * Settings Page * @since 0.1 * @version 1.3 */ public function after_general_settings() { // Settings $settings = $this->transfers; $before = $this->core->before; $after = $this->core->after; // Limits $limit = $settings['limit']['limit']; $limits = array('none' => __('No limits.', 'mycred'), 'daily' => __('Impose daily limit.', 'mycred'), 'weekly' => __('Impose weekly limit.', 'mycred')); $available_limits = apply_filters('mycred_transfer_limits', $limits, $settings); // Autofill by $autofill = $settings['autofill']; $autofills = array('user_login' => __('User Login (user_login)', 'mycred'), 'user_email' => __('User Email (user_email)', 'mycred')); $available_autofill = apply_filters('mycred_transfer_autofill_by', $autofills, $settings); if (!isset($settings['types'])) { $settings['types'] = $this->default_prefs['types']; } ?> <h4><div class="icon icon-active"></div><?php _e('Transfers', 'mycred'); ?> </h4> <div class="body" style="display:none;"> <?php if (count($this->point_types) > 1) { ?> <label class="subheader"><?php _e('Point Types', 'mycred'); ?> </label> <ol id="myCRED-transfer-logging-send"> <li> <?php mycred_types_select_from_checkboxes('mycred_pref_core[transfers][types][]', 'mycred-transfer-type', $settings['types']); ?> <span class="description"><?php _e('Select the point types that users can transfer.', 'mycred'); ?> </span> </li> </ol> <?php } else { ?> <input type="hidden" name="mycred_pref_core[transfers][types][]" value="mycred_default" /> <?php } ?> <label class="subheader"><?php _e('Log template for sending', 'mycred'); ?> </label> <ol id="myCRED-transfer-logging-send"> <li> <div class="h2"><input type="text" name="mycred_pref_core[transfers][logs][sending]" id="myCRED-transfer-log-sender" value="<?php echo esc_attr($settings['logs']['sending']); ?> " class="long" /></div> <span class="description"><?php echo $this->core->available_template_tags(array('general', 'user')); ?> </span> </li> </ol> <label class="subheader"><?php _e('Log template for receiving', 'mycred'); ?> </label> <ol id="myCRED-transfer-logging-receive"> <li> <div class="h2"><input type="text" name="mycred_pref_core[transfers][logs][receiving]" id="myCRED-transfer-log-receiver" value="<?php echo esc_attr($settings['logs']['receiving']); ?> " class="long" /></div> <span class="description"><?php echo $this->core->available_template_tags(array('general', 'user')); ?> </span> </li> </ol> <label class="subheader"><?php _e('Autofill Recipient', 'mycred'); ?> </label> <ol id="myCRED-transfer-autofill-by"> <li> <select name="mycred_pref_core[transfers][autofill]" id="myCRED-transfer-autofill"> <?php foreach ($available_autofill as $key => $label) { echo '<option value="' . $key . '"'; if ($settings['autofill'] == $key) { echo ' selected="selected"'; } echo '>' . $label . '</option>'; } ?> </select><br /> <span class="description"><?php _e('Select what user details recipients should be autofilled by.', 'mycred'); ?> </span> </li> </ol> <label class="subheader"><?php _e('Reload', 'mycred'); ?> </label> <ol id="myCRED-transfer-logging-receive"> <li> <input type="checkbox" name="mycred_pref_core[transfers][reload]" id="myCRED-transfer-reload" <?php checked($settings['reload'], 1); ?> value="1" /> <label for="myCRED-transfer-reload"><?php _e('Reload page on successful transfers.', 'mycred'); ?> </label> </li> </ol> <label class="subheader"><?php _e('Limits', 'mycred'); ?> </label> <ol id="myCRED-transfer-limits"> <?php // Loop though limits if (!empty($limits)) { foreach ($limits as $key => $description) { ?> <li> <input type="radio" name="mycred_pref_core[transfers][limit][limit]" id="myCRED-limit-<?php echo $key; ?> " <?php checked($limit, $key); ?> value="<?php echo $key; ?> " /> <label for="myCRED-limit-<?php echo $key; ?> "><?php echo $description; ?> </label> </li> <?php } } ?> <li class="empty"> </li> <li> <label for="<?php echo $this->field_id(array('limit' => 'amount')); ?> "><?php _e('Limit Amount', 'mycred'); ?> </label> <div class="h2"><?php echo $before; ?> <input type="text" name="<?php echo $this->field_name(array('limit' => 'amount')); ?> " id="<?php echo $this->field_id(array('limit' => 'amount')); ?> " value="<?php echo $this->core->number($settings['limit']['amount']); ?> " size="8" /> <?php echo $after; ?> </div> </li> </ol> <label class="subheader"><?php _e('Form Templates', 'mycred'); ?> </label> <ol id="myCRED-transfer-form-templates"> <li> <label for="<?php echo $this->field_id(array('templates' => 'login')); ?> "><?php _e('Not logged in Template', 'mycred'); ?> </label> <div class="h2"><input type="text" name="<?php echo $this->field_name(array('templates' => 'login')); ?> " id="<?php echo $this->field_id(array('templates' => 'login')); ?> " value="<?php echo esc_attr($settings['templates']['login']); ?> " class="long" /></div> <span class="description"><?php _e('Text to show when users are not logged in. Leave empty to hide. No HTML elements allowed!', 'mycred'); ?> </span> </li> <li class="empty"> </li> <li> <label for="<?php echo $this->field_id(array('templates' => 'balance')); ?> "><?php _e('Balance Template', 'mycred'); ?> </label> <div class="h2"><input type="text" name="<?php echo $this->field_name(array('templates' => 'balance')); ?> " id="<?php echo $this->field_id(array('templates' => 'balance')); ?> " value="<?php echo esc_attr($settings['templates']['balance']); ?> " class="long" /></div> <span class="description"><?php _e('Template to use when displaying the users balance (if included). No HTML elements allowed!', 'mycred'); ?> </span> </li> <li class="empty"> </li> <li> <label for="<?php echo $this->field_id(array('templates' => 'limit')); ?> "><?php _e('Limit Template', 'mycred'); ?> </label> <div class="h2"><input type="text" name="<?php echo $this->field_name(array('templates' => 'limit')); ?> " id="<?php echo $this->field_id(array('templates' => 'limit')); ?> " value="<?php echo esc_attr($settings['templates']['limit']); ?> " class="long" /></div> <span class="description"><?php _e('Template to use when displaying limits (if used). No HTML elements allowed!', 'mycred'); ?> </span> </li> <li class="empty"> </li> <li> <label for="<?php echo $this->field_id(array('templates' => 'button')); ?> "><?php _e('Button Template', 'mycred'); ?> </label> <div class="h2"><input type="text" name="<?php echo $this->field_name(array('templates' => 'button')); ?> " id="<?php echo $this->field_id(array('templates' => 'button')); ?> " value="<?php echo esc_attr($settings['templates']['button']); ?> " class="medium" /></div> <span class="description"><?php _e('Send Transfer button template. No HTML elements allowed!', 'mycred'); ?> </span> </li> </ol> <label class="subheader"><?php _e('Error Messages', 'mycred'); ?> </label> <ol id="myCRED-transfer-form-errors"> <li> <label for="<?php echo $this->field_id(array('errors' => 'low')); ?> "><?php _e('Balance to low to send.', 'mycred'); ?> </label> <div class="h2"><input type="text" name="<?php echo $this->field_name(array('errors' => 'low')); ?> " id="<?php echo $this->field_id(array('errors' => 'low')); ?> " value="<?php echo esc_attr($settings['errors']['low']); ?> " class="long" /></div> <span class="description"><?php _e('Text to show when a users balance is to low for transfers. Leave empty to hide. No HTML elements allowed!', 'mycred'); ?> </span> </li> <li class="empty"> </li> <li> <label for="<?php echo $this->field_id(array('errors' => 'over')); ?> "><?php _e('Transfer Limit Reached.', 'mycred'); ?> </label> <div class="h2"><input type="text" name="<?php echo $this->field_name(array('errors' => 'over')); ?> " id="<?php echo $this->field_id(array('errors' => 'over')); ?> " value="<?php echo esc_attr($settings['errors']['over']); ?> " class="long" /></div> <span class="description"><?php _e('Text to show when a user has reached their transfer limit (if used). Leave empty to hide. No HTML elements allowed!', 'mycred'); ?> </span> </li> </ol> </div> <?php }
/** * Add to General Settings * @since 0.1 * @version 1.1 */ public function after_general_settings() { // Since we are both registering our own settings and want to hook into // the core settings, we need to define our "defaults" here. $defaults = array('minimum' => 1, 'types' => array('mycred_default'), 'exchange' => 1, 'log' => '%plural% purchase', 'login' => __('Please login to purchase %_plural%', 'mycred'), 'custom_log' => 0, 'thankyou' => array('use' => 'page', 'custom' => '', 'page' => ''), 'cancelled' => array('use' => 'custom', 'custom' => '', 'page' => ''), 'gifting' => array('members' => 1, 'authors' => 1, 'log' => __('Gift purchase from %display_name%.', 'mycred'))); if (isset($this->core->buy_creds)) { $buy_creds = $this->core->buy_creds; } else { $buy_creds = $defaults; } $thankyou_use = $buy_creds['thankyou']['use']; $cancelled_use = $buy_creds['cancelled']['use']; ?> <h4><div class="icon icon-active"></div><strong>buy</strong>CRED</h4> <div class="body" style="display:none;"> <label class="subheader"><?php echo $this->core->template_tags_general(__('Minimum %plural%', 'mycred')); ?> </label> <ol id="mycred-buy-creds-minimum-amount"> <li> <div class="h2"><input type="text" name="mycred_pref_core[buy_creds][minimum]" id="<?php echo $this->field_id('minimum'); ?> " value="<?php echo $buy_creds['minimum']; ?> " size="5" /></div> <span class="description"><?php echo $this->core->template_tags_general(__('Minimum amount of %plural% a user must purchase. Will default to 1.', 'mycred')); ?> </span> </li> </ol> <?php if (count($this->point_types) > 1) { ?> <label class="subheader"><?php _e('Point Types', 'mycred'); ?> </label> <ol id="mycred-buy-creds-type"> <li> <span class="description"><?php _e('Select the point types that users can buy. You must select at least one!', 'mycred'); ?> </span> </li> <li> <?php mycred_types_select_from_checkboxes('mycred_pref_core[buy_creds][types][]', $this->field_id('types'), $buy_creds['types']); ?> </li> </ol> <?php } else { ?> <input type="hidden" name="mycred_pref_core[buy_creds][types][]" value="mycred_default" /> <?php } ?> <label class="subheader" for="<?php echo $this->field_id('login'); ?> "><?php _e('Login Template', 'mycred'); ?> </label> <ol id="mycred-buy-creds-default-log"> <li> <input type="text" name="mycred_pref_core[buy_creds][login]" id="<?php echo $this->field_id('login'); ?> " class="large-text code" value="<?php echo esc_attr($buy_creds['login']); ?> " /> <span class="description"><?php _e('Content to show when a user is not logged in.', 'mycred'); ?> </span> </li> </ol> <label class="subheader" for="<?php echo $this->field_id('log'); ?> "><?php _e('Log Template', 'mycred'); ?> </label> <ol id="mycred-buy-creds-default-log"> <li> <div class="h2"><input type="text" name="mycred_pref_core[buy_creds][log]" id="<?php echo $this->field_id('log'); ?> " value="<?php echo $buy_creds['log']; ?> " class="long" /></div> <span class="description"><?php echo $this->core->available_template_tags(array('general'), '%gateway%'); ?> </span> </li> </ol> <label class="subheader"><?php _e('Thank You Page', 'mycred'); ?> </label> <ol id="mycred-buy-creds-thankyou-page"> <li class="option"> <input type="radio" name="mycred_pref_core[buy_creds][thankyou][use]" <?php checked($thankyou_use, 'custom'); ?> id="<?php echo $this->field_id(array('thankyou' => 'use')); ?> -custom" value="custom" /> <label for="<?php echo $this->field_id(array('thankyou' => 'custom')); ?> "><?php _e('Custom URL', 'mycred'); ?> </label><br /> <div class="h2"><?php echo get_bloginfo('url') . '/'; ?> <input type="text" name="mycred_pref_core[buy_creds][thankyou][custom]" id="<?php echo $this->field_id(array('thankyou' => 'custom')); ?> " value="<?php echo $buy_creds['thankyou']['custom']; ?> " /></div> </li> <li class="empty"> </li> <li class="option"> <input type="radio" name="mycred_pref_core[buy_creds][thankyou][use]" <?php checked($thankyou_use, 'page'); ?> id="<?php echo $this->field_id(array('thankyou' => 'use')); ?> -page" value="page" /> <label for="mycred-buy-creds-thankyou-use-page"><?php _e('Page', 'mycred'); ?> </label><br /> <?php // Thank you page dropdown $thankyou_args = array('name' => 'mycred_pref_core[buy_creds][thankyou][page]', 'id' => $this->field_id(array('thankyou' => 'page')) . '-id', 'selected' => $buy_creds['thankyou']['page'], 'show_option_none' => __('Select', 'mycred')); wp_dropdown_pages($thankyou_args); ?> </li> </ol> <label class="subheader"><?php _e('Cancellation Page', 'mycred'); ?> </label> <ol id="mycred-buy-creds-cancel-page"> <li class="option"> <input type="radio" name="mycred_pref_core[buy_creds][cancelled][use]" <?php checked($cancelled_use, 'custom'); ?> id="<?php echo $this->field_id(array('cancelled' => 'custom')); ?> " value="custom" /> <label for="<?php echo $this->field_id(array('cancelled' => 'custom')); ?> "><?php _e('Custom URL', 'mycred'); ?> </label><br /> <div class="h2"><?php echo get_bloginfo('url') . '/'; ?> <input type="text" name="mycred_pref_core[buy_creds][cancelled][custom]" id="mycred-buy-creds-cancelled-custom-url" value="<?php echo $buy_creds['cancelled']['custom']; ?> " /></div> </li> <li class="empty"> </li> <li class="option"> <input type="radio" name="mycred_pref_core[buy_creds][cancelled][use]" <?php checked($cancelled_use, 'page'); ?> id="<?php echo $this->field_id(array('cancelled' => 'use')); ?> -page" value="page" /> <label for="<?php echo $this->field_id(array('cancelled' => 'use')); ?> -page"><?php _e('Page', 'mycred'); ?> </label><br /> <?php // Cancelled page dropdown $cancelled_args = array('name' => 'mycred_pref_core[buy_creds][cancelled][page]', 'id' => $this->field_id(array('cancelled' => 'page')) . '-id', 'selected' => $buy_creds['cancelled']['page'], 'show_option_none' => __('Select', 'mycred')); wp_dropdown_pages($cancelled_args); ?> </li> </ol> <label class="subheader"><?php _e('Purchase Log', 'mycred'); ?> </label> <ol id="mycred-buy-creds-seperate-log"> <li><input type="checkbox" name="mycred_pref_core[buy_creds][custom_log]" id="<?php echo $this->field_id('custom_log'); ?> "<?php checked($buy_creds['custom_log'], 1); ?> value="1" /><label for="<?php echo $this->field_id('custom_log'); ?> "><?php echo $this->core->template_tags_general(__('Show seperate log for %_plural% purchases.', 'mycred')); ?> </label></li> </ol> <label class="subheader"><?php _e('Gifting', 'mycred'); ?> </label> <ol id="mycred-buy-creds-gifting"> <li><input type="checkbox" name="mycred_pref_core[buy_creds][gifting][members]" id="<?php echo $this->field_id(array('gifting' => 'members')); ?> "<?php checked($buy_creds['gifting']['members'], 1); ?> value="1" /><label for="<?php echo $this->field_id(array('gifting' => 'members')); ?> "><?php echo $this->core->template_tags_general(__('Allow users to buy %_plural% for other users.', 'mycred')); ?> </label></li> <li><input type="checkbox" name="mycred_pref_core[buy_creds][gifting][authors]" id="<?php echo $this->field_id(array('gifting' => 'authors')); ?> "<?php checked($buy_creds['gifting']['authors'], 1); ?> value="1" /><label for="<?php echo $this->field_id(array('gifting' => 'authors')); ?> "><?php echo $this->core->template_tags_general(__('Allow users to buy %_plural% for content authors.', 'mycred')); ?> </label></li> <li class="empty"> </li> <li> <label for="<?php echo $this->field_id(array('gifting' => 'log')); ?> "><?php _e('Log Template', 'mycred'); ?> </label> <div class="h2"><input type="text" name="mycred_pref_core[buy_creds][gifting][log]" id="<?php echo $this->field_id(array('gifting' => 'log')); ?> " value="<?php echo $buy_creds['gifting']['log']; ?> " class="long" /></div> <span class="description"><?php echo $this->core->available_template_tags(array('general', 'user')); ?> </span> </li> </ol> <label class="subheader"><?php _e('Available Shortcodes', 'mycred'); ?> </label> <ol id="mycred-buy-creds-shortcodes"> <li> <a href="http://codex.mycred.me/shortcodes/mycred_buy/" target="_blank">[mycred_buy]</a> , <a href="http://codex.mycred.me/shortcodes/mycred_buy_form/" target="_blank">[mycred_buy_form]</a> , <a href="http://codex.mycred.me/shortcodes/mycred_buy_pending/" target="_blank">[mycred_buy_pending]</a> </li> </ol> </div> <?php }
/** * Outputs the options form on admin */ function form($instance) { $mycred = mycred(); // Defaults $title = isset($instance['title']) ? esc_attr($instance['title']) : __('My Wallet', 'mycred'); $types = isset($instance['types']) ? $instance['types'] : array(); $row_template = isset($instance['row']) ? $instance['row'] : '%label%: %cred_f%'; $show_visitors = isset($instance['show_visitors']) ? $instance['show_visitors'] : 0; $message = isset($instance['message']) ? esc_attr($instance['message']) : __('<a href="%login_url_here%">Login</a> to view your balance.', 'mycred'); ?> <!-- Widget Options --> <p class="myCRED-widget-field"> <label for="<?php echo esc_attr($this->get_field_id('title')); ?> "><?php _e('Title', 'mycred'); ?> :</label> <input 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); ?> " class="widefat" /> </p> <!-- Point Type --> <p class="myCRED-widget-field"> <label for="<?php echo esc_attr($this->get_field_id('types')); ?> "><?php _e('Point Types', 'mycred'); ?> :</label><br /> <?php mycred_types_select_from_checkboxes($this->get_field_name('types') . '[]', $this->get_field_id('types'), $types); ?> </p> <!-- Row layout --> <p class="myCRED-widget-field"> <label for="<?php echo esc_attr($this->get_field_id('row')); ?> "><?php _e('Row Layout', 'mycred'); ?> :</label> <input id="<?php echo esc_attr($this->get_field_id('row')); ?> " name="<?php echo esc_attr($this->get_field_name('row')); ?> " type="text" value="<?php echo esc_attr($row_template); ?> " class="widefat" /><br /> <small><?php echo $mycred->available_template_tags(array('general', 'amount')); ?> </small> </p> <!-- Show to Visitors --> <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('Show message when not logged in', 'mycred'); ?> </label><br /> <label for="<?php echo esc_attr($this->get_field_id('message')); ?> "><?php _e('Message', 'mycred'); ?> :</label><br /> <textarea class="widefat" id="<?php echo esc_attr($this->get_field_id('message')); ?> " name="<?php echo esc_attr($this->get_field_name('message')); ?> "><?php echo $message; ?> </textarea><br /> <small><?php echo $mycred->available_template_tags(array('general', 'amount')); ?> </small> </p> <?php }