Skip to content

Instantly share code, notes, and snippets.

View PhilippSchreiber's full-sized avatar

Philipp Schreiber PhilippSchreiber

View GitHub Profile
@PhilippSchreiber
PhilippSchreiber / wp_prepare_attachment_for_js.php
Created September 26, 2013 10:56
Modify the image URL used in Wordpress Media Frame.
function ps_wp_prepare_attachment_for_js($response, $attachment, $meta) {
if($response['type'] == 'image') {
$image_src = wp_get_attachment_image_src( $response['id'], 'thumbnail' ); //Use any image size added to your wordpress installation
if( is_array($image_src) ) {
$response['url'] = $image_src[0];
}
}
return $response;
@PhilippSchreiber
PhilippSchreiber / gist:6306312
Created August 22, 2013 12:01
wpSEO: Deactivate for some post types
add_filter( 'wpseo_add_meta_boxes', 'prefix_wpseo_add_meta_boxes );
function prefix_wpseo_add_meta_boxes() {
global $post;
$post_types_without_seo = array( 'date', 'slide', 'video' );
return !in_array( get_post_type($post), $post_types_without_seo);
}
@PhilippSchreiber
PhilippSchreiber / gist:6294701
Created August 21, 2013 13:52
Snippet: print_r in console
echo "<script>console.log( " . print_r($object, true) . " );</script>";
@PhilippSchreiber
PhilippSchreiber / social_count.php
Last active October 14, 2016 08:11
Get social stats in one number
function ps_get_social_count( $post_id, $flush_cache = false ) {
if( $flush_cache || false === ( $like_count = get_transient('like_count_' . $post_id) ) ) {
$url = get_permalink($post_id);
$fb_like_count = ps_get_fb_count($url);
$tweet_count = ps_get_tweet_count($url);
$gplus_count = ps_get_google_plus_count($url);
$pinterest_count = ps_get_pinterest_count($url);
@PhilippSchreiber
PhilippSchreiber / gist:3012358
Created June 28, 2012 16:35
PhoneGap / Cordova File Download
var fileSystem;
var documentRoot;
function onAppReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, function() {});
}
function gotFS(fileSystem) {
fileSystem = fileSystem;
documentRoot = fileSystem.root.fullPath;
@PhilippSchreiber
PhilippSchreiber / embed.php
Created January 8, 2012 09:51
Inhalte von externen Seiten ohne API einbinden
$url = 'http://www.andioliphilipp.de';
$doc_source = new DOMDocument;
$doc_source->validateOnParse = true;
@$doc_source->loadHTML(utf8_decode(file_get_contents($url)));
$content = $doc_source->getElementById('meta_partner');
$doc_output = new DOMDocument;
$doc_output->appendChild($doc_output->importNode($content,true));