Skip to content

Instantly share code, notes, and snippets.

View JeppeSigaard's full-sized avatar
💫

Jeppe Sigaard JeppeSigaard

💫
View GitHub Profile
@JeppeSigaard
JeppeSigaard / no-title-tags.php
Created May 23, 2017 09:42
Title tag remover plugin, fast AF
<?php
/* Plugin name: Fjern title tags */
add_filter('wp_get_attachment_image_attributes', function($attr){
unset($attr['title']);
return $attr;
});
<?php
add_filter( 'image_resize_dimensions', 'prfx_thumbnail_upscale', 10, 6 );
function prfx_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ){
if ( !$crop ) return null;
$aspect_ratio = $orig_w / $orig_h;
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
$crop_w = round($new_w / $size_ratio);
<?php /* Plugin name: Fjern admin bar */
add_action('init',function(){
if(!is_user_logged_in()){
add_filter( 'show_admin_bar', '__return_false' );
}
});
<?php /* plugin name: Maintenance */
add_action('init', function(){ if( $GLOBALS['pagenow'] !== 'wp-login.php' && !is_user_logged_in() ) { ?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="UTF-8">
<title>Maintenance title</title>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
/*
Plugin name: Attachment redirect
Description: Henvis sider for vedhæftning til forælder hvis den findes, eller forsiden hvis ikke.
Version: 0.1
*/
add_action('template_redirect', function(){
global $post;
<?php
/* --------------------------------------- */
// Show page templates as states in page list
add_filter( 'display_post_states', 'prfx_template_state', 10, 2 );
function prfx_template_state($post_states, $post){
// Fetch array of templates, returning Display name => slug, which is odd, but useful.
$templates = get_page_templates();
<?php
/*
Plugin name: Godkend login i 99 dage
Description: Forlænger perioden for et login til 99 dage
Author: Torben Meldgaard
Author URI: http://seatrouting.com
*/
add_filter('auth_cookie_expiration', 'my_expiration_filter', 99, 3);
<?php
/*
Plugin name: Google analytics tracking kode
Description: Indsæt sporingskode til google analytics i hjemmesidens footer
*/
add_action('wp_footer',function(){
echo "<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
<?php
add_image_size('alt-featured-size',752,350,true); // eller hvilke dimensioner du nu ønsker
add_filter('post_thumbnail_html',function($html, $post_id, $post_thumbnail_id, $size, $attr){
if ( is_single() || is_singular() || is_page() ){
$html = wp_get_attachment_image( $post_thumbnail_id, 'alt-featured-size', false, $attr );
}
return $html;
<?php
/*
Plugin name: WP like button arkiv addon
Description: Tilføj like button på arkivsider
*/
add_filter('[INDSÆT PASSENDE FILTER]','jio_do_wp_like_filter');
function jio_do_wp_like_filter($content){