[wordpress插件] ajax-extendAjax扩展

wordpress 插件 文章 2020-02-13 15:20 538 0 全屏看文

AI助手支持GPT4.0

评分

0

0

描述

ajax-extend allows you call functions, a function in one plugin or a function you write or even a core wordpress function, via Ajax, in the easiest way.

ajax-extend允许您以最简单的方式通过Ajax调用函数,一个插件中的函数或编写的函数,甚至是核心wordpress函数。

Example: The javascript code:

示例:javascript代码:

$j.ajax( { url : home_url, type : 'POST', dataType : 'html', data : { 'ajax_extend_mark' : 1, /* this is indispensable if you want ajax-extend to call the function you need. *

$ j.ajax({url:home_url,type:'POST',dataType:'html',data:{'ajax_extend_mark':1,/ *如果您想让ajax-extend调用您需要的函数,这是必不可少的。*

/ 'ajax_extend_action' : 'my_function', /* the function name (a WP core function, or a function in one plugin. any functions loaded by wp()) */ 'name' : 'sunjianle', }, success : function

/'ajax_extend_action':'my_function',/ *函数名称(WP核心函数,或一个插件中的函数。wp()加载的任何函数)* /'name':'sunjianle',},success:function

(data, textStatus, errorThron) { alert(data); } });

(data,textStatus,errorThron){alert(data);}});

The background PHP code:

后台PHP代码:

function my_function() { $name = $_POST["name"];

函数my_function(){$ name = $ _POST [“ name”];

echo "Hello, " .

回声“你好,”。

$name;

$ name;

global $wpdb;

全局$ wpdb;

$query_sql = "select user_login from wp_users limit 0,10";

$ query_sql =“从wp_users限制0,10中选择user_login”;

$users = $wpdb->get_results($wpdb->prepare($query_sql));

$ users = $ wpdb-> get_results($ wpdb-> prepare($ query_sql));

foreach($users as $user){ echo $users->user_login;

foreach($ users as $ user){echo $ users-> user_login;

} }

}}

安装步骤

Automatic install: Using the WordPress dashboard * Login to your weblog * Go to Plugins * Select Add New * Search for ajax-extend * Select Install * Select Install Now * Select Activate Plugin

自动安装:使用WordPress仪表板*登录您的博客*转到插件*选择添加新内容*搜索ajax扩展*选择安装*选择立即安装*选择激活插件

Manual: * Upload “ajax-extend” folder to the “/wp-content/plugins/” directory.

手册:*将“ ajax-extend”文件夹上载到“ / wp-content / plugins /”目录。

* Activate the plugin through the “Plugins” menu in WordPress.

*通过WordPress中的“插件”菜单激活插件。

下载地址

https://downloads.wordpress.org/plugin/ajax-extend.zip

https://downloads.wordpress.org/plugin/ajax-extend.zip

-EOF-

AI助手支持GPT4.0