Skip to content

Instantly share code, notes, and snippets.

View attitude's full-sized avatar

Martin Adamko attitude

View GitHub Profile
@attitude
attitude / do_action_timestamp.php
Created February 29, 2012 09:49
Display Timestamps when Debugging WordPress for Speed
<?php
//----------------------------------------------------------------------------------------------
// Display Timestamps when Debugging WordPress for Speed
//----------------------------------------------------------------------------------------------
//
// A GIST by Martin Adamko, martin(at)attitude.sk
//
// It happens from time to time you need to know where the crack is. I assume you are willing
// to kick in the WP source and put some 'echos' in there. But WP has 2 functions to help you
@attitude
attitude / patch-1049.diff
Created March 13, 2013 21:02
Patch for possible fix for issue #1049 of Pods Framework.
diff --git a/classes/PodsAPI.php b/classes/PodsAPI.php
index 129badf..571bd1a 100644
--- a/classes/PodsAPI.php
+++ b/classes/PodsAPI.php
@@ -3020,9 +3020,7 @@ class PodsAPI {
if ( !empty( $related_ids ) ) {
update_metadata( $object_type, $id, '_pods_' . $related_field[ 'name' ], $related_ids );
- foreach ( $related_ids as $rel_id ) {
- add_metadata( $object_type, $id, $related_field[ 'name' ], $rel_id );
@attitude
attitude / composer.json
Last active December 19, 2015 02:48
Handy function to return file extension
{
"name": "attitude/Functions/get_file_extension"
}
@attitude
attitude / composer.json
Last active December 19, 2015 02:48
Handy function to return file name without extension
{
"name": "attitude/Functions/get_file_filename"
}
@attitude
attitude / wp-contact-methods.php
Last active December 19, 2015 05:09
Add/Remove User Contact Methods WordPress Snipet/Plugin
<?php
/*
Plugin Name: Snipet: Add/Remove User Contact Methods
Plugin URI: http://www.attitude.sk
Description: Adds phone field to the user edit screen
Version: 0.1.1
Author: Martin Adamko
Author URI: http://www.attitude.sk
License: The MIT License (MIT)
@attitude
attitude / wp-register-the-post-thumbnail.php
Last active December 19, 2015 06:09
Register the Post Thumbnail Support Snippet/Plugin for WordPress with one click
<?php
/*
Plugin Name: Snipet: Enable `the_post_thumbnail`
Plugin URI: http://www.attitude.sk
Description: Displays `Post thumbnail` in post
Version: 0.1.0
Author: Mrg. art. Martin Adamko
Author URI: http://www.attitude.sk
License: The MIT License (MIT)
@attitude
attitude / function-array_merge_for_sql.php
Last active December 19, 2015 10:58
Function to merge new SQL argument arrays (right) with defaults (left)
<?php
/**
* Merges new SQL argument arrays with defaults
*
* Differs from {@link array_merge()} and {@link array_merge_recursive()}:
*
* 1. Array of 'where', 'orderby', 'groupby' and 'join' keys should be
* appended and remain unique.
* 2. 'select', 'limit' should be overwritten, by new argument on right
@attitude
attitude / function-file_size_format.php
Last active December 19, 2015 13:49
Returns formatted file size
<?php
/**
* Returns formatted file size
*
* Inspired by {@link http://betterwp.net/wordpress-tips/size_format/}, modified
* to work outside of WordPress environment.
*
* @param int $bytes Size in bytes
* @param int $decimals Number of decimal places
@attitude
attitude / function-wp_get_attachment_meta.php
Last active December 19, 2015 13:49
Returns metadata for current WordPress attachment or array of attachments
<?php
/**
* Returns metadata for current WordPress attachment or array of attachments
*
* Reads all attachment metadata and expands it. URLs are rewritten with upload
* dir prepended, file size is calculated if function exists. By default url protocol
* is removed, use `add_filter()` to disable.
*
* @uses {@link apply_filters() http://codex.wordpress.org/Function_Reference/apply_filters}
@attitude
attitude / function-maybe_decode_json.php
Last active December 19, 2015 16:29
Decodes JSON string if needed
<?php
/**
* Decodes JSON string if needed
*
* @uses json_decode()
* @author Martin Adamko <@martin_adamko>
* @licence The MIT Licence <http://opensource.org/licenses/MIT>
*
* @param string $str String to decode if needed