我想使用PHP图像处理功能更改图像的"色调".哪个是适用的正确过滤器?
注意:我来自Photoshop的背景,所以如果我对"色调"的解释与其他不同,这就是我的意思......
在Photoshop中,您可以使用"Hue"滤镜来更改图像的颜色,而不会实际影响图像的设计.
我目前正在使用下面的功能重新着色我的图像,但由于它完全重新绘制图像,失去了设计,因此无法满足我的需求.
function set_theme_color_header($hex)
{
$info = hexToRGB($hex); //utility function that converts hex to rgb
$token = "header.gif";
$img = imagecreatefromgif("header-template.gif";
$color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
imagecolorset($img, 0, $info["red"], $info["green"], $info["blue"]);
imagegif($img, $token);
}
?>
Run Code Online (Sandbox Code Playgroud) 当打电话给雅虎网络服务(http://boss.yahooapis.com/ysearch)以返回数据集时,是否可以设置超时并在程序结束后退出例程?
jQuery.getJSON("http://boss.yahooapis.com/ysearch/...etc",
function (data) {
//result set here
});
Run Code Online (Sandbox Code Playgroud) 下面的函数使用"test-backup.ini"文件,解析它并通过update_option()方法将值输入到DB中.
但是,当ini文件的值包含特殊字符,如感叹号(!)和等号(=)(以及其他我猜的)时,它会在parse_ini_file($ file)中抛出PHP语法错误:
语法错误,意外"!"等...
例如,将此内容作为test-backup.ini文件...
[settings]
line1 = asc
line2 = /*.blog ul li {margin-bottom:0 !important;}*/
line3 = true
line4 = <meta name="google-site-verification" content="" />
Run Code Online (Sandbox Code Playgroud)
我在line2上遇到"!"的语法错误 并在第4行为"="
在将$文件传递给parse_ini_file()以处理这些字符时,我应该如何过滤$ file,以便在传递给update_option()时调用它们?
到目前为止,我发现的是:
字符{} |&〜![()"不得在键中的任何位置使用,并且在值中具有特殊含义.
$file = WP_PLUGIN_DIR.'/test/test-backup.ini';
if (file_exists($file) && is_readable($file))
{
$ini_array = parse_ini_file($file); //errors when value contains =, !, etc
foreach ($ini_array as $key=>$value) {
update_option($key, $value);
}
echo 'The settings have been saved';
}
else
{
echo 'alternate response here';
}
Run Code Online (Sandbox Code Playgroud)
?>
我有一个包含一系列span标签的div,每个标签包含一串文本.我想将jQuery单击事件附加到所有跨度,以便在单击任何跨度内的文本时,将自动选择整行文本(dom> innerText对象)以方便拖放或复制/粘贴文本字符串.
例如,我的内容是......
<div id="mySpans">
<span> This is my text </span>
<span> This is my text </span>
</div>
Run Code Online (Sandbox Code Playgroud)
如果在跨度内的任何文本上单击光标,我想选择该跨度内的文本,以便可以将其拖放(没有span标记,只是跨度的innerText)作为副本.
jQuery有一个简单的方法吗?
编辑:我正在努力完成的更详细的解释:
在没有脚本帮助的情况下,为了复制文本块,用户必须手动拖动在文本块中选择选择矩形.然后,文本被选中,表示点击和拖动事件将拾取所有选定的文本.因此,我正在尝试创建脚本,允许单击文本以自动为用户选择文本,这样他们就不必自己手动执行.
我想在一个交换机案例中传递多个值.我意识到我不可能这样做.还有另一种方法,没有将每个案例放在网上吗?
switch(get_option('my_template'))
{
case 'test1', 'test2':
return 850;
break;
default:
return 950;
}
Run Code Online (Sandbox Code Playgroud) 下面的代码几乎完美无缺,但是我的一个页面上的页面标题的价值在几页刷新后仍然是空的...它坚持一段时间,然后它似乎重置为空.我想我必须在下面的代码中有冲突,但我无法理解它.
我允许用户通过自定义的"帖子/页面标题输入字段"为帖子和页面设置自定义页面标题.任何人都可以看到一个明显的问题,可能是将页面标题重置为空白?
// ===================
// = POST OPTION BOX =
// ===================
add_action('admin_menu', 'my_post_options_box');
function my_post_options_box() {
if ( function_exists('add_meta_box') ) {
//add_meta_box( $id, $title, $callback, $page, $context, $priority );
add_meta_box('post_header', 'Custom Post Header Code (optional)', 'custom_post_images', 'post', 'normal', 'low');
add_meta_box('post_title', 'Custom Post Title', 'custom_post_title', 'post', 'normal', 'high');
add_meta_box('post_title_page', 'Custom Post Title', 'custom_post_title', 'page', 'normal', 'high');
add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'core');
add_meta_box('categorydiv', __('Page Options'), 'post_categories_meta_box', 'page', 'side', 'core');
}
}
//Adds the custom images box
function custom_post_images() {
global …Run Code Online (Sandbox Code Playgroud) 以下函数旨在将rel="nofollow"属性应用于所有外部链接,而不是内部链接,除非该路径与$my_folder下面定义的预定义根URL匹配.
所以考虑到变量......
$my_folder = 'http://localhost/mytest/go/';
$blog_url = 'http://localhost/mytest';
Run Code Online (Sandbox Code Playgroud)
而内容......
<a href="http://localhost/mytest/">internal</a>
<a href="http://localhost/mytest/go/hostgator">internal cloaked link</a>
<a href="http://cnn.com">external</a>
Run Code Online (Sandbox Code Playgroud)
最终结果,更换后应该......
<a href="http://localhost/mytest/">internal</a>
<a href="http://localhost/mytest/go/hostgator" rel="nofollow">internal cloaked link</a>
<a href="http://cnn.com" rel="nofollow">external</a>
Run Code Online (Sandbox Code Playgroud)
请注意,第一个链接不会更改,因为它是一个内部链接.
第二行上的链接也是一个内部链接,但由于它匹配我们的$my_folder字符串,它nofollow也会得到.
第三个链接是最简单的,因为它与它不匹配blog_url,它显然是一个外部链接.
但是,在下面的脚本中,我的所有链接都已获得nofollow.如何修复脚本以执行我想要的操作?
function save_rseo_nofollow($content) {
$my_folder = $rseo['nofollow_folder'];
$blog_url = get_bloginfo('url');
preg_match_all('~<a.*>~isU',$content["post_content"],$matches);
for ( $i = 0; $i <= sizeof($matches[0]); $i++){
if ( !preg_match( '~nofollow~is',$matches[0][$i])
&& (preg_match('~' . $my_folder . '~', $matches[0][$i])
|| !preg_match( '~'.$blog_url.'~',$matches[0][$i]))){
$result = trim($matches[0][$i],">"); …Run Code Online (Sandbox Code Playgroud) 当我通过此函数运行包含双引号的短语时,它用quot替换引号.
我想完全删除它们(也是单引号).我怎样才能改变这个功能呢?
function string_sanitize($s) {
$result = preg_replace("/[^a-zA-Z0-9]+/", "", $s);
return $result;
}
Run Code Online (Sandbox Code Playgroud)
更新:
Example 1: This is 'the' first example
returns: Thisis030the039firstexample
Errors: Warning: preg_match_all() [function.preg-match-all]: Unknown modifier '0' in C
Example 2: This is my "second" example
returns: Thisismyquotsecondquotexample
Errors: Invalid express in Xpath
Run Code Online (Sandbox Code Playgroud) 我在tinyMCE编辑器中有短代码,括在括号中,如下所示:
[my_shortcode]some text that gets parsed by my shortcode function[/my_shortcode]
Run Code Online (Sandbox Code Playgroud)
是否可以将运行时样式css应用于tinyMCE编辑器内容,以便括号中的任何元素(在我的短代码列表中*)获得特殊的css处理以使它们脱颖而出?
我们的想法是,短代码目前没有特殊的颜色或格式,以区别于任何周围的文本,除非它们更突出,否则很难使用它们.
我的短代码列表(示例):
[my_shortcode],[my_shortcode_2],[my_shortcode_3]
Run Code Online (Sandbox Code Playgroud)
更新:我将采取我可以得到的这个,但理想情况下,我只想将样式应用于括号,而不是括号缠绕的文本.所以我只想将运行时css样式应用于短代码括号:例如[my_shortcode]和[/ my_shortcode],并保留它们单独包含的文本.
php ×6
jquery ×3
css ×1
getjson ×1
ini ×1
preg-match ×1
preg-replace ×1
regex ×1
shortcode ×1
syntax-error ×1
timeout ×1
tinymce ×1
wordpress ×1