galaxy configuration

This commit is contained in:
Alexander Yakovlev 2017-06-15 15:16:46 +07:00
parent 7efaeae322
commit 1e4374736e

View file

@ -42,8 +42,26 @@ function imbb_register_metabox() {
'id' => $prefix . 'image', 'id' => $prefix . 'image',
'type' => 'file', 'type' => 'file',
) ); ) );
$cmb->add_field( array(
'name' => esc_html__( 'Level', 'cmb2' ),
'desc' => esc_html__( 'A number from 0 to 3; 0 means galaxy center, 1 means first circle; max is 3', 'cmb2' ),
'id' => $prefix . 'level',
'type' => 'text_small',
));
} }
function galaxyuser($post, $i) { ?>
<a href="#" id="human-<?php echo $i ?>" target="_blank" class="humans">
<img src="<?php echo get_post_meta( $post->ID, 'imbb_image', TRUE ) ?>" alt="<?php echo $post->post_title ?>">
<div class="texts box">
<?php echo $post->post_content; ?>
<span class="name">
<?php echo get_post_meta( $post->ID, 'imbb_designation', TRUE ); ?>
</span>
</div>
</a>
<?php
}
function imbb_usergalaxy() { function imbb_usergalaxy() {
wp_enqueue_style( 'imbb_style', plugin_dir_url( __FILE__ ) . '/style.css' ); wp_enqueue_style( 'imbb_style', plugin_dir_url( __FILE__ ) . '/style.css' );
$query = get_posts(array( $query = get_posts(array(
@ -65,25 +83,48 @@ function imbb_usergalaxy() {
<div class="avatars"> <div class="avatars">
<?php <?php
$i = 1; $i = 1;
$posts = [];
foreach ($query as $post) { foreach ($query as $post) {
?> $level = get_post_meta( $post->ID, 'imbb_level', TRUE );
<a href="#" id="human-<?php echo $i ?>" target="_blank" class="humans"> if ($level === "") {
<img src="<?php echo get_post_meta( $post->ID, 'imbb_image', TRUE ) ?>" alt="<?php echo $post->post_title ?>"> $level = 3;
<div class="texts box"> } else {
<?php echo $post->post_content; ?> $level = (int) $level;
<span class="name"> }
<?php echo get_post_meta( $post->ID, 'imbb_designation', TRUE ); ?> if (!isset($posts[$level])) {
</span> $posts[$level] = [];
</div> }
</a> $posts[$level][] = $post;
<?php }
foreach ($posts[3] as $post) {
galaxyuser($post, $i);
$i++; $i++;
} }
?> ?>
<div class="circles circle-2"> <div class="circles circle-2">
<?php if (isset($posts[2])) {
foreach ($posts[2] as $post) {
galaxyuser($post, $i);
$i++;
}
}
?>
<div class="circles circle-3"> <div class="circles circle-3">
<?php if (isset($posts[1])) {
foreach ($posts[1] as $post) {
galaxyuser($post, $i);
$i++;
}
}
?>
<div class="circles circle-4"> <div class="circles circle-4">
<img src="http://loremflickr.com/100/100" style="border-radius:50%;" /> <?php if (isset($posts[0])) {
foreach ($posts[0] as $post) {
echo '<img src="'.get_post_meta( $post->ID, 'imbb_image', TRUE ).'">';
$i++;
}
}
?>
</div> </div>
</div> </div>
</div> </div>