Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * [cds_add_to_footer description]
- * DEBUG - output to footer only for logged-in admins
- * @return [type] [description]
- */
- function cds_add_to_footer(){
- // Don't display for non-admin users
- if ( ! current_user_can( 'manage_options' ) )
- return;
- // wp globals
- // global $wp_rewrite;
- // global $post;
- //#1
- if (is_single() ) {
- global $post;
- $categories = array();
- $category_nicknames = array();
- foreach((get_the_category($post->ID)) as $category) {
- $categories[] = $category;
- // add category slug to the $category_nicknames array
- $category_nicknames[] = $category->category_nicename;
- }
- echo '<div class="cds debug" style="
- background: #f1f1f1;
- border: 3px solid black;
- position: relative;
- padding: 20px;
- ">';
- highlight_string("\n<?php\n\$categories =\n" . var_export($categories, true) . ";\n?>");
- highlight_string("\n<?php\n\$category_nicknames =\n" . var_export($category_nicknames, true) . ";\n?>");
- echo '</div><!-- /.cds.debug -->';
- }
- }
- add_action('wp_footer','cds_add_to_footer');
Add Comment
Please, Sign In to add comment