Guest User

Untitled

a guest
Jul 12th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.99 KB | None | 0 0
  1. class My_Custom_Control_Class extends WP_Customize_Control {
  2.        
  3.         public $type    =   'my-custom-control';
  4.        
  5. /*
  6.         public function slide_args( $args ) {
  7.            
  8.             $attachment =   get_post( $id );
  9.            
  10.             $image          =   $attachment->guid;
  11.             $url            =   get_post_meta( $id, 'rtslider_link', true );
  12.             $cta            =   get_post_meta( $id, 'cta_button', true );
  13.             $title          =   $attachment->post_title;
  14.             $description    =   $attachment->post_content;
  15.            
  16.             return $args;
  17.         }
  18. */
  19.        
  20.         public function render_content() {
  21.             ?>
  22.             <div class="slider-container">
  23.                 <?php if ( $this->label) { ?>
  24.                     <span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
  25.                 <?php } ?>
  26.                
  27.                 <?php if($this->description){ ?>
  28.                     <span class="description customize-control-description">
  29.                         <?php echo wp_kses_post($this->description); ?>
  30.                     </span>
  31.                 <?php } ?>
  32.                
  33.                 <div class="slide_thumbs">
  34.                    
  35.                         <?php
  36.                            
  37.                                 $ids    =   explode( ',', $this->value() );
  38.                                 foreach ( $ids as $attachment_id ) {
  39.                                     if ($attachment_id  != '' ) :
  40.                                        
  41.                                         $edit_fields    =   get_attachment_fields_to_edit( get_post( $attachment_id ) );
  42.                                        
  43.                                         $img = wp_get_attachment_image_src( $attachment_id, 'large' ); ?>
  44.                                         <div class="slide-image">
  45.                                             <img src=" <?php echo esc_url( $img[0] ); ?> " data-id=" <?php echo $attachment_id ?> ">
  46.                                             <div class="slide-title">
  47.                                                 <h3>
  48.                                                     <?php echo $edit_fields['post_title']['label']; ?>
  49.                                                 </h3>
  50.                                                 <?php echo $edit_fields['post_title']['html']; ?>
  51.                                             </div>
  52.                                             <div class="slide-description">
  53.                                                 <h3>
  54.                                                     <?php echo $edit_fields['post_content']['label']; ?>
  55.                                                 </h3>
  56.                                                 <?php echo $edit_fields['post_content']['html']; ?>
  57.                                             </div>
  58.                                             <div class="slide-url">
  59.                                                 <h3>
  60.                                                     <?php echo $edit_fields['rtslider_link']['label']; ?>
  61.                                                 </h3>
  62.                                                 <?php echo $edit_fields['rtslider_link']['html']; ?>
  63.                                             </div>
  64.                                             <div class="slide-url">
  65.                                                 <h3>
  66.                                                     <?php echo $edit_fields['cta_button']['label']; ?>
  67.                                                 </h3>
  68.                                                 <?php echo $edit_fields['cta_button']['html']; ?>
  69.                                             </div>
  70.                                            
  71.                                            
  72.                                             <button type="button" class="button remove_slide_button">Remove Slide</button>
  73.                                         </div>
  74.                                     <?php endif;
  75.                                 }
  76.                         ?>
  77.                        
  78.                     </div>
  79.                    
  80.                     <button type="button" class="button button-primary add_slide_button">Add Slide</button>
  81.                     <button type="button" class="button button-primary reset_slide_button">Reset</button>
  82.                    
  83.                     <input type="hidden" class="slide_values" <?php echo esc_attr($this->link()) ?> value="<?php echo esc_attr( $this->value() ); ?>">
  84.             </div>
  85.             <?php
  86.         }
  87.     }
Add Comment
Please, Sign In to add comment