当前位置: 首页>>代码示例>>PHP>>正文


PHP _cleanup_header_comment函数代码示例

本文整理汇总了PHP中_cleanup_header_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP _cleanup_header_comment函数的具体用法?PHP _cleanup_header_comment怎么用?PHP _cleanup_header_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_cleanup_header_comment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_post_templates

 /**
  * Scans the template files of the active theme, and returns an
  * array of [Template Name => {file}.php]
  *
  * @since 0.2.0
  *
  * @return array
  */
 function get_post_templates()
 {
     $themes = get_themes();
     $theme = get_current_theme();
     $templates = $themes[$theme]['Template Files'];
     $post_templates = array();
     $base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
     foreach ((array) $templates as $template) {
         $template = WP_CONTENT_DIR . str_replace(WP_CONTENT_DIR, '', $template);
         $basename = str_replace($base, '', $template);
         /** Don't allow template files in subdirectories */
         if (false !== strpos($basename, '/')) {
             continue;
         }
         $template_data = implode('', file($template));
         $name = '';
         if (preg_match('|Single Post Template:(.*)$|mi', $template_data, $name)) {
             $name = _cleanup_header_comment($name[1]);
         }
         if (!empty($name)) {
             if (basename($template) != basename(__FILE__)) {
                 $post_templates[trim($name)] = $basename;
             }
         }
     }
     return $post_templates;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:35,代码来源:post-templates.php

示例2: get_plugin_data

/**
 * Parse 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.
 *
 * <code>
 * /*
 * 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
 *		plugin_text_domain()
 * 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.
 *  * / # Remove the space to close comment
 * </code>
 *
 * Plugin data returned array contains the following:
 *		'Name' - Name of the plugin, must be unique.
 *		'Title' - Title of the plugin and the link to the plugin's web site.
 *		'Description' - Description of what the plugin does and/or notes
 *		from the author.
 *		'Author' - The author's name
 *		'AuthorURI' - The authors web site address.
 *		'Version' - The plugin version number.
 *		'PluginURI' - Plugin web site address.
 *		'TextDomain' - Plugin's text domain for localization.
 *		'DomainPath' - Plugin's relative directory path to .mo files.
 *
 * 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.
 *
 * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
 * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
 * @since 1.5.0
 *
 * @param string $plugin_file Path to the plugin file
 * @param bool $markup If the returned data should have HTML markup applied
 * @param bool $translate If the returned data should be translated
 * @return array See above for description.
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    // We don't need to write to the file, so just open for reading.
    $fp = fopen($plugin_file, 'r');
    // Pull only the first 8kiB of the file in.
    $plugin_data = fread($fp, 8192);
    // PHP will close file handle, but we are good citizens.
    fclose($fp);
    preg_match('|Plugin Name:(.*)$|mi', $plugin_data, $name);
    preg_match('|Plugin URI:(.*)$|mi', $plugin_data, $uri);
    preg_match('|Version:(.*)|i', $plugin_data, $version);
    preg_match('|Description:(.*)$|mi', $plugin_data, $description);
    preg_match('|Author:(.*)$|mi', $plugin_data, $author_name);
    preg_match('|Author URI:(.*)$|mi', $plugin_data, $author_uri);
    preg_match('|Text Domain:(.*)$|mi', $plugin_data, $text_domain);
    preg_match('|Domain Path:(.*)$|mi', $plugin_data, $domain_path);
    foreach (array('name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path') as $field) {
        if (!empty(${$field})) {
            ${$field} = _cleanup_header_comment(${$field}[1]);
        } else {
            ${$field} = '';
        }
    }
    $plugin_data = array('Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description, 'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version, 'TextDomain' => $text_domain, 'DomainPath' => $domain_path);
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    }
    return $plugin_data;
}
开发者ID:bluedanbob,项目名称:wordpress,代码行数:88,代码来源:plugin.php

示例3: hybrid_get_post_templates

/**
 * Function for getting an array of available custom templates with a specific header. Ideally,
 * this function would be used to grab custom singular post (any post type) templates.
 *
 * @since 0.7
 * @param array $args Arguments to check the templates against.
 * @return array $post_templates The array of templates.
 */
function hybrid_get_post_templates( $args = array() ) {

	$args = wp_parse_args( $args, array( 'label' => array( 'Post Template' ) ) );

	$themes = get_themes();
	$theme = get_current_theme();
	$templates = $themes[$theme]['Template Files'];
	$post_templates = array();

	if ( is_array( $templates ) ) {
		$base = array( trailingslashit( get_template_directory() ), trailingslashit( get_stylesheet_directory() ) );

		foreach ( $templates as $template ) {
			$basename = str_replace( $base, '', $template );

			$template_data = implode( '', file( $template ) );

			$name = '';
			foreach ( $args['label'] as $label ) {
				if ( preg_match( "|{$label}:(.*)$|mi", $template_data, $name ) ) {
					$name = _cleanup_header_comment( $name[1] );
					break;
				}
			}

			if ( !empty( $name ) )
				$post_templates[trim( $name )] = $basename;
		}
	}

	return $post_templates;
}
开发者ID:nerdfiles,项目名称:tbotw.org,代码行数:40,代码来源:admin.php

示例4: get_file_data

 function get_file_data($file, $default_headers, $context = '')
 {
     // We don't need to write to the file, so just open for reading.
     $fp = fopen($file, 'r');
     // Pull only the first 8kiB of the file in.
     $file_data = fread($fp, 8192);
     // PHP will close file handle, but we are good citizens.
     fclose($fp);
     if ($context != '') {
         $extra_headers = apply_filters("extra_{$context}" . '_headers', array());
         $extra_headers = array_flip($extra_headers);
         foreach ($extra_headers as $key => $value) {
             $extra_headers[$key] = $key;
         }
         $all_headers = array_merge($extra_headers, $default_headers);
     } else {
         $all_headers = $default_headers;
     }
     foreach ($all_headers as $field => $regex) {
         preg_match('/' . preg_quote($regex, '/') . ':(.*)$/mi', $file_data, ${$field});
         if (!empty(${$field})) {
             ${$field} = _cleanup_header_comment(${$field}[1]);
         } else {
             ${$field} = '';
         }
     }
     $file_data = compact(array_keys($all_headers));
     return $file_data;
 }
开发者ID:jimrucinski,项目名称:Vine,代码行数:29,代码来源:compat.php

示例5: get_post_templates

 function get_post_templates()
 {
     $themes = wp_get_themes();
     $theme = get_option('template');
     $templates = $themes[$theme]['Template Files'];
     $post_templates = array();
     if (is_array($templates)) {
         $base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
         foreach ($templates as $template) {
             $basename = str_replace($base, '', $template);
             if ($basename != 'functions.php') {
                 // don't allow template files in subdirectories
                 if (false !== strpos($basename, '/')) {
                     continue;
                 }
                 if ($basename == 'post_templates.php') {
                     continue;
                 }
                 $template_data = implode('', file($template));
                 $name = '';
                 if (preg_match('|Single Post Template:(.*)$|mi', $template_data, $name)) {
                     $name = _cleanup_header_comment($name[1]);
                 }
                 if (!empty($name)) {
                     $post_templates[trim($basename)] = $name;
                 }
             }
         }
     }
     return $post_templates;
 }
开发者ID:Snaehild,项目名称:GH2016,代码行数:31,代码来源:post_templates.php

示例6: post_tpl_get_templates

function post_tpl_get_templates()
{
    $templates = wp_get_theme()->get_files('php', 1, true);
    $post_templates = array();
    foreach ((array) $templates as $file => $full_path) {
        if (!preg_match('|' . str_replace("_", " ", "Modello_di_pubblicazione:") . '(.*)$|mi', file_get_contents($full_path), $header)) {
            continue;
        }
        $post_templates[$file] = _cleanup_header_comment($header[1]);
    }
    return $post_templates;
}
开发者ID:venerdi2,项目名称:pasw2015,代码行数:12,代码来源:pasw2015-post-templates.php

示例7: get_file_description

/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $file
 * @return unknown
 */
function get_file_description($file)
{
    global $wp_file_descriptions;
    if (isset($wp_file_descriptions[basename($file)])) {
        return $wp_file_descriptions[basename($file)];
    } elseif (file_exists($file) && is_file($file)) {
        $template_data = implode('', file($file));
        if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) {
            return _cleanup_header_comment($name[1]) . ' Page Template';
        }
    }
    return basename($file);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:21,代码来源:file.php

示例8: get_post_templates

 function get_post_templates()
 {
     $templates = wp_get_theme()->get_files('php', 1);
     $post_templates = array();
     $base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
     foreach ((array) $templates as $file => $full_path) {
         if (!preg_match('|Single Post Template:(.*)$|mi', file_get_contents($full_path), $header)) {
             continue;
         }
         $post_templates[$file] = _cleanup_header_comment($header[1]);
     }
     return $post_templates;
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:13,代码来源:post_templates.php

示例9: get_file_description

/**
 * Get the description for standard HiveQueen theme files and other various standard
 * HiveQueen files
 *
 * @since 0.0.1
 *
 * @global array $hq_file_descriptions
 * @param string $file Filesystem path or filename
 * @return string Description of file from $hq_file_descriptions or basename of $file if description doesn't exist
 */
function get_file_description($file)
{
    global $hq_file_descriptions;
    if (isset($hq_file_descriptions[basename($file)])) {
        return $hq_file_descriptions[basename($file)];
    } elseif (file_exists($file) && is_file($file)) {
        $template_data = implode('', file($file));
        if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) {
            return sprintf(__('%s Page Template'), _cleanup_header_comment($name[1]));
        }
    }
    return trim(basename($file));
}
开发者ID:gcorral,项目名称:hivequeen,代码行数:23,代码来源:file.php

示例10: get_file_description

/**
 * Get the description for standard WordPress theme files and other various standard
 * WordPress files
 *
 * @since 1.5.0
 *
 * @global array $wp_file_descriptions
 * @param string $file Filesystem path or filename
 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.
 *                Appends 'Page Template' to basename of $file if the file is a page template
 */
function get_file_description($file)
{
    global $wp_file_descriptions, $allowed_files;
    $relative_pathinfo = pathinfo($file);
    $file_path = $allowed_files[$file];
    if (isset($wp_file_descriptions[basename($file)]) && '.' === $relative_pathinfo['dirname']) {
        return $wp_file_descriptions[basename($file)];
    } elseif (file_exists($file_path) && is_file($file_path)) {
        $template_data = implode('', file($file_path));
        if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) {
            return sprintf(__('%s Page Template'), _cleanup_header_comment($name[1]));
        }
    }
    return trim(basename($file));
}
开发者ID:nxty2011,项目名称:WordPress,代码行数:26,代码来源:file.php

