本文整理汇总了PHP中BackWPup::plugin_data方法的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup::plugin_data方法的具体用法?PHP BackWPup::plugin_data怎么用?PHP BackWPup::plugin_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackWPup
的用法示例。
在下文中一共展示了BackWPup::plugin_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_plugin_data
/**
* get information about the Plugin
*
* @param string $name Name of info to get or NULL to get all
* @return string|array
*/
public static function get_plugin_data($name = NULL)
{
if ($name) {
$name = strtolower(trim($name));
}
if (empty(self::$plugin_data)) {
self::$plugin_data = get_file_data(__FILE__, array('name' => 'Plugin Name', 'pluginuri' => 'Plugin URI', 'version' => 'Version', 'description' => 'Description', 'author' => 'Author', 'authoruri' => 'Author URI', 'textdomain' => 'Text Domain', 'domainpath' => 'Domain Path', 'license' => 'License', 'licenseuri' => 'License URI'), 'plugin');
//Translate some vars
self::$plugin_data['name'] = trim(self::$plugin_data['name']);
self::$plugin_data['pluginuri'] = trim(self::$plugin_data['pluginuri']);
self::$plugin_data['description'] = trim(self::$plugin_data['description']);
self::$plugin_data['author'] = trim(self::$plugin_data['author']);
self::$plugin_data['authoruri'] = trim(self::$plugin_data['authoruri']);
//set some extra vars
self::$plugin_data['basename'] = plugin_basename(dirname(__FILE__));
self::$plugin_data['mainfile'] = __FILE__;
self::$plugin_data['plugindir'] = untrailingslashit(dirname(__FILE__));
self::$plugin_data['hash'] = get_site_option('backwpup_cfg_hash');
if (empty(self::$plugin_data['hash']) || strlen(self::$plugin_data['hash']) < 6 || strlen(self::$plugin_data['hash']) > 12) {
update_site_option('backwpup_cfg_hash', substr(md5(md5(BackWPup::get_plugin_data("mainfile"))), 14, 6));
self::$plugin_data['hash'] = get_site_option('backwpup_cfg_hash');
}
if (defined('WP_TEMP_DIR') && is_dir(WP_TEMP_DIR)) {
self::$plugin_data['temp'] = trailingslashit(untrailingslashit(str_replace('\\', '/', WP_TEMP_DIR)) . '/backwpup-' . self::$plugin_data['hash']);
} else {
$upload_dir = wp_upload_dir();
self::$plugin_data['temp'] = trailingslashit(untrailingslashit(str_replace('\\', '/', $upload_dir['basedir'])) . '/backwpup-' . self::$plugin_data['hash'] . '-temp');
}
self::$plugin_data['running_file'] = self::$plugin_data['temp'] . 'backwpup-working.php';
self::$plugin_data['url'] = plugins_url('', __FILE__);
self::$plugin_data['cacert'] = FALSE;
if (file_exists(self::$plugin_data['plugindir'] . '/vendor/Guzzle/Http/Resources/cacert.pem')) {
self::$plugin_data['cacert'] = self::$plugin_data['plugindir'] . '/vendor/Guzzle/Http/Resources/cacert.pem';
}
self::$plugin_data['cacert'] = apply_filters('backwpup_cacert_bundle', self::$plugin_data['cacert']);
//get unmodified WP Versions
include ABSPATH . WPINC . '/version.php';
/** @var $wp_version string */
self::$plugin_data['wp_version'] = $wp_version;
//Build User Agent
self::$plugin_data['user-agent'] = self::$plugin_data['name'] . '/' . self::$plugin_data['version'] . '; WordPress/' . self::$plugin_data['wp_version'] . '; ' . home_url();
}
if (!empty($name)) {
return self::$plugin_data[$name];
} else {
return self::$plugin_data;
}
}
示例2: get_plugin_data
/**
* get information about the Plugin
*
* @param string $name Name of info to get or NULL to get all
* @return string|array
*/
public static function get_plugin_data($name = NULL)
{
if ($name) {
$name = strtolower(trim($name));
}
if (empty(self::$plugin_data)) {
self::$plugin_data = get_file_data(__FILE__, array('name' => 'Plugin Name', 'version' => 'Version'), 'plugin');
self::$plugin_data['name'] = trim(self::$plugin_data['name']);
//set some extra vars
self::$plugin_data['basename'] = plugin_basename(dirname(__FILE__));
self::$plugin_data['mainfile'] = __FILE__;
self::$plugin_data['plugindir'] = untrailingslashit(dirname(__FILE__));
self::$plugin_data['hash'] = get_site_option('backwpup_cfg_hash');
if (empty(self::$plugin_data['hash']) || strlen(self::$plugin_data['hash']) < 6 || strlen(self::$plugin_data['hash']) > 12) {
self::$plugin_data['hash'] = substr(md5(md5(__FILE__)), 14, 6);
update_site_option('backwpup_cfg_hash', self::$plugin_data['hash']);
}
if (defined('WP_TEMP_DIR') && is_dir(WP_TEMP_DIR)) {
self::$plugin_data['temp'] = str_replace('\\', '/', get_temp_dir()) . 'backwpup-' . self::$plugin_data['hash'] . '/';
} else {
$upload_dir = wp_upload_dir();
self::$plugin_data['temp'] = str_replace('\\', '/', $upload_dir['basedir']) . '/backwpup-' . self::$plugin_data['hash'] . '-temp/';
}
self::$plugin_data['running_file'] = self::$plugin_data['temp'] . 'backwpup-working.php';
self::$plugin_data['url'] = plugins_url('', __FILE__);
self::$plugin_data['cacert'] = apply_filters('backwpup_cacert_bundle', ABSPATH . WPINC . '/certificates/ca-bundle.crt');
//get unmodified WP Versions
include ABSPATH . WPINC . '/version.php';
/** @var $wp_version string */
self::$plugin_data['wp_version'] = $wp_version;
//Build User Agent
self::$plugin_data['user-agent'] = self::$plugin_data['name'] . '/' . self::$plugin_data['version'] . '; WordPress/' . self::$plugin_data['wp_version'] . '; ' . home_url();
}
if (!empty($name)) {
return self::$plugin_data[$name];
} else {
return self::$plugin_data;
}
}