Ajaxize will allow you to ajaxize almost any php function on your site.
It can be a plugin, a function you wrote, or even a core wordpress function.
There are some (obvious or less obvious) limitations currently:
- Functions must return valid HTML - this will be called in php and returned via the Ajax call
- Functions cannot accept any parameters (at least at the moment)
Copy & paste this div below ";
$output_div = "";
$content .= "" . htmlentities($output_div) . "
";
$content .= " Function output (via ajaxize):
";
$content .= '';
$content .= str_replace('><', '> If you see this message. Something is not working <', $output_div);
$content .= '
';
return $content;
}
function ajaxize_admin_add_page() {
global $ajaxize_this_hook;
$ajaxize_this_hook = add_options_page('Ajaxize settings', 'Ajaxize', 'manage_options', 'ajaxize_this', 'ajaxize_options_page');
}
// display the admin options page
function ajaxize_options_page() { ?>
";
}
function plugin_setting_ajax_referer_check () {
$options = get_option('ajaxize_this_options');
if ($options['ajax_referer_check'] == 1) { $checked = "checked='checked'"; }
echo "";
}
// validate our options
function ajaxize_options_validate_secret_key($input) {
$options = get_option('ajaxize_this_options');
$options['ajax_referer_check'] = 0;
// doing per-field regex validation.
// You can add / change validation rules here
foreach ($input as $k => $v) {
if (preg_match('/ajax_referer_check/i', $k)) { $options[$k] = $v; continue; }
if (preg_match('/^[a-z0-9]{12,}$/i', $v)) {
$options[$k] = $v;
}
else {
add_settings_error('secret_key','ajaxize_this_err','Secret Key must be alphanumeric and at least 12 characters long','error');
}
}
return $options;
}
function ajaxize_this_validate_function($fn_name) {
if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $fn_name)) {
if (! function_exists($fn_name)) {
add_action('admin_notices', create_function('', 'echo \'\';'));
}
else return $fn_name;
}
else {
add_action('admin_notices', create_function('', 'echo \'Invalid function name. Make sure to remove () and any extra spaces.
\';'));
}
}
add_filter('contextual_help', 'ajaxize_this_help', 10, 3);
// help page for ajaxize plugin (taken from FAQ)
function ajaxize_this_help($contextual_help, $screen_id, $screen) {
global $ajaxize_this_hook;
if ($screen_id == $ajaxize_this_hook) {
$contextual_help = <<Ajaxize
Ajaxize will allow you to ajaxize almost any php function on your site.
It can be a plugin, a function you wrote, or even a core wordpress function.
Frequently Asked Questions
Please check out the Frequently Asked Questions page for more info.
EOD;
}
return $contextual_help;
}
/* END PLUGIN SETTINGS */
?>