本文整理汇总了PHP中SucomUtil::get_stripped_php方法的典型用法代码示例。如果您正苦于以下问题:PHP SucomUtil::get_stripped_php方法的具体用法?PHP SucomUtil::get_stripped_php怎么用?PHP SucomUtil::get_stripped_php使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SucomUtil
的用法示例。
在下文中一共展示了SucomUtil::get_stripped_php方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify_tmpl_head_elements
public function modify_tmpl_head_elements()
{
$headers = glob(get_stylesheet_directory() . '/header*.php');
foreach ($headers as $file) {
$base = basename($file);
$backup = $file . '~backup-' . date('Ymd-His');
// double check in case of reloads etc.
if (($html = SucomUtil::get_stripped_php($file)) === false || strpos($html, '<head>') === false) {
$this->p->notice->err(sprintf(__('<head> element not found in %s.', 'nextgen-facebook'), $file), true);
continue;
}
// make a backup of the original
if (!copy($file, $backup)) {
$this->p->notice->err(sprintf(__('Error copying %1$s to %2$s.', 'nextgen-facebook'), 'header.php', $backup), true);
continue;
}
$php = file_get_contents($file);
$php = str_replace('<head>', '<head <?php do_action( \'add_head_attributes\' ); ?>>', $php);
if (!($fh = @fopen($file, 'wb'))) {
$this->p->notice->err(sprintf(__('Failed to open file %s for writing.', 'nextgen-facebook'), $file), true);
continue;
}
if (fwrite($fh, $php)) {
fclose($fh);
$this->p->notice->inf(sprintf(__('The %1$s template has been successfully updated and saved. A backup copy of the original template is available in %2$s.', 'nextgen-facebook'), $base, $backup), true);
}
}
$this->p->notice->trunc_id('notice-header-tmpl-no-head-attr');
// just in case
}