{"id":14512,"date":"2011-08-18T13:33:59","date_gmt":"2011-08-18T13:33:59","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/ajax-extend\/"},"modified":"2011-08-20T08:20:06","modified_gmt":"2011-08-20T08:20:06","slug":"ajax-extend","status":"closed","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/ajax-extend\/","author":8174016,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0","stable_tag":"trunk","tested":"3.2.1","requires":"3.1","requires_php":"","requires_plugins":"","header_name":"ajax-extend","header_author":"sunjianle","header_description":"","assets_banners_color":"","last_updated":"2011-08-20 08:20:06","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1724,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[221,5878,1341,229,5879,2391],"plugin_category":[59],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-14512","plugin","type-plugin","status-closed","hentry","plugin_tags-ajax","plugin_tags-core-functions","plugin_tags-functions","plugin_tags-javascript","plugin_tags-plugin-functions","plugin_tags-plugins","plugin_category-utilities-and-tools","plugin_committers-sunjianle"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/ajax-extend.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>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.<\/p>\n <p>Example: The javascript code:<\/p>\n <pre>\n$j.ajax( {     url : home_url,     type : 'POST',     dataType : 'html',     data : {         'ajax&#095;extend&#095;mark' : 1, \/* this is indispensable if you want ajax-extend to call the function you need. *\/         'ajax&#095;extend&#095;action' : 'my&#095;function', \/* the function name (a WP core function, or a function in one plugin. any functions loaded by wp()) *\/         'name' : 'sunjianle',     },     success : function(data, textStatus, errorThron) {         alert(data);     } }); <\/pre>\n <p>The background PHP code:<\/p>\n <pre>\nfunction my_function() {     $name = $_POST[\"name\"];     echo \"Hello, \" . $name;      global $wpdb;     $query_sql = \"select user_login                 from wp_users                 limit 0,10\";     $users = $wpdb-&gt;get_results($wpdb-&gt;prepare($query_sql));     foreach($users as $user){         echo $users-&gt;user_login;     } } <\/pre>\n\n<!--section=installation-->\n<p>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<\/p>\n <p>Manual: * Upload \"ajax-extend\" folder to the \"\/wp-content\/plugins\/\" directory. * Activate the plugin through the \"Plugins\" menu in WordPress.<\/p>\n\n<!--section=faq-->\n<h4>How to do with ajax-extend?<\/h4>\n <p>The javascript code:<\/p>\n <pre>\n$j.ajax( {     url : home_url,     type : 'POST',     dataType : 'html',     data : {         'ajax&#095;extend&#095;mark' : 1, \/* this is indispensable if you want ajax-extend to call the function you need. *\/         'ajax&#095;extend&#095;action' : 'my&#095;function', \/* the function name (a WP core function, or a function in one plugin. any functions loaded by wp()) *\/         'name' : 'sunjianle',     },     success : function(data, textStatus, errorThron) {         alert(data);     } }); <\/pre>\n <p>The background PHP code:<\/p>\n <pre>\nfunction my_function() {     $name = $_POST[\"name\"];     echo \"Hello, \" . $name;      global $wpdb;     $query_sql = \"select user_login                 from wp_users                 limit 0,10\";     $users = $wpdb-&gt;get_results($wpdb-&gt;prepare($query_sql));     foreach($users as $user){         echo $users-&gt;user_login;     } } <\/pre>\n <h4>How can I test if ajax-extend is working?<\/h4>\n <h4>How does ajax-extend work?<\/h4>\n <pre>\nadd_action( \"wp\", \"ajax_operation\" );  function ajax_operation() {     \/*      * ajax_extend_mark : \n     * ajax_extend_action :      *\/     if(isset($_REQUEST[\"ajax_extend_mark\"]))     {         $function_name = $_REQUEST[\"ajax_extend_action\"];         if(!function_exists($function_name))             return;         call_user_func($function_name);         die();     }    \n} <\/pre>\n <p>That is the core code and the all code of ajax-extend. What you need to understand the code above.<\/p>\n <h4>Are there any limitations to which functions I can use?<\/h4>\n <p>Yes. 1. Functions must return valid HTML - this will be called in php and returned via the Ajax call 2. Functions cannot accept any parameters (at least at the moment)<\/p>\n\n<!--section=changelog-->\n<h4>1.0<\/h4>\n <p>First release<\/p>","raw_excerpt":"&#039;ajax-extend&#039; allows you call functions, a function in one plugin or a function you write or even a core wordpress function, via Ajax, in th &hellip;","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/14512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=14512"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/sunjianle"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=14512"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=14512"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=14512"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=14512"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=14512"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=14512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}