I’m working on my own little back end framework for future clients and I’m making a folder named “Forms” to store all of my forms for CMS interaction. Inside the forms folder I’d like to store .php files similar to wordpress style plugins that I can title in the comments code like wp does… ie
/*
Plugin Name: Name Of The Plugin
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
*/
I’m wondering how WP reads that data as it is commented out… do they use file_get_contents(‘plugin.php’); and parse it as well as include the plugin? Is there a php function to actually read comments?
Thoughts?
explode
each line by:
and get result inarray
array[0]
makes the key andarray[1]
makes the value.WordPress has created its own function to handle file headers. I used this in my new Total Widget Control Plugin. Here’s the function name and help docs on how to use it.
get_file_data( $file_path, $headers, $context)
string $file: Path to the file
array $default_headers: List of headers, in the format array(‘HeaderKey’ => ‘Header Name’)
string $context: If specified adds filter hook “extra_{$context}_headers”