本文整理汇总了PHP中get_file_data函数的典型用法代码示例。如果您正苦于以下问题:PHP get_file_data函数的具体用法?PHP get_file_data怎么用?PHP get_file_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_file_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getScriptData
public static function getScriptData($sPathOrContent, $sType = 'plugin', $aDefaultHeaderKeys = array())
{
$_aHeaderKeys = $aDefaultHeaderKeys + array('sName' => 'Name', 'sURI' => 'URI', 'sScriptName' => 'Script Name', 'sLibraryName' => 'Library Name', 'sLibraryURI' => 'Library URI', 'sPluginName' => 'Plugin Name', 'sPluginURI' => 'Plugin URI', 'sThemeName' => 'Theme Name', 'sThemeURI' => 'Theme URI', 'sVersion' => 'Version', 'sDescription' => 'Description', 'sAuthor' => 'Author', 'sAuthorURI' => 'Author URI', 'sTextDomain' => 'Text Domain', 'sDomainPath' => 'Domain Path', 'sNetwork' => 'Network', '_sitewide' => 'Site Wide Only');
$aData = file_exists($sPathOrContent) ? get_file_data($sPathOrContent, $_aHeaderKeys, $sType) : self::getScriptDataFromContents($sPathOrContent, $sType, $_aHeaderKeys);
switch (trim($sType)) {
case 'theme':
$aData['sName'] = $aData['sThemeName'];
$aData['sURI'] = $aData['sThemeURI'];
break;
case 'library':
$aData['sName'] = $aData['sLibraryName'];
$aData['sURI'] = $aData['sLibraryURI'];
break;
case 'script':
$aData['sName'] = $aData['sScriptName'];
break;
case 'plugin':
$aData['sName'] = $aData['sPluginName'];
$aData['sURI'] = $aData['sPluginURI'];
break;
default:
break;
}
return $aData;
}
示例2: __construct
/**
* Constructor for Licence Validator in each plugin
*
* @param string $file - full server path to the main plugin file
* @param string $identifier - selling Shop Product ID
* @param string $home_shop_url - selling Shop URL of this plugin (product)
*/
public function __construct($file, $identifier, $home_shop_url)
{
$info = get_file_data($file, array('Title' => 'Plugin Name', 'Version' => 'Version', 'Url' => 'Plugin URI'), 'plugin');
$this->identifier = $identifier;
$this->file = $file;
$this->path = plugin_dir_path($this->file);
$this->plugin_slug = plugin_basename($this->file);
list($a, $b) = explode('/', $this->plugin_slug);
$this->file_slug = str_replace('.php', '', $b);
$this->title = $info['Title'];
$this->version = $info['Version'];
$this->plugin_url = $info['Url'];
$this->home_shop_url = $home_shop_url;
// if (is_ssl()) { // TODO: It should be enabled with proper options (i.e. require secure connection).
$this->home_shop_url = str_replace('http://', 'https://', $this->home_shop_url);
// }
if ($this->home_shop_url[strlen($this->home_shop_url) - 1] !== '/') {
$this->home_shop_url .= '/';
}
self::$plugins[$this->identifier] = array('version' => $this->version, 'plugin_slug' => $this->plugin_slug, 'file_slug' => $this->file_slug, 'path' => $this->path, 'title' => $this->title);
if (self::$instance === null) {
self::$instance = $this;
// Define the alternative response for information checking
add_filter('plugins_api', array($this, 'getUpdateData'), 20, 3);
}
// define the alternative API for updating checking
add_filter('pre_set_site_transient_update_plugins', array($this, 'checkUpdates'));
add_action('in_plugin_update_message-' . $this->plugin_slug, array($this, 'updateMessage'), 10, 2);
add_action('admin_init', '\\Jigoshop\\Licence::activateKeys');
}
示例3: get_module_info
/**
* fetch module info from file
* /utilities/modules.php
* @param $file
*/
public static function get_module_info($file)
{
$header = array('name' => 'Module Name', 'description' => 'Description', 'version' => 'Version', 'author' => 'Author', 'uri' => 'Author URI');
if (file_exists($file)) {
return get_file_data($file, $header);
}
}
示例4: create_model
function create_model($table_name)
{
$file = fopen("{$table_name}.php", "w");
$file_data = get_file_data($table_name);
fwrite($file, $file_data);
fclose($file);
}
示例5: init
/**
* Init
*/
function init()
{
// Running this here rather than the constructor since get_file_data is a bit expensive
$info = get_file_data($this->file, array('Title' => 'Plugin Name', 'Version' => 'Version'), 'plugin');
$this->plugin_title = $info['Title'];
$this->plugin_version = $info['Version'];
// Store the plugin to a static variable
self::$plugins[$this->api_key] = array('version' => $this->plugin_version, 'slug' => $this->plugin_slug, 'url' => $this->plugin_url, 'path' => $this->plugin_path, 'title' => $this->plugin_title);
// Check For Plugin Information
add_filter('plugins_api', array($this, 'plugin_information'), 10, 3);
// Check For Updates
add_filter('pre_set_site_transient_update_plugins', array($this, 'update_check'));
add_filter('upgrader_post_install', array($this, 'upgrader_post_install'), 10, 3);
if (!self::$instance) {
self::$instance = true;
// Register Navigation Menu Link
add_action('admin_menu', array($this, 'register_nav_menu_link'), 10);
add_filter('http_request_args', array($this, 'http_request_sslverify'), 10, 2);
if (!$this->instance_exists()) {
// Setup Admin Notices
add_action('admin_notices', array($this, 'admin_notice'));
add_action('admin_init', array($this, 'hide_admin_notice'));
}
}
}
示例6: GetPluginInfo
/**
* Returns an array string plugin information.
*
* @see the get_plugin_data() function defined in ABSPATH . 'wp-admin/includes/plugin.php'
*/
protected function GetPluginInfo($sFilePath)
{
$_aDefault = array('PluginName' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'AuthorURI', 'TextDomain' => 'TextDomain', 'DomainPath' => 'DomainPath', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
// There are cases that the path is not passed; there are various reasons for it
// such as allowing the redirecting parameter value of the caller function to be null for backward compatibility etc.
return $sFilePath ? get_file_data($sFilePath, $_aDefault, '') : $_aDefault;
}
示例7: hooks_theme_install_or_update
/**
* @param Theme_Upgrader $upgrader
* @param array $extra
*/
public function hooks_theme_install_or_update($upgrader, $extra)
{
if (!isset($extra['type']) || 'theme' !== $extra['type']) {
return;
}
if ('install' === $extra['action']) {
$slug = $upgrader->theme_info();
if (!$slug) {
return;
}
wp_clean_themes_cache();
$theme = wp_get_theme($slug);
$name = $theme->name;
$version = $theme->version;
aal_insert_log(array('action' => 'installed', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
}
if ('update' === $extra['action']) {
if (isset($extra['bulk']) && true == $extra['bulk']) {
$slugs = $extra['themes'];
} else {
$slugs = array($upgrader->skin->theme);
}
foreach ($slugs as $slug) {
$theme = wp_get_theme($slug);
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
$theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
$name = $theme['Name'];
$version = $theme_data['Version'];
aal_insert_log(array('action' => 'updated', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
}
}
}
示例8: pl_get_plugins
/**
* Get plugins and optionally filter out WP plugins
*/
static function pl_get_plugins($filter = false, $pro = false)
{
$default_headers = array('Version' => 'Version', 'PageLines' => 'PageLines', 'Plugin Name' => 'Plugin Name', 'Description' => 'Description', 'Version' => 'Version', 'Category' => 'Category');
include_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugins = get_plugins();
if (!$filter) {
return $plugins;
}
// get the headers for each plugin file
foreach ($plugins as $path => $data) {
$fullpath = sprintf('%s%s', trailingslashit(WP_PLUGIN_DIR), $path);
$plugins[$path] = get_file_data($fullpath, $default_headers);
}
// if the headers do not contain 'PageLines' then unset from the array and let WP handle them
foreach ($plugins as $path => $data) {
if (!$data['PageLines']) {
unset($plugins[$path]);
}
}
// only look for pro plugins
if ($pro) {
foreach ($plugins as $path => $data) {
$cats = array_map('trim', explode(',', $data['Category']));
if (!array_search('pro', $cats)) {
unset($plugins[$path]);
}
}
return $plugins;
}
return $plugins;
}
示例9: register_workflows_callback
public static function register_workflows_callback($arguments)
{
global $pagenow;
extract($arguments);
$data = get_file_data($path . '/parts/' . $folder . '/' . $part, apply_filters('piklist_get_file_data', array('name' => 'Title', 'description' => 'Description', 'capability' => 'Capability', 'order' => 'Order', 'flow' => 'Flow', 'page' => 'Page', 'post_type' => 'Post Type', 'taxonomy' => 'Taxonomy', 'role' => 'Role', 'redirect' => 'Redirect', 'header' => 'Header', 'disable' => 'Disable', 'position' => 'Position', 'default' => 'Default'), 'workflows'));
$data = apply_filters('piklist_add_part', $data, 'workflows');
if (!isset($data['flow'])) {
return null;
}
if ((!isset($data['capability']) || empty($data['capability']) || $data['capability'] && current_user_can(strtolower($data['capability']))) && (!isset($data['role']) || empty($data['role']) || piklist_user::current_user_role($data['role']))) {
if (!empty($data['page'])) {
$data['page'] = strstr($data['page'], ',') ? piklist::explode(',', $data['page']) : array($data['page']);
}
$data['page_slug'] = piklist::slug($data['name']);
$data['flow_slug'] = piklist::slug($data['flow']);
if (!$data['header']) {
$data = self::is_active($data);
}
if (in_array($pagenow, array('admin.php', 'users.php', 'plugins.php', 'options-general.php')) && $data['position'] == 'title') {
$data['position'] = 'header';
}
$workflow = array('config' => $data, 'part' => $path . '/parts/' . $folder . '/' . $part);
if (!isset(self::$workflows[$data['flow']])) {
self::$workflows[$data['flow']] = array();
}
if ($data['header'] == 'true') {
array_unshift(self::$workflows[$data['flow']], $workflow);
} elseif (!empty($data['order'])) {
self::$workflows[$data['flow']][$data['order']] = $workflow;
} else {
array_push(self::$workflows[$data['flow']], $workflow);
}
}
}
示例10: Fac_PHPVersion_AdminNotice
function Fac_PHPVersion_AdminNotice()
{
$name = get_file_data(__FILE__, array('Plugin Name'), 'plugin');
printf('<div class="error">
<p><strong>%s</strong> plugin can\'t work properly. Your current PHP version is <strong>%s</strong>. Minimum required PHP version is <strong>%s</strong>.</p>
</div>', $name[0], FAC_CUR_PHP_VERSION, FAC_MIN_PHP_VERSION);
}
示例11: __construct
/**
* Initializes the plugin by setting filters and administration functions.
*/
private function __construct()
{
$this->templates = array();
// Add a filter to the attributes metabox to inject template into the cache.
add_filter('page_attributes_dropdown_pages_args', array($this, 'register_project_templates'));
// Add a filter to the save post to inject out template into the page cache
add_filter('wp_insert_post_data', array($this, 'register_project_templates'));
// Add a filter to the template include to determine if the page has our
// template assigned and return it's path
add_filter('template_include', array($this, 'view_project_template'));
// Get array of page templates
$templates = scandir(plugin_dir_path(__FILE__) . 'templates/');
if (is_array($templates)) {
foreach ($templates as $template) {
if ($template == '.' || $template == '..' || strpos($template, '.')) {
continue;
}
$template_meta = get_file_data(plugin_dir_path(__FILE__) . 'templates/' . $template . '/' . $template . '.php', array('name' => 'Template Name', 'description' => 'Description'));
$this->templates[$template . '/' . $template . '.php'] = isset($template_meta['name']) ? $template_meta['name'] : 'ProGo Page Template';
}
}
// Add action to register template functions.php
add_action('init', array($this, 'register_template_functions'));
// Admin Menu
add_action('admin_menu', array($this, 'progo_page_templater_menu'));
}
示例12: register_notices_callback
public static function register_notices_callback($arguments)
{
$screen = get_current_screen();
extract($arguments);
$file = $path . '/parts/' . $folder . '/' . $part;
$data = get_file_data($file, apply_filters('piklist_get_file_data', array('notice_id' => 'Notice ID', 'notice_type' => 'Notice Type', 'capability' => 'Capability', 'role' => 'Role', 'page' => 'Page'), 'notice'));
$data = apply_filters('piklist_add_part', $data, 'notice');
$dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_piklist_notices', true));
if (!empty($dismissed[0]) && in_array($data['notice_id'], $dismissed)) {
return;
}
$page = str_replace(' ', '', $data['page']);
$pages = $page ? explode(',', $page) : false;
if ($screen->id == $page || empty($page) || in_array($screen->id, $pages)) {
if ($data['capability'] && !current_user_can($data['capability']) || $data['role'] && !piklist_user::current_user_role($data['role'])) {
return false;
} else {
$content = array('content' => trim(piklist::render($file, null, true)));
if (isset($data)) {
$data = array_merge($data, $content);
self::$notices[] = $data;
}
}
}
}
示例13: get_plugin_data
/**
* Parses the plugin contents to retrieve plugin's metadata.
*
* The metadata of the plugin's data searches for the following in the plugin's
* header. All plugin data must be on its own line. For plugin description, it
* must not have any newlines or only parts of the description will be displayed
* and the same goes for the plugin data. The below is formatted for printing.
*
* /*
* Plugin Name: Name of Plugin
* Plugin URI: Link to plugin information
* Description: Plugin Description
* Author: Plugin author's name
* Author URI: Link to the author's web site
* Version: Must be set in the plugin for WordPress 2.3+
* Text Domain: Optional. Unique identifier, should be same as the one used in
* load_plugin_textdomain()
* Domain Path: Optional. Only useful if the translations are located in a
* folder above the plugin's base path. For example, if .mo files are
* located in the locale folder then Domain Path will be "/locale/" and
* must have the first slash. Defaults to the base folder the plugin is
* located in.
* Network: Optional. Specify "Network: true" to require that a plugin is activated
* across all sites in an installation. This will prevent a plugin from being
* activated on a single site when Multisite is enabled.
* * / # Remove the space to close comment
*
* Some users have issues with opening large files and manipulating the contents
* for want is usually the first 1kiB or 2kiB. This function stops pulling in
* the plugin contents when it has all of the required plugin data.
*
* The first 8kiB of the file will be pulled in and if the plugin data is not
* within that first 8kiB, then the plugin author should correct their plugin
* and move the plugin data headers to the top.
*
* The plugin file is assumed to have permissions to allow for scripts to read
* the file. This is not checked however and the file is only opened for
* reading.
*
* @since 1.5.0
*
* @param string $plugin_file Path to the plugin file
* @param bool $markup Optional. If the returned data should have HTML markup applied.
* Default true.
* @param bool $translate Optional. If the returned data should be translated. Default true.
* @return array {
* Plugin data. Values will be empty if not supplied by the plugin.
*
* @type string $Name Name of the plugin. Should be unique.
* @type string $Title Title of the plugin and link to the plugin's site (if set).
* @type string $Description Plugin description.
* @type string $Author Author's name.
* @type string $AuthorURI Author's website address (if set).
* @type string $Version Plugin version.
* @type string $TextDomain Plugin textdomain.
* @type string $DomainPath Plugins relative directory path to .mo files.
* @type bool $Network Whether the plugin can only be activated network-wide.
* }
*/
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
$default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
$plugin_data = get_file_data($plugin_file, $default_headers, 'plugin');
// Site Wide Only is the old header for Network
if (!$plugin_data['Network'] && $plugin_data['_sitewide']) {
/* translators: 1: Site Wide Only: true, 2: Network: true */
_deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The %1$s plugin header is deprecated. Use %2$s instead.'), '<code>Site Wide Only: true</code>', '<code>Network: true</code>'));
$plugin_data['Network'] = $plugin_data['_sitewide'];
}
$plugin_data['Network'] = 'true' == strtolower($plugin_data['Network']);
unset($plugin_data['_sitewide']);
// If no text domain is defined fall back to the plugin slug.
if (!$plugin_data['TextDomain']) {
$plugin_slug = dirname(plugin_basename($plugin_file));
if ('.' !== $plugin_slug && false === strpos($plugin_slug, '/')) {
$plugin_data['TextDomain'] = $plugin_slug;
}
}
if ($markup || $translate) {
$plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
} else {
$plugin_data['Title'] = $plugin_data['Name'];
$plugin_data['AuthorName'] = $plugin_data['Author'];
}
return $plugin_data;
}
示例14: WPCW_metabox_showTemplateSelectionTool
/**
* Constructs the inner form to allow the user to choose a template for a
* unit.
*/
function WPCW_metabox_showTemplateSelectionTool()
{
printf('<p>%s</p>', __('Here you can choose which template to use for this unit.', 'wp_courseware'));
// Get a list of all templates
$theme = wp_get_theme();
// N.B. No caching, even though core Page Templates has that.
// Nacin advises:
// "ultimately, "caching" for page templates is not very helpful"
// "by default, the themes bucket is non-persistent. also, calling
// get_page_templates() no longer requires us to load up all theme
// data for all themes so overall, it's much quicker already."
$postTemplates = array('' => '--- ' . __('Use default template', 'wp_courseware') . ' ---');
// Get a list of all PHP files in the theme, so that we can check for theme headers.
// Allow the search to go into 1 level of folders.
$fileList = (array) $theme->get_files('php', 2);
foreach ($fileList as $fileName => $fullFilePath) {
// Progressively check the headers for each file. The header is called 'Unit Template Name'.
// e.g.
//
// Unit Template Name: Your Custom Template
//
$headers = get_file_data($fullFilePath, array('unit_template_name' => 'Unit Template Name'));
// No header found
if (empty($headers['unit_template_name'])) {
continue;
}
// We got one!
$postTemplates[$fileName] = $headers['unit_template_name'];
}
// Show form with selected template that the user can choose from.
global $post;
$selectedTemplate = get_post_meta($post->ID, WPCW_TEMPLATE_META_ID, true);
echo WPCW_forms_createDropdown('wpcw_units_choose_template_list', $postTemplates, $selectedTemplate);
}
示例15: xtreme_get_template_data
function xtreme_get_template_data($template_file)
{
$default_headers = array('Name' => 'Xtreme Name');
//using the WP 2.9 introduce function for us too.
$template_data = get_file_data($template_file, $default_headers, '');
return $template_data;
}