WordPress.org

Support

Support » How-To and Troubleshooting » How plugings are parsed?

How plugings are parsed?

  • Hi all

    Trying to understand the parsing processes of plugins, please help me?

    It seems to me that all “plugin code” is parsed at every page/post/backend request, is that correct?

    I noticed this when building an backed plugin that created warnings in the front-end, that confuses me. I want my back-end plug code to run, yes in the backend.

    Or if I want a plugin on the frontpage, does all the code get parsed on pages and other post_types?

    all the best // Johannes

Viewing 4 replies - 1 through 4 (of 4 total)
  • have you tried adding a conditionals like:

    if( is_admin() ) {
      // run some admin only plugin code here
    }

    or

    if( get_post_type() == 'book' ) {
      // run some 'book' post type code here
    }

    Hi jkovis, and thank you for the reply!

    Yes, that is good thinking, but does that mean that the code wont get parsed? I guess no?

    That means that the methods/functions inside that block will not be executed? The php-file will still get loaded at every request, or do I miss something important?

    If (for example) my codebase get large I rather load only the files I need to execute the things I want.

    Please lead me to the correct way 🙂

    regards // Johannes

    Yes, from my understanding the Plugin file will still get loaded but once it hits the conditional it will either run/not run depending on the condition (i.e. will be ignored).

    Say you only wanted a block of code to be parsed if it is in the admin section of WordPress then you could use something like:

    if( is_admin() ) {
      // run some admin only plugin code here
    }

    as jkovis pointed out.

    ok, thank you both!

    regards // johannes

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How plugings are parsed?’ is closed to new replies.
Skip to toolbar