Skip to content

Instantly share code, notes, and snippets.

View ErikBernskiold's full-sized avatar

Erik Bernskiold ErikBernskiold

View GitHub Profile
@ErikBernskiold
ErikBernskiold / WordPress Non-Admins Can't Access Dashboard
Created December 9, 2016 13:47
Simple code to prevent non-admins to access /wp-admin/, perfect for login-protected sites.
<?php
/**
* Class-based
**/
add_action( 'init', array( $this, 'prevent_non_admin_dashboard_access' ) );
public function prevent_non_admin_dashboard_access() {
if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
@ErikBernskiold
ErikBernskiold / jQuery Scroll Anchor Link Click
Created January 5, 2016 12:51
Smooth scrolling animation for anchor links.
@ErikBernskiold
ErikBernskiold / gist:0ae0ee20e5c739d4a75b
Created September 19, 2015 14:09
Ilmenite Cookie Consent: Update Text
<?php
/**
* Change Cookie Consent Text
*/
function ilcc_change_consent_text( $text ) {
$text = __( 'This is my new text that I want', 'MYTEXTDOMAIN' );
return $text;
}
@ErikBernskiold
ErikBernskiold / Enqueue Main Stylesheet in Functions
Created January 15, 2015 16:36
Enqueue Main Stylesheet in Functions
if ( ! function_exists( 'mysite_enqueue_styles' ) ) :
/**
* Stylesheets
*
* Registers and enqueues theme stylesheets.
**/
function mysite_enqueue_styles() {
// Register
// wp_register_style( $handle, $src, $deps, $ver, $media );
wp_register_style( 'style', get_stylesheet_uri, false, '1.0', 'all' );
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: 'assets/js/main.js',
dest: 'assets/js/main.min.js'
}
@ErikBernskiold
ErikBernskiold / WP-VCS-.gitignore
Created July 8, 2014 15:08
.gitignore for version controlled WordPress
###################
# .gitignore
#
# We include all core files in the project repo and split passwords
# into ignored situational configurations so that we can store the wp-config.
###################
# WordPress #
#############
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
Swedish
nplurals=2; plural=(n != 1);
English
nplurals=2; plural=(n != 1);
List:
http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms
@ErikBernskiold
ErikBernskiold / WordPress: Gravity Forms SASS Base
Created September 15, 2013 09:34
Basic custom styles, in SASS for Gravity Forms
/**
* Forms
*
* Styling for Gravity Forms
*/
.gform_body {
ul {
margin: 0;
padding: 0;
@ErikBernskiold
ErikBernskiold / gist:6317193
Created August 23, 2013 09:13
WordPress: List all hooks for a filter/action
function dump_hook( $tag, $hook ) {
ksort($hook);
echo "<pre>>>>>>\t$tag<br>";
foreach( $hook as $priority => $functions ) {
echo $priority;
foreach( $functions as $function )