Skip to content

Instantly share code, notes, and snippets.

@remkus
remkus / functions.php
Created September 24, 2013 16:08
attachement default no link
<?php
add_action( 'admin_init', 'fs_imagelink_setup', 10 );
/**
* Set default link option for attachments
*
* @return void
*/
function fs_imagelink_setup() {
$image_set = get_option( 'image_default_link_type' );
<?php
remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'befrank_nieuwsbericht_sidebar' );
/**
* Replace default sidebar with news specific
*/
function befrank_nieuwsbericht_sidebar() {
dynamic_sidebar( 'nieuwsbericht-sidebar' );
@remkus
remkus / functions.php
Created August 11, 2013 09:21
How tot detect is a certain page template is in use.
<?php
**/
* How tot detect is a certain page template is in use.
*
* @link http://www.wupperpiraten.de/2009/12/is-a-certain-page-template-active/
*/
function is_pagetemplate_active( $pagetemplate = '' ) {
global $wpdb;
$sql = "select meta_key from $wpdb->postmeta where meta_key like '_wp_page_template' and meta_value like '" . $pagetemplate . "'";
$result = $wpdb->query( $sql );
@remkus
remkus / functions.php
Created May 16, 2013 12:24
Automatically set featured images
<?php
function auto_featured_image() {
global $post;
if ( ! has_post_thumbnail( $post->ID ) ) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ( $attached_image ) {
foreach ( $attached_image as $attachment_id => $attachment ) {
@remkus
remkus / functions.php
Created May 11, 2013 12:20
Allow oEmbed in textwidgets
<?php
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 );
@remkus
remkus / column-classes.css
Last active December 14, 2015 14:08
Column classes
/* 04f - Column Classes ----------- */
.five-sixths,
.four-fifths,
.four-sixths,
.one-fifth,
.one-fourth,
.one-half,
.one-sixth,
.one-third,
@remkus
remkus / somewhere-in-functions.php
Last active December 14, 2015 09:18
Force Featured Image
<?php
add_action( 'save_post', 'force_check_thumbnail') ;
add_action( 'admin_notices', 'show_thumbnail_error' );
/**
* Force Featured Image
*
* @link http://wpdevsnippets.com/require-post-thumbnail-uploaded-before-publishing/
* @param global $post_id
* @return
@remkus
remkus / flexible-oembed-settings.php
Created December 25, 2012 11:55
Flexible oEmbed
<?php
add_filter( 'embed_defaults', 'custom_oembed_defaults' );
/**
* Custom WordPress oEmbed widths
* @param var $embed_size
* @return var
*/
function custom_oembed_defaults( $embed_size ) {
@remkus
remkus / no-spaces-buddypress-usernames.php
Created December 25, 2012 11:41
Prevent spaces in BuddyPress usernames
<?php
add_action( 'bp_loaded','bpdev_remove_bp_pre_user_login_action') ;
/**
* BuddyPress replaces the space with '-' which is not known to the user
* We remove the attached function to stop BP from circumventing the space in username
*
*/
function bpdev_remove_bp_pre_user_login_action(){