小编Dai*_*thí的帖子

wordpress插件 - >调用未定义的函数wp_get_current_user()

我正在尝试使用func wp_get_current_user()在我的插件中获取当前用户信息.但我得到了 Call to undefined function wp_get_current_user()

显然这种情况正在发生,因为/wp-includes/pluggable包含该函数的文件在加载插件之后才会加载.

有关如何在我的插件中获取用户详细信息的任何想法?

php wordpress wordpress-plugin

27
推荐指数
4
解决办法
4万
查看次数

wordpress:只在短代码出现的地方加载javascript

有一个有趣的难题.我需要为我的插件加载大约8个javascript文件和相同数量的样式.只有在我的短代码运行时才需要这些.

我试图用print_styles和print_scripts加载它们但是它们没有正确渲染,加上这样做会打破xhtml验证.因此,目前他们加载每个页面,由于所需的文件数量,这样做是不可行的.

在另一个项目中,我在我的插件的index.php文件中编写了一个函数,该文件将获取当前页面,搜索它以查找我的短代码,如果找到它,那么它会打印脚本,但这是一个丑陋的黑客.

有人有任何建议或解决方案吗?任何帮助将不胜感激,问候,Daithi

php wordpress wordpress-plugin

10
推荐指数
3
解决办法
6368
查看次数

jstree contextmenu创建文件/文件夹功能

我试图让用户创建文件或文件夹.因此,当他们右键单击菜单时,上下文菜单将显示:create => file folder

这部分是有效的,问题在于附加到每个上下文菜单的功能.此时单击"文件"或"文件夹"调用:this.create(obj);如何指定类型?我试过了obj.attr("rel","type","folder"),我已经尝试过obj.rslt.rel很多其他人,但我只是在黑暗中拍摄,哈哈.我已经完成了文档,布局很好,但它对解释对象的属性没用.

下面是上下文菜单的代码,类型插件和创建节点的绑定.

    fma_jstree = $("#archive")
.bind("before.jstree", function (e, data) {
    $("#alog").append(data.func + "<br />");
})
.jstree({
    // List of active plugins
    "plugins" : [
    "themes","json_data","ui","crrm","cookies","dnd","search","types","hotkeys","contextmenu"
    //"themes","json_data","ui","crrm","cookies","dnd","search","types","contextmenu"
    ],

    "contextmenu" : {
        items : { // Could be a function that should return an object like this one
            "create" : {
                "separator_before"  : false,
                "separator_after"   : true,
                "label"             : "Create",
                "action"            : false,
                "submenu" :{
                    "create_file" : {
                        "seperator_before" : false,
                        "seperator_after" …
Run Code Online (Sandbox Code Playgroud)

jquery jstree

5
推荐指数
1
解决办法
1万
查看次数

wordpress - 动作钩'预发布帖'?

需要在发布之前更改帖子内容.我可以覆盖本机发布功能,但不想这样做.

我想做的是:

add_action('before_publish_post','my_func');
function my_func($content){
    $content = "new content";
    return $content;
}
Run Code Online (Sandbox Code Playgroud)

我看过'publish_post'钩子,但这只允许我更改帖子内容而不是之前发布.

任何帮助将不胜感激,欢呼

php wordpress

3
推荐指数
1
解决办法
1万
查看次数

php curl使用GET wierd结果发送变种

我正在尝试在远程站点的页面中调用URL.决定使用卷曲.在远程站点上,URL变量显示为:

$_REQUEST   Array
(
    [var1] => val1
    [amp;var2] => val2
    [amp;var3] => val3
)
Run Code Online (Sandbox Code Playgroud)

被调用的网址是:

http://site.com/controller/action.php?var1=val1&var2=val2&var3=val3
Run Code Online (Sandbox Code Playgroud)

请注意,我没有&amp;在网址中使用,但请求全局使用它,或者差不多 - 它amp;代替&amp;并且&不像我使用的那样!不是说它应该有任何一个.

curl对象已登录到表单,设置cookie,在另一页上发布表单,现在这是我必须遵循的最后一个链接.

这是我正在使用的PHP:

    curl_setopt($this->ch, CURLOPT_URL, "http://site.com/controller/action.php?var1=val1&var2=val2&var3=val3");
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($this->ch, CURLOPT_REFERER, "http://site.com/");
    curl_setopt($this->ch, CURLOPT_VERBOSE, 1);
    curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cookie);
    curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookie);
    curl_setopt($this->ch, CURLOPT_POST, 0);
    curl_setopt($this->ch, CURLOPT_HTTPGET, 1);
    $output = curl_exec($this->ch);
    $info = curl_getinfo($this->ch);
Run Code Online (Sandbox Code Playgroud)

在此之后我又运行了另一个curl请求,我仍然登录,因此问题不是cookie.因为使用$ _POST的最后一个请求(登录表单)已经将CURLOPT_POST设置为0并且将CURLOPT_HTTPGET设置为1.这是$ info的输出:

info    Array
(
    [url] => http://site.com/controller/action.php?var1=val1&var2=val2&var3=val3
    [content_type] => text/html; charset=utf-8
    [http_code] => 403
    [header_size] => …
Run Code Online (Sandbox Code Playgroud)

php curl get

2
推荐指数
1
解决办法
5823
查看次数

标签 统计

php ×4

wordpress ×3

wordpress-plugin ×2

curl ×1

get ×1

jquery ×1

jstree ×1