Skip to content

Instantly share code, notes, and snippets.

@graphikuz
graphikuz / gist:18e383e96ea32944dc7b
Created August 11, 2014 10:11
Wordpress: Disable automatic formating
<?php
/**
* Disable automatic formating
*/
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
?>
@graphikuz
graphikuz / gist:47468b90f37ad9501789
Created August 11, 2014 09:56
Wordpress: Disable Google Analytics for logged in users
<?php
/**
* Disable Google Analytics for logged in users
*/
function ga() {
if ( !is_user_logged_in() ) { // not for logged in users
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX']); // insert your Google Analytics id here
@graphikuz
graphikuz / gist:e44c05d5a837546a4fc2
Created August 11, 2014 09:52
HTML: Add facebook like button
<script src="http://connect.facebook.net/sl_SI/all.js#xfbml=1"></script>
<fb:like href="<?php echo get_permalink()?>"; layout="standard" show_faces="true" width="450" font="arial"></fb:like>
@graphikuz
graphikuz / gist:620f656e0b72bf81526e
Created August 11, 2014 09:46
Wordpress: Strig IMG from content
<?php
/**
* Strip IMG fron content
*/
echo preg_replace('/<img[^>]+./' , '' , get_the_content());
?>
@graphikuz
graphikuz / gist:177cda8fca5f54d0934f
Created August 11, 2014 09:45
Wordpress: Hide admin help tab
<?php
/**
* Hide admin help tab
*/
function hide_help() {
echo '&lt;style type="text/css">
#contextual-help-link-wrap { display: none !important; }
&lt;/style>';
}
add_action('admin_head', 'hide_help');
@graphikuz
graphikuz / gist:78f61ad478dc4087871f
Created August 11, 2014 09:44
Wordpress: Add custom menus to theme
<?php
/**
* Add custom menus to theme
* @function.php
*/
function my_custom_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' )
@graphikuz
graphikuz / gist:9462f0b8397af12d8ee1
Created August 11, 2014 09:34
WordpresS: Add/remove contact info fields in user proofile
<?php
/**
* Add/remove contact info fields in user proofile
*/
function new_contactmethods( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter'; // Add Twitter
$contactmethods['facebook'] = 'Facebook'; // Add Facebook
unset($contactmethods['yim']); // Remove YIM
unset($contactmethods['aim']); // Remove AIM
unset($contactmethods['jabber']); // Remove Jabber
@graphikuz
graphikuz / gist:4968e7a40f5de78f8c7b
Created August 11, 2014 09:32
Wordpress: Custom Admin styleshhet
<?php
/**
* Custom Admin styleshhet
*/
function customAdmin() {
$url = get_settings('siteurl');
$url = $url . '/wp-content/themes/my-theme/styles/wp-admin.css';
echo '&lt;!-- custom admin css -->
&lt;link rel="stylesheet" type="text/css" href="' . $url . '" />
&lt;!-- /end custom adming css -->';
@graphikuz
graphikuz / gist:b3193c93a038a91f2b96
Created August 11, 2014 09:29
Wordpress: Hide update notifications from non admin users
<?php
/**
* Hide update notifications from non admin users
*/
if ( !current_user_can('administrator') ) {
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
?>
@graphikuz
graphikuz / gist:a6c798b0013c9e9b2654
Created August 11, 2014 09:25
Wordpress: Add more buttons to WP editor
<?php
/**
* Strip IMG from content
*/
echo preg_replace('/<img[^>]+./' , '' , get_the_content());
?>