Guest User

Untitled

a guest
Jan 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. /**
  3. * Add Toggle Switch to Display Posts Shortcode plugin
  4. *
  5. */
  6.  
  7.  
  8. function fm_dps_toggle_switch( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) {
  9.  
  10.  
  11. if( empty( $atts['include_toggle'] ) || true !== filter_var( $atts['include_toggle'], FILTER_VALIDATE_BOOLEAN ) )
  12. return $output;
  13.  
  14.  
  15. if( ! current_user_can( 'edit_post', get_the_ID() ) )
  16. return $output;
  17.  
  18.  
  19. $toggle_switch = ' <a class="toggle-switch" href="' . INSERT CODE HERE; . '">Label</a>';
  20.  
  21.  
  22. $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $author . $category_display_text . $excerpt . $content . $toggle_switch . '</' . $inner_wrapper . '>';
  23.  
  24.  
  25. return $output;
  26. }
  27.  
  28. add_filter( 'display_posts_shortcode_output', 'fm_dps_toggle_switch', 10, 11 );
  29.  
  30. wp_update_post( array( 'ID' => get_the_ID(), 'post_status' => 'private' ));
  31.  
  32. wp_update_post( array( 'ID' => get_the_ID(), 'post_status' => 'public' ));
Add Comment
Please, Sign In to add comment