本文整理汇总了PHP中nggGallery::suppress_injection方法的典型用法代码示例。如果您正苦于以下问题:PHP nggGallery::suppress_injection方法的具体用法?PHP nggGallery::suppress_injection怎么用?PHP nggGallery::suppress_injection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggGallery
的用法示例。
在下文中一共展示了nggGallery::suppress_injection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_gallery
/**
* Create a new gallery in a new folder
*
*
* @param string $title The gallery name.
* @param string $defaultpath The path where the gallery should be added.
* @param bool $output (optional) If the function should show an error messsage or not.
* @param string $description (optional) The gallery description.
*
* @since 1.9.24 Added the description parameter.
*
* @return bool|int True if successful, otherwise false.$galleryID if is successful and output = false)
*/
static function create_gallery($title, $defaultpath, $output = true, $description = '')
{
global $user_ID;
get_currentuserinfo();
//get current user ID & sets global object $current_user
$name = sanitize_file_name(sanitize_title($title));
//cleanup pathname
$name = apply_filters('ngg_gallery_name', $name);
if (empty($name)) {
// No gallery name ?
if ($output) {
nggGallery::show_error(__('No valid gallery name!', 'nggallery'));
}
return false;
}
$txt = '';
$nggRoot = WINABSPATH . $defaultpath;
// check for main folder
if (!is_dir($nggRoot)) {
if (!wp_mkdir_p($nggRoot)) {
$txt = __('Directory', 'nggallery') . ' <strong>' . esc_html($defaultpath) . '</strong> ' . __('didn\'t exist. Please create first the main gallery folder ', 'nggallery') . '!<br />';
$txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery') . ' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> ';
if ($output) {
nggGallery::show_error($txt);
}
return false;
}
}
// check for permission settings, Safe mode limitations are not taken into account.
if (!is_writeable($nggRoot)) {
$txt = __('Directory', 'nggallery') . ' <strong>' . esc_html($defaultpath) . '</strong> ' . __('is not writeable !', 'nggallery') . '<br />';
$txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery') . ' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> ';
if ($output) {
nggGallery::show_error($txt);
}
return false;
}
// 1. Check for existing folder, if it already exists, create new one with suffix
if (is_dir($nggRoot . $name) && !SAFE_MODE) {
$suffix = 1;
do {
$alt_name = substr($name, 0, 200 - (strlen($suffix) + 1)) . "_{$suffix}";
$dir_check = is_dir($nggRoot . $alt_name);
$suffix++;
} while ($dir_check);
$name = $alt_name;
}
// define relative path to gallery inside wp root folder
$nggpath = $defaultpath . $name;
$win_nggpath = WINABSPATH . $nggpath;
// 2. Create new gallery folder
if (!wp_mkdir_p($win_nggpath)) {
$txt = __('Unable to create directory ', 'nggallery') . esc_html($nggpath) . '!<br />';
}
// 3. Check folder permission
if (!is_writeable($win_nggpath)) {
$txt .= __('Directory', 'nggallery') . ' <strong>' . esc_html($nggpath) . '</strong> ' . __('is not writeable !', 'nggallery') . '<br />';
}
// 4. Now create thumbnail folder inside
if (!is_dir($win_nggpath . '/thumbs')) {
if (!wp_mkdir_p($win_nggpath . '/thumbs')) {
$txt .= __('Unable to create directory ', 'nggallery') . ' <strong>' . esc_html($nggpath) . '/thumbs !</strong>';
}
}
if (SAFE_MODE) {
$help = __('The server setting Safe-Mode is on !', 'nggallery');
$help .= '<br />' . __('If you have problems, please create directory', 'nggallery') . ' <strong>' . esc_html($nggpath) . '</strong> ';
$help .= __('and the thumbnails directory', 'nggallery') . ' <strong>' . esc_html($nggpath) . '/thumbs</strong> ' . __('with permission 777 manually !', 'nggallery');
if ($output) {
nggGallery::show_message($help);
}
}
// show a error message
if (!empty($txt)) {
if (SAFE_MODE) {
// for safe_mode , better delete folder, both folder must be created manually
@rmdir($win_nggpath . '/thumbs');
@rmdir($win_nggpath);
}
if ($output) {
nggGallery::show_error($txt);
}
return false;
}
//clean the description and add the gallery
$description = nggGallery::suppress_injection($description);
$galleryID = nggdb::add_gallery($title, $nggpath, $description, 0, 0, $user_ID);
//.........这里部分代码省略.........
示例2: nggallery_picturelist
//.........这里部分代码省略.........
echo "<span class='{$action}'>{$link}{$sep}</span>";
}
echo '</div>';
?>
</p>
</td>
<?php
break;
case 'thumbnail':
$attributes = 'class="id column-thumbnail media-icon"' . $style;
?>
<td <?php
echo $attributes;
?>
><a href="<?php
echo esc_url(add_query_arg('i', mt_rand(), $picture->imageURL));
?>
" class="shutter" title="<?php
echo $picture->filename;
?>
">
<img class="thumb" src="<?php
echo esc_url(add_query_arg('i', mt_rand(), $picture->thumbURL));
?>
" id="thumb<?php
echo $pid;
?>
" />
</a>
</td>
<?php
break;
case 'alt_title_desc':
$img_alt_text = nggGallery::suppress_injection($picture->alttext);
$img_description = nggGallery::suppress_injection($picture->description);
?>
<td <?php
echo $attributes;
?>
>
<input placeholder="<?php
_e("Alt & title text", 'nggallery');
?>
" name="alttext[<?php
echo $pid;
?>
]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php
echo $img_alt_text;
?>
" /><br/>
<textarea placeholder="<?php
_e("Description", 'nggallery');
?>
" name="description[<?php
echo $pid;
?>
]" style="width:95%; margin: 1px;" rows="2" ><?php
echo $img_description;
?>
</textarea>
</td>
<?php
break;
case 'exclude':
?>
<td <?php