Skip to content

Instantly share code, notes, and snippets.

@andyknapp
andyknapp / functions.php
Created June 20, 2013 02:19
Remove items from WP admin (profile section in this example) with jQuery Felt kinda weird to use js to do this, but had to be done and was the only solution I could come up with
function hide_personal_options(){echo "\n"
. '<script type="text/javascript">jQuery(document).ready(function($) {
$(\'form#your-profile > h3:first\').hide();
$(\'form#your-profile > table:first\').hide();
$(\'table.form-table:eq(1) tr:eq(3)\').hide();
$(\'table.form-table:eq(1) tr:eq(4)\').hide();
$(\'table.form-table:eq(2) tr:eq(1)\').hide();
$(\'table.form-table:eq(2) tr:eq(2)\').hide();
$(\'table.form-table:eq(2) tr:eq(3)\').hide();
$(\'table.form-table:eq(2) tr:eq(4)\').hide();
@andyknapp
andyknapp / functions.php
Created June 20, 2013 02:25
Default WP post thumbnail (featured img) if one isn't uploaded
function ak_post_thumbnail_html( $html ) {
if ( empty( $html ) )
$html = '<img src="' . trailingslashit( get_stylesheet_directory_uri() ) . 'images/default-thumbnail.jpg' . '" alt="No Image provided" />';
return $html;
}
add_filter( 'post_thumbnail_html', 'ak_post_thumbnail_html' );
@andyknapp
andyknapp / index.html
Created June 20, 2013 12:08
Sticky footer from CSS-Tricks
<div class="container">
<header></header>
<div class="content"></div>
</div>
<footer class="site-footer">
<p>footer stays at bottom</p>
</footer>
@andyknapp
andyknapp / index.html
Created July 10, 2013 14:42
A CodePen by Chris Coyier. Don't Overthink It Grids - Writeup on CSS-Tricks : http://css-tricks.com/dont-overthink-it-grids/
<h1>Don't Overthink It Grids <em>(while we wait for flexbox)</em></h1>
<div class="grid">
<div class="col-2-3">
<div class="module">
<h3>2/3</h3>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</div>
</div>
<div class="col-1-3">
@andyknapp
andyknapp / functions.php
Created July 10, 2013 17:35
dynamic date function for wp
function copyright_date() {
global $wpdb;
$copyright_dates = $wpdb->get_results("
SELECT
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
FROM
$wpdb->posts
WHERE
post_status = 'publish'

Website Contract [month] [year]

Description of this Contract

This contract is not meant to trick or deceive you; the intention is purely to protect both parties. I have tried to keep the wording as plain as possible, but if anything is unclear, please let me know and I will be more than happy to clarify it with you. Also, until you sign it, please feel free to request to change bits of it to suit your requirements.

In short, [client name] is contracting me, [my name], to [description of my role] between [start date and finish date].

By signing this, you are confirming that you have the power and ability to enter into this contract on behalf of [client's company].

@andyknapp
andyknapp / functions.php
Last active December 21, 2015 12:49
Remove menu items from WP dashboard for all user roles expect admin
function ak_remove_menu_pages() {
if( !current_user_can('administrator') ) {
remove_menu_page('link-manager.php');
}
}
add_action( 'admin_menu', 'ak_remove_menu_pages' );
@andyknapp
andyknapp / functions.php
Created August 22, 2013 15:29
deregister plugin css files
function ak_deregister_styles() {
wp_deregister_style( 'soliloquy-style' );
wp_deregister_style( 'tribe-events-calendar-style');
}
add_action( 'wp_print_styles', 'ak_deregister_styles', 100 );
@andyknapp
andyknapp / functions.php
Created August 22, 2013 15:36
remove WP dashboard widgets
function ak_remove_dashboard_widgets() {
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('wp_dashboard_setup', 'ak_remove_dashboard_widgets' );
@andyknapp
andyknapp / functions.php
Created August 22, 2013 15:43
expand editor role capabilities to include gravity forms
function add_grav_forms(){
$role = get_role('editor');
$role->add_cap('gform_full_access');
}
add_action('admin_init','add_grav_forms');