示例11: get_header

 function get_header($page)
 {
     $default_headers = array('Name' => 'Template Name');
     $fp = fopen(APPPATH . 'views/templates/' . $page, 'r');
     $file_data = fread($fp, 512);
     fclose($fp);
     $file_data = str_replace("\r", "\n", $file_data);
     foreach ($default_headers as $field => $regex) {
         if (preg_match('/^[ \\t\\/*#@]*' . preg_quote($regex, '/') . ':(.*)$/mi', $file_data, $match) && $match[1]) {
             $all_headers[$field] = _cleanup_header_comment($match[1]);
         } else {
             $all_headers[$field] = '';
         }
         return $all_headers;
     }
 }
开发者ID:borka-s,项目名称:ajde_makedonija,代码行数:16,代码来源:pages_helper.php

示例12: get_file_version

 /**
  * Retrieve metadata from a file. Based on WP Core's get_file_data function
  *
  * @since 0.8
  * @param string $file Path to the file
  * @param array $all_headers List of headers, in the format array('HeaderKey' => 'Header Name')
  */
 public function get_file_version($file)
 {
     // We don't need to write to the file, so just open for reading.
     $fp = fopen($file, 'r');
     // Pull only the first 8kiB of the file in.
     $file_data = fread($fp, 8192);
     // PHP will close file handle, but we are good citizens.
     fclose($fp);
     // Make sure we catch CR-only line endings.
     $file_data = str_replace("\r", "\n", $file_data);
     $version = '';
     if (preg_match('/^[ \\t\\/*#@]*' . preg_quote('@version', '/') . '(.*)$/mi', $file_data, $match) && $match[1]) {
         $version = _cleanup_header_comment($match[1]);
     }
     return $version;
 }
