flickr.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 527 行 · 第 1/2 页
PHP
527 行
add_action('admin_menu', 'show_flickr_options_page');
add_action('plugins_loaded', 'flickr_update');
function show_flickr_options_page() {
add_options_page(__('Flickr', 'flickr'), __('Flickr', 'flickr'), 8, __FILE__, 'flickr_options_page');
}
function flickr_options_page() {
$options = array(
// plugin options
'wptag_display', 'flickr_display',
// flickr options
'flickr_cache', 'flickr_maxrows', 'flickr_maxcols', 'flickr_maxheight', 'flickr_maxwidth'
// tag options
//,'wptag_url', 'wptag_title', 'wptag_tagpattern', 'wptag_tagspattern'
);
foreach($options as $option){
${$option} = htmlspecialchars($GLOBALS[$option], ENT_QUOTES);
}
if(isset($_POST['submitted'])) {
foreach($options as $option){
update_option($option, $_POST[$option]);
}
}
if(isset($_POST['clear_cache'])) {
flickr_clear_cache();
}
$formaction = $_SERVER['PHP_SELF'] . "?page=flickr.php";
?>
<div class="wrap">
<h2><?php _e('Flickr Options', 'flickr'); ?></h2>
<form name="flickr_options" method="post" action="<?php echo $formaction; ?>">
<input type="hidden" name="submitted" value="1" />
<fieldset class="options">
<legend>
<label><?php _e('Flickr options', 'flickr'); ?></label>
</legend>
<p>
<?php
_e('The options to control flickr images on your blog pages. Visit <a href="http://xoopsforge.com">XForge</a> for more information', 'flickr');
?></p>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Display tags:', 'flickr'); ?> </th>
<td>
<input type="checkbox" name="wptag_display" value="1" <?php echo empty($wptag_display)?"":"checked";?> />
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Display images:', 'flickr'); ?> </th>
<td>
<input type="checkbox" name="flickr_display" value="1" <?php echo empty($flickr_display)?"":"checked";?> />
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Cache time:', 'flickr'); ?> </th>
<td>
<input type="text" name="flickr_cache" value="<?php echo $flickr_cache; ?>" /><br />
<i><?php _e('Cache time for flickr items (in seconds). Default is 1 day', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Maximum rows:', 'flickr'); ?> </th>
<td>
<input type="text" name="flickr_maxrows" value="<?php echo $flickr_maxrows; ?>" /><br />
<i><?php _e('Rows of images to display. One row per tag. 0 for no limit', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Maximum columns:', 'flickr'); ?> </th>
<td>
<input type="text" name="flickr_maxcols" value="<?php echo $flickr_maxcols; ?>" /><br />
<i><?php _e('Images to display for each row (tag). 0 for no limit', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Maximum height:', 'flickr'); ?> </th>
<td>
<input type="text" name="flickr_maxheight" value="<?php echo $flickr_maxheight; ?>" /><br />
<i><?php _e('Image maximum height', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Maximum width:', 'flickr'); ?> </th>
<td>
<input type="text" name="flickr_maxwidth" value="<?php echo $flickr_maxwidth; ?>" /><br />
<i><?php _e('Image maximum width', 'flickr'); ?></i>
</td>
</tr>
<!--
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Tag url:', 'flickr'); ?> </th>
<td>
<input type="text" name="wptag_url" value="<?php echo $wptag_url; ?>" size="60" /><br />
<i><?php _e('Tags full link', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Tag title:', 'flickr'); ?> </th>
<td>
<input type="text" name="wptag_title" value="<?php echo $wptag_title; ?>" size="60" /><br />
<i><?php _e('Title for tags', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Tag pattern:', 'flickr'); ?> </th>
<td>
<input type="text" name="wptag_tagpattern" value="<?php echo $wptag_tagpattern; ?>" size="60" /><br />
<i><?php _e('pattern for tag inside content', 'flickr'); ?></i>
</td>
</tr>
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Tags pattern:', 'flickr'); ?> </th>
<td>
<input type="text" name="wptag_tagspattern" value="<?php echo $wptag_tagspattern; ?>" size="60" /><br />
<i><?php _e('pattern for tags at the end of content', 'flickr'); ?></i>
</td>
</tr>
-->
<tr>
<th width="33%" valign="top" scope="row"><?php _e('Clear cache:', 'flickr'); ?> </th>
<td>
<input type="checkbox" name="clear_cache" value="1" "checked"/><br />
<i><?php _e('To delete all cached files', 'flickr'); ?></i>
</td>
</tr>
</table>
</fieldset>
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options »', 'flickr'); ?>" />
</p>
</form>
</div>
<?php }
/*
Plugin Name: SimpleTags
Plugin URI: http://www.broobles.com/scripts/simpletags/
Description: Allows you to create a list of Technorati tags at the bottom of your post by providing a comma separated list of tags between the <tags> tags. You can use it with any blogging tool/method, not just when posting from WordPress itself (doesn't use custom fields). Supports multiple words within tags. Also allows in-post tagging of words by enclosing them in <tag> tags.
Version: 1.1
Date: July 16th, 2005
Author: Broobles
Author URI: http://www.broobles.com
Contributors: Artur Ortega
*/
function wp_tags($text) {
$wptag_url = $GLOBALS['wptag_url'];
$tag_pattern = $GLOBALS['wptag_tagpattern'];
$tags_pattern = $GLOBALS['wptag_tagspattern'];
$tags_count = 0;
$taglist_exists = 0; # Set to 1 if the tags list is present
$tags = array();
# Check for in-post <tag> </tag>
if (preg_match_all ($tag_pattern, $text, $matches)) {
for ($m=0; $m<count($matches[0]); $m++) {
$ttags = array_filter( array_map("trim", explode(",", $matches[2][$m])) );
for ($i = 0; $i<count($ttags); $i++) {
if( in_array($ttags[$i], $tags) ) continue;
$tags[] = $ttags[$i];
}
$text = str_replace($matches[0][$m],$matches[2][$m],$text);
}
}
# Check for <tags> </tags>
if (preg_match ($tags_pattern, $text, $matches)) {
$taglist_exists = 1;
$ttags = array_filter( array_map("trim", explode(",", $matches[2])) );
for ($i=0; $i<count($ttags); $i++) {
if( in_array($ttags[$i], $tags) ) continue;
$tags[] = $ttags[$i];
}
// specified flickr items
if(preg_match("/^flickr:[\s]*([0-9]{1,2})$/i", $tags[count($tags)-1], $mt)){
$rows = intval($mt[1]);
if(empty($rows)){
$GLOBALS['flickr_display'] = false;
}else{
$GLOBALS['flickr_maxrows'] = $rows;
}
array_pop($tags);
}
// hide techno tags
if(preg_match("/^notag$/i", $tags[count($tags)-1])){
$GLOBALS['wptag_display'] = false;
array_pop($tags);
}
}
$tags = array_map("strip_tags", $tags);
$GLOBALS['flickr_tags'] = $tags;
if(isset($GLOBALS['wptag_display']) && empty($GLOBALS['wptag_display'])){
$text = preg_replace($tags_pattern, "", $text);
return $text;
}
$tags_count = count($tags);
# If tags were found, include them in the post
if ($tags_count>0) {
if(!empty($GLOBALS["xoopsModuleConfig"]["do_tag"]) && @include_once XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php"){
for($i=0; $i<$tags_count; $i++){
$tags[$i] = "<a href=\"".XOOPS_URL."/modules/wordpress/view.tag.php?term=".urlencode(encoding_wp2xoops($tags[$i]))."\">".$tags[$i]."</a>";
}
}else{
for($i=0; $i<$tags_count; $i++){
$tags[$i] = sprintf($wptag_url, urlencode($tags[$i]), $tags[$i]);
}
}
$technotags = '<div class="wp_tags"><span class="tag_title">'.$GLOBALS['wptag_title']. '</span> <span class="tag_item">' . implode(", ", $tags).'</span></div>';
if ($taglist_exists == 1) {
$text = preg_replace($tags_pattern, $technotags, $text);
} else {
$text .= $technotags;
}
}
return $text;
}
add_filter('the_content', 'wp_tags');
// prevent duplicated tag handling
add_action('plugins_loaded', 'wp_skip_wptag_hanlders');
$GLOBALS['wp_wptag_handlers'] = array('simpleTags');
function wp_skip_wptag_hanlders(){
foreach($GLOBALS['wp_wptag_handlers'] as $handler){
if(function_exists($handler)){
remove_filter('the_content',$handler);
}
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?