Skip to content

Instantly share code, notes, and snippets.

View nicksleap's full-sized avatar
😏
джаваскриптезер

Nicholay Portnov nicksleap

😏
джаваскриптезер
  • Freelancer
  • Tbilisi, Georgia
View GitHub Profile
<?php
// don't allow users to access WordPress admin
add_action('admin_init', 'endo_hide_dashboard');
function endo_hide_dashboard() {
if ( ! current_user_can( 'manage_options' ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
wp_redirect(home_url()); exit;
}
}
// getCookie(), setCookie(), deleteCookie()
// возвращает cookie если есть или undefined
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
))
return matches ? decodeURIComponent(matches[1]) : undefined
@fedesilvaponte
fedesilvaponte / wp_pagination.php
Created August 2, 2012 11:40
WP Pagination without plugin
<?php
function pagination($prev = '«', $next = '»') {
global $wp_query, $wp_rewrite;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
$pagination = array(
'base' => @add_query_arg('paged','%#%'),
'format' => '',
'total' => $wp_query->max_num_pages,
'current' => $current,
'prev_text' => __($prev),