0

Hi I have a php script that makes liberal use of

/* */

//

my question is will that conflict with wordpress since the wordpress engine often reads variables inside those things?

The reason I ask is that to make a custom template, you just modify some text inside the documentation in the first part of the script

/** * Template Name: Full Width Page * * @package WordPress * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 */

I worry my documentation inside my script could cause wordpress to do unexpected actions or worse create a security vulnerability

3
  • 2
    You need WAY more detail in your question. Please elaborate. Commented Sep 27, 2017 at 14:56
  • 3
    WordPress is written in PHP, it's not a fork or alternative to PHP. it doesn't do any PHP file parsing as your question suggests
    – Tom J Nowell
    Commented Sep 27, 2017 at 15:01
  • I updated it, i mean wordpress does read inside the annotation and documentation right, otherwise how would they see the template name etc.
    – john doe
    Commented Sep 27, 2017 at 15:30

1 Answer 1

5

I believe the practice of including additional data within PHP code comments is typically called annotations.

WordPress core makes no use of annotations technique for any code runtime tasks and doesn't have an API for such purpose.

In number of context it will read file headers to extract meta data, such as main plugin files and some theme templates. As long as you follow documentation and include necessary elements for those I doubt you are going to have any trouble with them.

5
  • 3
    this is mostly correct but have few exceptions relating to plugin and page template headers Commented Sep 27, 2017 at 15:14
  • Hm hm... You are right, but I am not confident is that falls within "annotations" ? I think it's commonly associated with more technical stuff like controlling dependency injection. I'll amend the answer anyway.
    – Rarst
    Commented Sep 27, 2017 at 15:18
  • Probably the original was correct for what the OP asks, but people might get wrong impression that they can put "whatever" everywhere Commented Sep 27, 2017 at 15:27
  • okay thanks, so as long as the annotations/documentation isn't in the first part of the template plugin files, i should be okay right?
    – john doe
    Commented Sep 27, 2017 at 15:33
  • @johndoe yes, outside of file headers you are completely fine :) I am also pretty sure you are unlikely to introduce any security issues since headers WP cares about should be whitelisted and escaped for output.
    – Rarst
    Commented Sep 27, 2017 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.