Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Comment parsing proof of concept
/*
Skin Name: Default
Author: Cameron Jones
Author URI: https://cameronjonesweb.com.au
*/
<?php
/**
* Plugin Name: Testing Comment Parsing
*/
class Testing_Comment_Parsing {
/**
* Creates a singleton instance of the plugin class.
*/
public static function get_instance() {
static $inst = null;
if ( null === $inst ) {
$inst = new self();
}
return $inst;
}
public function __construct() {
$this->hooks();
}
private function hooks() {
add_action( 'init', [ $this, 'load_things' ] );
}
public function load_things() {
$path = plugin_dir_path( __FILE__ ) . 'skins';
$contents = scandir( $path );
$files = [];
foreach ( $contents as $content ) {
if ( ! is_dir( $content ) ) {
$files[] = $content;
}
}
$url = plugins_url( '/', __FILE__ ) . 'skins';
$headers = [ 'Skin Name', 'Author', 'Author URI' ];
foreach ( $files as $file ) {
$file_path = trailingslashit( $path ) . $file;
// URL.
var_dump( str_replace( $path, $url, $file_path ) );
// Headers.
var_dump( get_file_data( $file_path, $headers ) );
}
wp_die();
}
}
new Testing_Comment_Parsing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.