template_redirect
function redirect_page_standard() {
wp_redirect( get_site_url() . '/notice.html', 301 );
}
add_action( 'template_redirect', 'redirect_page_standard' );
function redirect_page_standard() {
wp_redirect( get_site_url() . '/notice.html', 301 );
}
add_action( 'template_redirect', 'redirect_page_standard' );
require_once(dirname(dirname(__FILE__)).'/wp-load.php');
// Adds a dropdown to filter users based on a meta field
function add_recommand_filter_into_user_table() {
global $pagenow;
if (is_admin() && $pagenow == 'users.php') {
$optNone = '';
$optYes = '';
$optNo = '';
if(isset($_GET['recommand'])){
if(strcmp($_GET['recommand'],'1') == 0){
$optYes = 'selected="selected"';
}else{
$optNo = 'selected="selected"';
}
}else{
$optNone = 'selected="selected"';
}
echo '';
}
}
add_action('restrict_manage_users', 'add_recommand_filter_into_user_table');
// Updates user query based on filtering criteria
function query_recommand_query_from_user_table($query) {
global $pagenow;
if (is_admin() && $pagenow == 'users.php' && isset($_GET['recommand'])) {
$recommandValue = wp_strip_all_tags($_GET['recommand']);
if(strcmp($recommandValue,'') != 0){
$meta_query = array(
array(
'key' => RECOMMAND_KEY,
'value' => $recommandValue
)
);
$query->set('meta_key', RECOMMAND_KEY);
$query->set('meta_query', $meta_query);
}
}
}
add_filter('pre_get_users','query_recommand_query_from_user_table');
add_action( 'wp_ajax_my_action', 'my_action_callback' );
function my_action_callback() {
global $wpdb; // this is how you get access to the database
$whatever = intval( $_POST['whatever'] );
$whatever += 10;
echo $whatever;
wp_die(); // this is required to terminate immediately and return a proper response
}
jQuery(document).ready(function($) {
var data = {
'action': 'my_action',
'whatever': 1234
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
alert('Got this from the server: ' + response);
});
});
function reg_scripts() {
wp_enqueue_style( 'bootstrapstyle', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'bootstrapthemestyle', get_template_directory_uri() . '/css/bootstrap-theme.min.css' );
wp_enqueue_script( 'bootstrap-script', get_template_directory_uri() . '/js/bootstrap.min.js', array(), true );
}
add_action('wp_enqueue_scripts', 'reg_scripts');