示例#1
0
 function mycred_render_rank_list($atts, $content = NULL)
 {
     extract(shortcode_atts(array('order' => 'DESC', 'wrap' => 'div'), $atts));
     if ($content === NULL || empty($content)) {
         $content = '<p>%rank% <span class="min">%min%</span> - <span class="max">%max%</span></p>';
     }
     $mycred = mycred();
     $output = '';
     $all_ranks = mycred_get_ranks('publish', '-1', $order);
     if (!empty($all_ranks)) {
         $output .= '<' . $wrap . ' class="mycred-rank-list">';
         $content = apply_filters('mycred_rank_list', $content, $atts, $mycred);
         foreach ($all_ranks as $rank_id => $rank) {
             $row = str_replace('%rank%', $rank->post_title, $content);
             $row = str_replace('%rank_logo%', mycred_get_rank_logo($rank_id), $row);
             $row = str_replace('%min%', get_post_meta($rank_id, 'mycred_rank_min', true), $row);
             $row = str_replace('%max%', get_post_meta($rank_id, 'mycred_rank_max', true), $row);
             $row = str_replace('%count%', count(mycred_get_users_of_rank($rank_id)), $row);
             $row = $mycred->template_tags_general($row);
             $output .= $row . "\n";
         }
         $output .= '</' . $wrap . '>';
     }
     return $output;
 }
示例#2
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 
        }
示例#3
0
        /**
         * Rank Settings Metabox
         * @since 1.1
         * @version 1.0
         */
        public function rank_settings($post)
        {
            $mycred = mycred();
            $min = get_post_meta($post->ID, 'mycred_rank_min', true);
            $max = get_post_meta($post->ID, 'mycred_rank_max', true);
            ?>

<input type="hidden" name="mycred_rank[token]" value="<?php 
            echo wp_create_nonce('mycred-edit-rank');
            ?>
" />
<div style="display:block;float:none;clear:both;">
	<div style="display:block;width:50%;margin:0;padding:0;float:left;">
		<p>
			<?php 
            echo $mycred->template_tags_general(__('Minimum %plural% to reach this rank', 'mycred'));
            ?>
:<br />
			<input type="text" name="mycred_rank[min]" id="mycred-rank-min" value="<?php 
            echo $min;
            ?>
" />
		</p>
		<p>
			<?php 
            echo $mycred->template_tags_general(__('Maximum %plural% to be included in this rank', 'mycred'));
            ?>
:<br />
			<input type="text" name="mycred_rank[max]" id="mycred-rank-max" value="<?php 
            echo $max;
            ?>
" />
		</p>
		<?php 
            do_action('mycred_rank_after_req', $post, $this->core);
            ?>

	</div>
	<div style="display:block;width:50%;margin:0;padding:0;float:left;">
		<p><?php 
            _e('All Published Ranks', 'mycred');
            ?>
:</p>
<?php 
            $all = mycred_get_ranks();
            if (!empty($all)) {
                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 '<p><strong style="display:inline-block;width:40%;">' . $rank->post_title . '</strong> ' . $_min . ' - ' . $_max . '</p>';
                }
            } else {
                echo '<p>' . __('No Ranks found', 'mycred') . '.</p>';
            }
            ?>
	</div>
	<div class="clear">&nbsp;</div>
</div>
<?php 
        }