Author:
erics, January 24th, 2020
|
add_action('admin_init', 'redirect_non_admin_users' ); function redirect_non_admin_users() { if ( ! current_user_can( ‘manage_options’ ) && (‘/wp-admin/admin-ajax.php’ != $_SERVER[‘PHP_SELF’]) ) { wp_redirect ("Your_Destination_URL_Here"); die(); exit; } } |
Categories: How-To's, Technology Tags: /wp-admin/profile.php, Access, ajax, Disable, manage_options, Profile, profile.php, redirect, Subscriber, WordPress, WP, wp_redirect, wp-admin
|
No comments
Author:
erics, September 24th, 2015
The key is to send a response header like this: Access-Control-Allow-Origin: * In the Apache web server, one enables this via the following directive: Header set Access-Control-Allow-Origin * This requires the use of mod_headers, which is enabled by default in Apache. For example:
|
LoadModule headers_module modules/mod_headers.so ... <VirtualHost *:80> ServerName www.your.domain ServerAlias *your.domain DocumentRoot /var/www/yourdomain DirectoryIndex index.php index.html Header set Access-Control-Allow-Origin * </VirtualHost> |
Categories: How-To's, Technology Tags: Access-Control-Allow-Origin, ajax, apache, cross, cross-site, cross-site javascript, headers, howto, http, javascript, Load, mod_headers, tips, xsite
|
No comments
Author:
erics, July 9th, 2013
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
/* Plugin Name: Your New Plugin Plugin URI: http://www.yoursite.com Version: 1.0 Description: Your new plugin's description... Author: Your Name Author URI: http://www.yoursite.com License: Copyright 2013 Your Name (email : you@yoursite.com) */ add_action('wp_ajax_nopriv_ajaxTest', 'ajaxTest'); add_action('wp_ajax_ajaxTest', 'ajaxTest'); function ajaxTest() { ob_clean(); // generate the response $response = json_encode( array( 'status' => 0, 'msg' => 'AJAX TEST SUCCESS!' ) ); // response output header( "Content-Type: application/json" ); echo $response; exit; } Call with: $ajaxurl = admin_url("admin-ajax.php") $ajaxurl?action=ajaxTest // |
Happy Coding!
Categories: How-To's, Technology Tags: ajax, howto, Plugin, tips, WordPress
|
No comments
Author:
erics, September 26th, 2011
Just an addendum to the previous post about ajax loader spinner images…
|
jQuery('.page-number, .pgNext:not(.pgEmpty)').live("click", function (event) { jQuery('#Spinner').fadeIn(); }); |
Categories: How-To's, Technology Tags: ajax, howto, javascript, JQuery, jquery.pager, JS, Loader, Pager, Spinner, tips
|
No comments
Author:
erics, September 23rd, 2011
GET Resources http://code.jquery.com/jquery-1.6.4.min.js http://jqueryui.com/resources/download/jquery-ui-1.10.1.custom.zip LOAD Resources
|
<LINK rel="stylesheet" HREF="/css/smoothness/jquery-ui-1.8.14.custom.min.css"> <script src="/js/jquery-1.6.4.min.js"></script> <script src="/js/jquery-ui-1.8.16.custom.min.js"></script> |
HTML Substitute your own loader graphic from http://www.ajaxload.info/
|
<img src="//www.ericmichaelstone.com/wp-content/uploads/2013/02/ajax-loader.gif" alt="Please wait..." class="Spinner hidden" id="Spinner-first" /> |
CSS
|
.Spinner { margin: 0; padding: 0; border: 0; } .Spinner.hidden { display: none; } |
JS Show the spinner called “first”: jQuery(‘#Spinner-first’).fadeIn(); Hide the spinner called “first”: jQuery(‘#Spinner-first’).fadeOut(); Hide all spinners that start with an ID of “Spinner”: jQuery(‘[id^=Spinner]’).fadeOut(); That’s All Folks…
Categories: How-To's, Technology Tags: ajax, ajax-loader.gif, CSS, gif, html, img, javascript, JQuery, jQuery UI, jQueryUI, JS, Loader, Spinner
|
1 comment
Author:
erics, May 4th, 2011
Use the “dataFilter” Ajax option given the following server reply: { status: 17, result: “You are not logged in” } [code] var $tabs = jQuery(‘#menutabs’).tabs({ ajaxOptions: { dataFilter: function(server_json_reply){ var data = jQuery.parseJSON(server_json_reply); if (data.status == 17) { alert(‘Your session has timed out and you have been logged off.’); window.location = “/”; } return data.result; […]
Categories: How-To's, Technology Tags: ajax, howto, javascript, JQuery, jQuery Tabs, jQuery UI, JSON, tips
|
No comments
Author:
erics, September 29th, 2009
Some examples of how to access the option values and text in an HTML SELECT via javascript: onchange=”groupsFilter(this.options[this.selectedIndex].value); return false;” onChange=”if (this.options[this.selectedIndex].value != ”) submit()” Take the option text currently highlighted and use it to populate another location in the web page: replaceSpan(‘unit1’,this.options[this.selectedIndex].text);
Categories: How-To's, Technology Tags: ajax, howto, html, javascript, onchange, select, tips
|
No comments
Author:
erics, September 29th, 2009
Tuesday, 1:52am…Finally got the Groups filter working! It allows the user to create as many groups as they want, then allows them to assign each medication to as many groups as they want. Then can use the groups to filter on the Medications page. Tomorrow I will write the code to a group of meds […]
Categories: PainMinder™, Rants Tags: ajax, features, Health, PainMinder, php
|
No comments