Advertisement
simbasounds

Genesis Rows Template

Jun 23rd, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.48 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'wp_enqueue_scripts', 'enqueue_backstretch' );
  4. function enqueue_backstretch() {
  5. wp_enqueue_script( 'backstretch', '/wp-content/uploads/dynamik-gen/skins/rowgen/js/backstretch.js', array( 'jquery' ), '1.0.0', true );
  6. wp_enqueue_script( 'backstretch-set', '/wp-content/uploads/dynamik-gen/skins/rowgen/js/backstretch-set.js' , array( 'jquery', 'backstretch' ), '1.0.0', true );
  7. }
  8.  
  9. // Force full width content layout setting
  10. add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
  11.  
  12. remove_action( 'genesis_loop', 'genesis_do_loop' );
  13. add_action( 'genesis_loop', 'rows_do_loop' );
  14.  
  15. // Outputs a custom loop
  16. function rows_do_loop() {
  17.  
  18. //* Localize backstretch script
  19. add_action( 'genesis_entry_header', 'rows_set_background_image', 4 );
  20. function rows_set_background_image() {
  21. global $images;
  22. global $row_ids;
  23.      if ( has_post_thumbnail() ) {
  24.           $image = array( 'src' => has_post_thumbnail() ? genesis_get_image( array( 'format' => 'url' ) ) : '' );
  25.           $images[] = $image;
  26.           $row_id = get_the_id();
  27.           $row_ids[] = ".post-".$row_id;
  28.      }
  29. }
  30.  
  31.      //* Remove the entry meta in the entry header
  32.      remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  33.      //* Remove the post meta function
  34.      remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
  35.  
  36.      $include = genesis_get_option( 'blog_cat' );
  37.      $exclude = genesis_get_option( 'blog_cat_exclude' ) ? explode( ',', str_replace( ' ', '', genesis_get_option( 'blog_cat_exclude' ) ) ) : '';
  38.      global $paged;
  39.      $query_args = wp_parse_args(
  40.            genesis_get_custom_field( 'query_args' ),
  41.            array(
  42.                 'cat'              => $include,
  43.                 'category__not_in' => $exclude,
  44.                 'showposts'        => genesis_get_option( 'blog_cat_num' ),
  45.                 'paged'            => $paged,
  46.                 'post_type'      => array( 'row' ),
  47.            )
  48.      );
  49.      genesis_custom_loop( $query_args );
  50. }
  51.  
  52. add_action( 'genesis_entry_header', 'output_cdata', 5 );
  53. function output_cdata() {
  54.      global $images;
  55.      $json_images = json_encode($images);
  56.      $params = array('images' => $json_images,);
  57.      wp_localize_script( 'backstretch-set', 'BackStretchImgs', $params );
  58.  
  59.      global $row_ids;
  60.      $json_ids = json_encode($row_ids);
  61.      $idparams = array('row_ids' => $json_ids,);
  62.      wp_localize_script( 'backstretch-set', 'BackStretchIDs', $idparams );
  63. }
  64.  
  65. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement