Skip to content

Instantly share code, notes, and snippets.

@gish
gish / gist:3999716
Created November 2, 2012 09:24
Testar kod
div {
color: red;
}
@gish
gish / gist:4059989
Created November 12, 2012 15:33
JSHint pre-commit hook
#!/bin/bash
cd $(git rev-parse --show-toplevel)
# JSHINT
echo -n "Jshint..."
JSHINTRESULT=`jshint .`
JSHINT=$?
if [ $JSHINT != 0 ]
then
<?php
public function add_endpoints( )
{
add_rewrite_endpoint( 'galleri', EP_PERMALINK );
}
add_action( 'init', 'add_endpoints');
<?php
$fields = array(
'countries' => array(
'type' => 'select',
'groups' => array(
array(
'name' => 'Europe'
'options' => array(
'no' => 'Norge',
'sv' => 'Sverige'
<?php
// Hämta en placeholder-bild
$image_url = 'http://placehold.it/640x480';
// Spara bilden till inlägget med ID 1
$image_html = media_sideload_image( $image_url, 1, 'En placeholder-bild' );
// Klart!
?>
<?php
// Anta att vi har bildens binära data i $binary_image.
// ID på inlägg filen ska höra till
$post_id = 1;
// Filändelse/typ
$file_type = 'image/jpeg';
// Filnamn
@gish
gish / functions-pattern.php
Created March 28, 2013 10:11
Functions file pattern for WordPress
<?php
add_action(
'plugins_loaded',
array( My_Plugin::get_instance(), 'setup' )
);
class My_Plugin
{
/**
@gish
gish / .htaccess
Created April 16, 2013 07:17
Forbid access to WordPress license and readme files
<IfModule mod_rewrite.c>
RewriteRule ^readme.html - [F]
RewriteRule ^licens(.*).txt - [F]
</IfModule>
@gish
gish / remove-wp-generator-tag.php
Created April 16, 2013 07:20
Remove WP generator tag
<?php
if( !is_admin() )
{
remove_action( 'wp_head', 'wp_generator' );
}
@gish
gish / wp-config.php
Created May 29, 2013 11:03
WP-konfiguration för multistage
<?php
define( 'ENVIRONMENT', getenv( 'ENVIRONMENT' ) ? getenv( 'ENVIRONMENT' ) : 'production' );
define( 'DOMAIN', $_SERVER['HTTP_HOST'] );
// Här är default-inställningarna. De kan overridas för varje stage
$settings = array(
// Sökvägar
'WP_SITEURL' => 'http://' . DOMAIN . '/wordpress',
'WP_HOME' => 'http://' . DOMAIN,
'WP_CONTENT_DIR' => dirname( __FILE__ ) . '/content',