1.0.0 • Published 7 years ago

wp-get-file-data v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

wp-get-file-data

Get WordPress file information from NodeJS.

Port of WordPress get_file_data.

Installation

> npm install https://github.com/dkfiresky-wp/wp-get-file-data.git

Usage

Plugin data

const fileData = require( 'wp-get-file-data' );

fileData( '/wordpress/wp-content/plugins/akismet/akismet.php', {
	'Name': 'Plugin Name',
	'PluginURI': 'Plugin URI',
	'Version': 'Version',
	'Description': 'Description',
	'Author': 'Author',
	'AuthorURI': 'Author URI',
	'TextDomain': 'Text Domain',
	'DomainPath': 'Domain Path',
	'Network': 'Network'
}, ( error, result ) => {
	if ( null !== error) throw error;
	console.log( result );
} );
// The above will provide information like:
{
	Name: 'Akismet',
	PluginURI: 'https://akismet.com/',
	Version: '3.1.11',
	Description: 'Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="https://akismet.com/get/">Sign up for an Akismet plan</a> to get an API key, and 3) Go to your Akismet configuration page, and save your API key.',
	Author: 'Automattic',
	AuthorURI: 'https://automattic.com/wordpress-plugins/',
	TextDomain: 'akismet',
	DomainPath: '',
	Network: ''
}

Theme data

const fileData = require( 'wp-get-file-data' );

fileData( '/wordpress/wp-content/themes/twentysixteen/style.css', {
	'Name': 'Theme Name',
	'ThemeURI': 'Theme URI',
	'Description': 'Description',
	'Author': 'Author',
	'AuthorURI': 'Author URI',
	'Version': 'Version',
	'Template': 'Template',
	'Status': 'Status',
	'Tags': 'Tags',
	'TextDomain': 'Text Domain',
	'DomainPath': 'Domain Path',
}, ( error, result ) => {
	if ( null !== error) throw error;
	console.log( result );
} );
// The above will provide information like:
{
	Name: 'Twenty Sixteen',
	ThemeURI: 'https://wordpress.org/themes/twentysixteen/',
	Description: 'Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere.',
	Author: 'the WordPress team',
	AuthorURI: 'https://wordpress.org/',
	Version: '1.3',
	Template: '',
	Status: '',
	Tags: 'one-column, two-columns, right-sidebar, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, flexible-header, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready, blog',
	TextDomain: 'twentysixteen',
	DomainPath: ''
}