105 lines
2.8 KiB
PHP
105 lines
2.8 KiB
PHP
<?php
|
|
/*
|
|
Plugin Name: UserGalaxy
|
|
Description: A special page with a list of users
|
|
Version: 1.0.0
|
|
Author: Alexander Yakovlev
|
|
Text Domain: usergalaxy
|
|
*/
|
|
|
|
function imbb_posttype(){
|
|
register_post_type( 'team',
|
|
array(
|
|
'labels' => array(
|
|
'name' => __( 'Team' ),
|
|
'singular_name' => __( 'Employee' )
|
|
),
|
|
'public' => true,
|
|
'has_archive' => false,
|
|
'rewrite' => array(
|
|
'slug' => 'team'
|
|
),
|
|
)
|
|
);
|
|
}
|
|
|
|
function imbb_register_metabox() {
|
|
$prefix = 'imbb_';
|
|
$cmb = new_cmb2_box( array(
|
|
'id' => $prefix . 'metabox',
|
|
'title' => esc_html__( 'Options', 'cmb2' ),
|
|
'object_types' => array( 'team', ), // Post type
|
|
));
|
|
$cmb->add_field( array(
|
|
'name' => esc_html__( 'Designation', 'cmb2' ),
|
|
'desc' => esc_html__( 'Role in the team', 'cmb2' ),
|
|
'id' => $prefix . 'designation',
|
|
'type' => 'text_small',
|
|
));
|
|
$cmb->add_field( array(
|
|
'name' => esc_html__( 'Portrait', 'cmb2' ),
|
|
'desc' => esc_html__( 'Upload an image or enter a URL.', 'cmb2' ),
|
|
'id' => $prefix . 'image',
|
|
'type' => 'file',
|
|
) );
|
|
}
|
|
|
|
function imbb_usergalaxy() {
|
|
wp_enqueue_style( 'imbb_style', plugin_dir_url( __FILE__ ) . '/style.css' );
|
|
$query = new WP_Query(array(
|
|
'post_type' => 'team',
|
|
'post_status' => 'publish',
|
|
'posts_per_page' => -1,
|
|
));
|
|
?>
|
|
<div class="all">
|
|
<div class="container">
|
|
<div class="circles circle-1">
|
|
<?php
|
|
for ($i = 1; $i <= $query->found_posts; $i++) {
|
|
?>
|
|
<div class="small-circle small-<?php echo $i ?>"></div>
|
|
<?php
|
|
}
|
|
?>
|
|
<div class="avatars">
|
|
<?php
|
|
$i = 1;
|
|
while ($query->have_posts()) {
|
|
?>
|
|
<a href="#" id="human-<?php echo $i ?>" target="_blank" class="humans">
|
|
<img src="<?php echo get_post_meta( get_the_ID(), 'imbb_image', TRUE ) ?>" alt="<?php echo get_title() ?>">
|
|
<div class="texts box">
|
|
<?php echo $query->the_post(); ?>
|
|
<span class="name">
|
|
<?php echo get_post_meta( get_the_ID(), 'imbb_designation', TRUE ); ?>
|
|
</span>
|
|
</div>
|
|
</a>
|
|
<?php
|
|
$i++;
|
|
}
|
|
?>
|
|
<div class="circles circle-2">
|
|
<div class="circles circle-3">
|
|
<div class="circles circle-4">
|
|
<?php // <img src="images/11.jpeg" style="position:absolute; top:40%; left:40%; border-radius:50%;" /> ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
wp_reset_query();
|
|
}
|
|
function imbb_scripts() {
|
|
wp_register_script( 'imbb_script', plugin_dir_url( __FILE__ ) . '/script.js', array('jquery'), '1.1.0', true );
|
|
wp_enqueue_script( 'imbb_script' );
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'imbb_scripts' );
|
|
add_shortcode('usergalaxy', 'imbb_usergalaxy');
|
|
add_action( 'init', 'imbb_posttype' );
|
|
add_action( 'cmb2_admin_init', 'imbb_register_metabox' );
|