This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hip_toolbar_items() { | |
global $wp_admin_bar; | |
$args = array( | |
'id' => 'id', | |
'title' => __( 'Title', 'textdomain' ), | |
'href' => admin_url(), | |
); | |
$wp_admin_bar->add_menu( $args ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'attachment_fields_to_edit', 'hip_edit_media_custom_field', 11, 2 ); | |
add_filter( 'attachment_fields_to_save', 'hip_save_media_custom_field', 11, 2 ); | |
function hip_edit_media_custom_field( $form_fields, $post ) { | |
$form_fields['image_source'] = array( | |
'label' => __( 'Bildkälla', 'ds' ), | |
'input' => 'text', | |
'value' => get_post_meta( $post->ID, 'image_source', true ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Custom columns on edit terms screens i admin | |
* */ | |
add_filter( 'manage_edit-{taxonomy-slug}_columns', 'hip_{taxonomy-slug}_columns_head' ); | |
add_filter( 'manage_{taxonomy-slug}_custom_column', 'hip_{taxonomy-slug}_columns_content_taxonomy', 10, 3 ); | |
function hip_{taxonomy-slug}_columns_head( $columns ) { | |
unset( $columns['posts'] ); // unset the posts column | |
unset( $columns['slug'] ); // unset the slug column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'template_include', 'my_prefix_template' ); | |
function my_prefix_template( $template ) { | |
$template_filename = "foobar.php"; | |
if ( !file_exists( get_stylesheet_directory() . "/" . $template_filename ) ) { | |
$template = plugin_dir_path( __FILE__ ) . '/' . $template_filename; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM $termstable AS terms | |
JOIN ".$wpdb->prefix."term_taxonomy AS termtax ON terms.term_id = termtax.term_id | |
WHERE termtax.taxonomy = '$taxonomy' | |
AND terms.name LIKE '%$searchterm%' COLLATE utf8_swedish_ci | |
ORDER BY termtax.count DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = "url to file"; | |
$tmp = download_url( $url ); | |
/* Does a file with this name already exist in the media library? */ | |
$filename = remove_accents( preg_replace("/\\.[^.\\s]{3,4}$/", "", basename( $url ) ) ); | |
global $wpdb; | |
$poststable = $wpdb->prefix . "posts"; | |
$filename_exists = $wpdb->get_col( "SELECT post_name FROM $poststable WHERE post_name LIKE '$filename' AND post_type = 'attachment'" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'post_gallery', 'hip_post_gallery', 10, 2 ); | |
function hip_post_gallery( $output, $attr) { | |
global $post, $wp_locale; | |
static $instance = 0; | |
$instance++; | |
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement | |
if ( isset( $attr['orderby'] ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hip_has_shortcode( $content, $tags ) { | |
if( is_array( $tags ) ) { | |
foreach ( $tags as $tag ) { | |
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); | |
if ( empty( $matches ) ) | |
return false; | |
foreach ( $matches as $shortcode ) { | |
if ( $tag === $shortcode[2] ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Hippies attachments noindex | |
Plugin URI: | |
Description: Do not index attachment pages and set default image link type to "none" on plugin activation. | |
Version: 1 | |
Author: Hippies | |
Author URI: http://hippies.se/ | |
*/ | |
add_action( 'wp_head', 'hip_attachments_noindex_wp_head' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
var status = notices.post_status, | |
savePostBtn = $("#save-post"), | |
publishPostBtn = $("#publishing-action #publish"); | |
if( status != "publish" && status != 0 ) { | |
publishPostBtn.removeClass("button-primary"); | |
savePostBtn.addClass("button-primary"); | |
} | |
}); |