Advertisement
Guest User

Ajax para gerar galeria

a guest
Aug 18th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. // Adiciona uma action Ajax para recuperar uma nova galeria, após a edição da meta_box
  4. add_action( 'wp_ajax_get_new_gallery', array( $this, 'wp_ajax_get_new_gallery_callback' ) );
  5.  
  6. // A função
  7. function wp_ajax_get_new_gallery_callback() {
  8.     // Checa a referência (wp_nonce)
  9.     check_ajax_referer( 'seutema-gallery-nonce', 'seutema_ajax_gallery' );
  10.  
  11.     $response = array( 'status' => 'error' );
  12.    
  13.     if ( isset( $_POST['gallery_ids'] ) ) {
  14.         $html = do_shortcode( '[gallery ids="' . $_POST['gallery_ids'] . '" columns="5" itemtag="li" icontag="div" captiontag="" link="none"]' );
  15.         $response = array(
  16.             'status' => 'ok',
  17.             'response' => $html,
  18.         );
  19.     }
  20.    
  21.     wp_send_json( $response );
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement