Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Add Toggle Switch to Display Posts Shortcode plugin
- *
- */
- function fm_dps_toggle_switch( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) {
- if( empty( $atts['include_toggle'] ) || true !== filter_var( $atts['include_toggle'], FILTER_VALIDATE_BOOLEAN ) )
- return $output;
- if( ! current_user_can( 'edit_post', get_the_ID() ) )
- return $output;
- $toggle_switch = ' <a class="toggle-switch" href="' . INSERT CODE HERE; . '">Label</a>';
- $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $author . $category_display_text . $excerpt . $content . $toggle_switch . '</' . $inner_wrapper . '>';
- return $output;
- }
- add_filter( 'display_posts_shortcode_output', 'fm_dps_toggle_switch', 10, 11 );
- wp_update_post( array( 'ID' => get_the_ID(), 'post_status' => 'private' ));
- wp_update_post( array( 'ID' => get_the_ID(), 'post_status' => 'public' ));
Add Comment
Please, Sign In to add comment