i created a test-plugin that outputs all the variables & their content available to access for plugins:

i picked some that could be interesting to wordpress plugin developers:

interesting filters:

“This filter runs in wp-admin when loading a post for editing

two parameters: the content and the id of the post to be edited”

https://codex.wordpress.org/Plugin_API/Filter_Reference/content_edit_pre

“Retrieve the numeric ID of the current post”

https://codex.wordpress.org/Function_Reference/get_the_ID

Output All Variables Available to a Wordperss Plugin:

==== create plugin ==== 

/WORDPRESS/wp-content/plugins/test/test.php

fill with:

<?php
/**
* Plugin Name: test
* Plugin URI: https://dwaves.de/test
* Description: MISSION: Output All Variables Available to a Wordperss Plugin
* Version: 1.0
* Author: admin@dwaves.de
* Author URI: https://dwaves.de
* License: GNU
*/

add_filter('the_content', 'myFunction');

add_filter('the_content', 'myFunction');

function myFunction() {
    echo '<pre>';
    
    // print_r($GLOBALS); // print all currently available/defined global variables
    
    print_r($GLOBALS["posts"]);    // output all posts
    $current_post_id = $GLOBALS["wp_the_query"]->current_post; // probably get current post number in posts-array
    echo $GLOBALS["posts"][$current_post_id]->post_content;     // output content for current post 
    
    echo '</pre>';
}

 ?> ==== output ====     [wp_version] => 4.2.2     [wp_db_version] => 31535     [tinymce_version] => 4109-20150505     [required_php_version] => 5.2.4     [required_mysql_version] => 5.0 [posts] => Array ( [1] => stdClass Object ( [ID] => 1 [post_author] => 1 [post_date] => 2015-06-26 09:07:07 [post_date_gmt] => 2015-06-26 09:07:07 [post_content] => Welcome to WordPress. This is your first post. Edit or delete it, then start blogging! # content of the post







My Caption







[post_title] => Hello world! # title of the post [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => hello-world [to_ping] => [pinged] => [post_modified] => 2015-06-30 15:21:12 [post_modified_gmt] => 2015-06-30 15:21:12 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/WORDPRESS/?p=1 [menu_order] => 0 [post_type] => post [post_mime_type] =>  [comment_count] => 1 # how many comments this post has
 ) [last_changed] => 0.84571400 1435678351 [wp_get_archives:53058f6b83972cfc3253e30ef06fcaa9:0.84571400 1435678351] => Array ( [0] => stdClass Object ( [year] => 2015 [month] => 6 [posts] => 1 ) ) ) [category] => Array ( [1] => stdClass Object ( [term_id] => 1  [name] => Uncategorized # what categories the current post belongs to [slug] => uncategorized [term_group] => 0 [term_taxonomy_id] => 1 [taxonomy] => category [description] => [parent] => 0 [count] => 1 [object_id] => 1 [filter] => raw ) )

...
  [wp_actions] => Array
        (
            [muplugins_loaded] => 1
            [registered_taxonomy] => 11
            [registered_post_type] => 11
            [plugins_loaded] => 1
            [sanitize_comment_cookies] => 1
            [setup_theme] => 1
            [unload_textdomain] => 1
            [load_textdomain] => 5
            [after_setup_theme] => 1
            [auth_cookie_malformed] => 1
            [auth_cookie_valid] => 1
            [set_current_user] => 1
            [init] => 1
            [widgets_init] => 1
            [register_sidebar] => 1
            [wp_register_sidebar_widget] => 14
            [wp_loaded] => 1
            [parse_request] => 1
            [send_headers] => 1
            [parse_tax_query] => 4
            [parse_query] => 2
            [pre_get_posts] => 2
            [posts_selection] => 2
            [wp] => 1
            [template_redirect] => 1
            [wp_default_scripts] => 1
            [wp_default_styles] => 1
            [admin_bar_init] => 1
            [add_admin_bar_menus] => 1
            [get_header] => 1
            [wp_head] => 1
            [wp_enqueue_scripts] => 1
            [wp_print_styles] => 1
            [wp_print_scripts] => 1
            [get_sidebar] => 1
            [dynamic_sidebar_before] => 1
            [dynamic_sidebar] => 7
            [pre_get_search_form] => 1
            [loop_start] => 2
            [the_post] => 3
            [loop_end] => 1
            [parse_comment_query] => 1
            [pre_get_comments] => 1
            [wp_meta] => 1
            [dynamic_sidebar_after] => 1
            [get_template_part_content] => 1
        )

download the complete 800KByte list: wordpress.org – Output All Variables Available to a Wordperss Plugin.txt

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin