Advertisement
shmilon

slider shortcode

Mar 28th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.55 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: Seo Toolkit
  5.  
  6. */
  7.  
  8.  
  9. /**
  10.  * Enqueue plugin style-file
  11.  */
  12. function seo_toolkit_scripts() {
  13.     // Respects SSL, Style.css is relative to the current file
  14.     wp_register_style( 'seo-testimonials', plugins_url('/assets/css/testimonials.css', __FILE__) );
  15.     wp_register_style( 'bootstrap', plugins_url('/assets/css/bootstrap.min.css', __FILE__) );
  16.     wp_register_script( 'seo-slider-js', plugins_url('/assets/js/slider.js', __FILE__) );
  17.  
  18. }
  19. add_action('init','seo_toolkit_scripts');
  20.    
  21.        
  22.    
  23.     add_action( 'init', 'seo_testimonial_post_type' );
  24.     function seo_testimonial_post_type() {
  25.         register_post_type( 'Testimonial',
  26.         array(
  27.           'labels' => array(
  28.             'name' => __( ' Testimonials' ),
  29.             'singular_name' => __( 'Testimonial' )
  30.           ),
  31.           'public' => true,
  32.           'supports' => 'editor',
  33.           'has_archive' => true,
  34.         )
  35.       );
  36.     }
  37.    
  38.    
  39.  
  40. function seo_toolkit($atts, $content = null){
  41.     extract(shortcode_atts(
  42.     array(
  43.    
  44.         'img_url_link' => '',
  45.    
  46.     ),$atts
  47.    
  48.     ));
  49.    
  50.         //$img_url = plugins_url('/images/slider1.jpg', __FILE__);
  51.    
  52.     $list = '<div id="myCarousel" class="carousel slide">
  53.                <ol class="carousel-indicators">
  54.                    <li data-target="#myCarousel" data-slide-to="1"></li>
  55.                    <li data-target="#myCarousel" data-slide-to="2"></li>
  56.                </ol>
  57.            <div class="carousel-inner">
  58.                <div class="item active">';  
  59.  
  60.  
  61.  
  62.     $list .=  '<div class="fill" style="background-image:url('.<?php plugins_url($img_url_link, __FILE__); ?>'.');'></div>';
  63.  
  64.  
  65.  
  66.  
  67.     $list .=   '<div class="carousel-caption">
  68.                     <h2>Caption 1</h2>
  69.                 </div>
  70.                 </div>
  71.             <div class="item">';
  72.  
  73.     $list .=  '<div class="fill" style="background-image:url();"></div>
  74.                <div class="carousel-caption">
  75.                     <h2>Caption 2</h2>
  76.                 </div>
  77.             </div>
  78.     <div class="item">';  
  79.  
  80.     $list .= '<div class="fill" style="background-image:url();"></div>';
  81.  
  82.     $list .=  '<div class="carousel-caption">
  83.                     <h2>Caption 3</h2>
  84.                 </div>
  85.             </div>
  86.         </div>
  87.         <a class="left carousel-control" href="#myCarousel" data-slide="prev">
  88.             <span class="icon-prev"></span>
  89.         </a>
  90.         <a class="right carousel-control" href="#myCarousel" data-slide="next">
  91.             <span class="icon-next"></span>
  92.         </a>
  93.     </div>';
  94.  
  95.  
  96.  
  97.     return $list;
  98. }
  99.     add_shortcode('slider','seo_toolkit');
  100.  
  101.  
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement