Last active
September 23, 2016 22:04
-
-
Save sxidsvit/b0f7745bebf8f4b496fe to your computer and use it in GitHub Desktop.
Код галереи, созданный в модуле Pinegrow Blocks WP (lesson 10).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <section class="content-block gallery-1 gallery-1-1"> | |
| <?php | |
| $gallery = blocks_get_gallery( get_theme_mod( 'blocks_gallery_1_1_source' ) ); | |
| ?> | |
| <div class="container"> | |
| <div class="underlined-title"> | |
| <h1><?php echo get_theme_mod( 'blocks_gallery_1_1_title', __( 'A selection of our work', 'blockswpdemo' ) ); ?></h1> | |
| <hr> | |
| <h2><?php echo get_theme_mod( 'blocks_gallery_1_1_subtitle', __( 'Hand-picked just for you', 'blockswpdemo' ) ); ?></h2> | |
| </div> | |
| <ul class="filter"> | |
| <li class="active"> | |
| <a href="#" data-filter="*"> | |
| <?php _e( 'All', 'blockswpdemo' ); ?> | |
| </a> | |
| </li> | |
| <?php foreach($gallery['tags'] as $tag_slug => $tag_name) : ?> | |
| <li> | |
| <a href="#" data-filter="<?php echo '.'.$tag_slug ?>"> | |
| <?php echo $tag_name ?> | |
| </a> | |
| </li> | |
| <?php endforeach; ?> | |
| </ul> | |
| <!-- /.gallery-filter --> | |
| <div class="row"> | |
| <div class="isotope-gallery-container"> | |
| <?php foreach($gallery['images'] as $image) : ?> | |
| <div class="col-md-3 col-sm-6 col-xs-12 gallery-item-wrapper <?php echo $image['tags_string'] ?>"> | |
| <?php | |
| //Press CMD+H to edit. Your PHP code comes here... | |
| ?> | |
| <div class="gallery-item"> | |
| <div class="gallery-thumb"> | |
| <img src="<?php echo $image['thumbnail'][0] ?>" class="img-responsive" alt="<?php echo $image['thumbnail']['alt'] ?>"> | |
| <div class="image-overlay"></div> | |
| <a href="<?php echo $image['image'][0] ?>" class="gallery-zoom" alt="<?php echo $image['alt'] ?>"><i class="fa fa-eye" alt="This is the title"></i></a> | |
| <a href="<?php echo $image['link'] ?>" class="gallery-link" target="_blank"><i class="fa fa-link"></i></a> | |
| </div> | |
| <div class="gallery-details"> | |
| <h5><?php echo $image['title'] ?></h5> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endforeach; ?> | |
| <!-- /.gallery-item-wrapper --> | |
| <!-- /.gallery-item-wrapper --> | |
| <!-- /.gallery-item-wrapper --> | |
| <!-- /.gallery-item-wrapper --> | |
| <!-- /.gallery-item-wrapper --> | |
| <!-- /.gallery-item-wrapper --> | |
| <!-- /.gallery-item-wrapper --> | |
| </div> | |
| <!-- /.isotope-gallery-container --> | |
| </div> | |
| <!-- /.row --> | |
| </div> | |
| <!-- /.container --> | |
| </section> | |
| <!-- Functions.php section Customizer Controls --> | |
| $wp_customize->add_section( 'blocks_gallery_1_1', array( | |
| 'title' => __( 'Галерея', 'blockswpdemo' ) | |
| )); | |
| $wp_customize->add_setting( 'blocks_gallery_1_1_source', array( | |
| 'type' => 'theme_mod' | |
| )); | |
| $wp_customize->add_control( new WP_BlocksContentDropdown_Customize_Control( $wp_customize, 'blocks_gallery_1_1_source', array( | |
| 'label' => 'Источник контента (пост с галлереей)', | |
| 'type' => 'custom', | |
| 'section' => 'blocks_gallery_1_1' | |
| ) ) ); | |
| $wp_customize->add_setting( 'blocks_gallery_1_1_title', array( | |
| 'type' => 'theme_mod', | |
| 'default' => 'A selection of our work' | |
| )); | |
| $wp_customize->add_control( 'blocks_gallery_1_1_title', array( | |
| 'label' => __( 'Заголовок галереи', 'blockswpdemo' ), | |
| 'type' => 'text', | |
| 'section' => 'blocks_gallery_1_1' | |
| )); | |
| $wp_customize->add_setting( 'blocks_gallery_1_1_subtitle', array( | |
| 'type' => 'theme_mod', | |
| 'default' => 'Hand-picked just for you' | |
| )); | |
| $wp_customize->add_control( 'blocks_gallery_1_1_subtitle', array( | |
| 'label' => __( 'Подзаголовок ', 'blockswpdemo' ), | |
| 'type' => 'textarea', | |
| 'section' => 'blocks_gallery_1_1' | |
| )); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ключевой момент - авторская функция blocks_get_gallery(), которая позволяет получит все параметры и изображений, формирующих галерею.