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',
'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() {
wp_enqueue_style( 'imbb_style', plugin_dir_url( __FILE__ ) . '/style.css' );
$query = get_posts(array(
@ -65,29 +83,52 @@ function imbb_usergalaxy() {
<div class="avatars">
<?php
$i = 1;
$posts = [];
foreach ($query as $post) {
?>
<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
$level = get_post_meta( $post->ID, 'imbb_level', TRUE );
if ($level === "") {
$level = 3;
} else {
$level = (int) $level;
}
if (!isset($posts[$level])) {
$posts[$level] = [];
}
$posts[$level][] = $post;
}
foreach ($posts[3] as $post) {
galaxyuser($post, $i);
$i++;
}
?>
<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-4">
<img src="http://loremflickr.com/100/100" style="border-radius:50%;" />
</div>
</div>
</div>
<?php if (isset($posts[1])) {
foreach ($posts[1] as $post) {
galaxyuser($post, $i);
$i++;
}
}
?>
<div class="circles circle-4">
<?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>
<?php