开发者ID:kleitz,项目名称:ProSports,代码行数:23,代码来源:class-sp-admin-status.php

示例13: getScriptDataFromContents

 public static function getScriptDataFromContents($sContent, $sType = 'plugin', $aDefaultHeaderKeys = array())
 {
     $sContent = str_replace("\r", "\n", $sContent);
     $_aHeaders = $aDefaultHeaderKeys;
     if ($sType) {
         $_aExtraHeaders = apply_filters("extra_{$sType}_headers", array());
         if (!empty($_aExtraHeaders)) {
             $_aExtraHeaders = array_combine($_aExtraHeaders, $_aExtraHeaders);
             $_aHeaders = array_merge($_aExtraHeaders, (array) $aDefaultHeaderKeys);
         }
     }
     foreach ($_aHeaders as $_sHeaderKey => $_sRegex) {
         $_bFound = preg_match('/^[ \\t\\/*#@]*' . preg_quote($_sRegex, '/') . ':(.*)$/mi', $sContent, $_aMatch);
         $_aHeaders[$_sHeaderKey] = $_bFound && $_aMatch[1] ? _cleanup_header_comment($_aMatch[1]) : '';
     }
     return $_aHeaders;
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:17,代码来源:AdminPageFramework_WPUtility_File.php

示例14: cuttz_get_templates

/**
 * Gets all the custom templates stored inside the current skin directory
 * @param type $post 
 * @return ? templates
 * @since 1.0
 */
function cuttz_get_templates($post)
{
    $page_templates = '';
    // wp_cache_get( 'page_templates' );
    $page_templates = array();
    $files = glob(SKIN_DIR . '/*.php');
    foreach ($files as $file => $full_path) {
        if (!preg_match('|Template Name:(.*)$|mi', file_get_contents($full_path), $header)) {
            continue;
        }
        $page_templates[basename($full_path)] = _cleanup_header_comment($header[1]);
    }
    if (wp_get_theme()->parent()) {
        $page_templates = wp_get_theme()->parent()->get_page_templates($post) + $page_templates;
    }
    return apply_filters('cuttz_page_templates', $page_templates, $post);
}
开发者ID:garywp,项目名称:cuttz-framework,代码行数:23,代码来源:cuttz-custom-template-box.php

示例15: geko_check_update

function geko_check_update($transient)
{
    if (empty($transient->checked)) {
        return $transient;
    }
    $theme_data = wp_get_theme(wp_get_theme()->template);
    $theme_slug = $theme_data->get_template();
    //Delete '-master' from the end of slug
    $theme_uri_slug = preg_replace('/-master$/', '', $theme_slug);
    $remote_version = '0.0.0';
    $style_css = wp_remote_get("https://raw.githubusercontent.com/erm2587/" . $theme_uri_slug . "/master/style.css")['body'];
    if (preg_match('/^[ \\t\\/*#@]*' . preg_quote('Version', '/') . ':(.*)$/mi', $style_css, $match) && $match[1]) {
        $remote_version = _cleanup_header_comment($match[1]);
    }
    if (version_compare($theme_data->version, $remote_version, '<')) {
        $transient->response[$theme_slug] = array('theme' => $theme_slug, 'new_version' => $remote_version, 'url' => 'https://github.com/erm2587/' . $theme_uri_slug, 'package' => 'https://github.com/erm2587/' . $theme_uri_slug . '/archive/master.zip');
    }
    return $transient;
}
开发者ID:IgekoSC,项目名称:geko_classic,代码行数:19,代码来源:checkupdates.php


注:本文中的_cleanup_header_comment函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。