Skip to content

Instantly share code, notes, and snippets.

@graphikuz
graphikuz / gist:9aa19dd84d8a85a19c76
Created August 11, 2014 09:14
Wordpress: Set permalink from functions.php
<?php
/**
* Set permalink from functions.php
*/
function set_permalink(){
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%postname%/');
}
add_action('init', 'set_permalink');
?>
@graphikuz
graphikuz / gist:0622b2d8b460dbc3ce9c
Created August 11, 2014 09:02
Wordpress: Detect Iphone
<?php
/**
* Detect Iphone
*/
global $is_iphone;
if($is_iphone) {
// User in on an iPhone.
}
?>
@graphikuz
graphikuz / gist:e3508e2f322608db40a9
Created August 11, 2014 08:56
Wordpress: Add Custom Stylesheet to Editor
<?php
/**
* Add CSS to Visual Editor.
* The parameter $custom_stylesheet is the name of the stylesheet, relative to the theme root.
* It also accepts an array of stylesheets. It is optional and defaults to ‘editor-style.css’.
*/
$custom_stylesheet = 'css/custom-editor-style.css';
add_editor_style($custom_stylesheet);
@graphikuz
graphikuz / gist:8362112789042e289946
Created August 11, 2014 08:49
Wordpress: Hide Screen Options Tab
<?php
// Hide admin 'Screen Options' tab
function remove_screen_options_tab()
{
return false;
}
add_filter('screen_options_show_screen', 'remove_screen_options_tab');
?>
@graphikuz
graphikuz / gist:60180e07d6ea7dfc4354
Last active August 29, 2015 14:05
Wordpress: Remove default post type
<?php
/**
* Remove Default Post Type
*/
add_action('admin_menu','remove_default_post_type');
function remove_default_post_type() {
remove_menu_page('edit.php');
@graphikuz
graphikuz / gist:cf91fc2b262981ebc5e1
Last active August 29, 2015 14:05
Wordpress: Customize WP Menu Icon
<?php
/**
* Customize WP Menu Icon
*/
function add_menu_icons_styles(){
?>
<style>
@graphikuz
graphikuz / gist:e8f17b59bdc4f74cc41a
Created August 8, 2014 15:04
Wordpress: Add Categories and/or Tags to page
/**
* Add Categories and/or Tags to page
*/
function myplugin_settings() {
// Add tag metabox to page
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
@graphikuz
graphikuz / gist:bd314d75bca61b467368
Last active August 29, 2015 14:05
Wordpress: Remove theme editor
<?php
/**
* Remove theme editor
*
* Disable plugins editor
*/
function remove_editor_menu() {
remove_action('admin_menu', '_add_themes_utility_last', 101);
@graphikuz
graphikuz / gist:e866a8c00b1b26926bb7
Created August 8, 2014 10:15
Wordpress: Disable jpeg compression
/**
* Disable jpeg compression
*/
add_filter('jpeg_quality', function($arg){return 100;});
@graphikuz
graphikuz / gist:7d4f5ecef241b5004e4a
Created August 8, 2014 10:14
Wordpress: Remove plugin updates
/**
* Remove plugin updates
*/
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );