Martin Adamko attitude

View composer.json
1 2 3 4 5 6
{
"name": "attitude/Functions/generate_slug",
"autoload": {
"files": ["function-generate_slug.php"]
}
}
View composer.json
1 2 3 4 5 6
{
"name": "attitude/Functions/is_assoc_array",
"autoload": {
"files": ["function-is_assoc_array.php"]
}
}
View wp-json-api-post-meta.diff
1 2 3 4 5 6 7 8 9 10
diff --git a/lib/class-wp-json-posts.php b/lib/class-wp-json-posts.php
index e440b25..59c6bfd 100644
--- a/lib/class-wp-json-posts.php
+++ b/lib/class-wp-json-posts.php
@@ -847,14 +847,57 @@ class WP_JSON_Posts {
return $can_insert;
}
- // Post meta
- // TODO: implement this
View closing-connection-early-page-load-speed-tip.md

Page Speed Tip: Defer time consuming processes after sending the page output

Recently I have written a PHP class to try server analytics. But using the UAMP, script has to wait for response from Google's servers in order to close the connection. Even if the response took less than 100ms, still it's unnecessary time for client to wait and show loading spinner and block page render.

There is a space for optimisation: closing connection early and present the client with the response before the script finishes it's run.

View on-git-read-tree-and-dependencies.md

Here is a quick tip on pulling dependencies in your project using git read-tree command.

The Problem

How to use a single component from some library (eg. Form from Symfony), but not the whole library (tried the git submodule ?).

  1. Init project:

    Create a new project and init Git:

View Runnig PHP v5.3 in MAMP.md

Introduction

Lately I needed to test some code against PHP version 5.3 wich is (hopefully not forever) the highest supported version on one of my clients hosting right now. To cut the story short, I develop and test on a local MAMP server, usualy for PHP v5.4+. The free version of MAMP will let you run either v5.4.4 or v5.2.17 of PHP. To run other version you need to purchase MAMP Pro. But I haven't read/heard a single person saing about MAMP Pro worth its price tag.

Setup

My MAMP installation comes with many PHP versions preinstalled. See /Applications/MAMP/conf (Cmd+G), but you can swich only between two: the lowest and the heighest version of PHP. No option between. There are these versions in my MAMP/conf folder:

View function-get_pagination_data.php
1 2 3 4 5 6 7 8 9 10
<?php
 
/**
* Returns {{mustache}} ready data for pagination
*
* Pagination array for `prev`, `next`, `start`, `end` and `jump`
* to direct pages
*
* @author Martin Adamko <@martin_adamko>
* @licence The MIT Licence <http://opensource.org/licenses/MIT>
View function-maybe_decode_json.php
1 2 3 4 5 6 7 8 9 10
<?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
View function-wp_get_attachment_meta.php
1 2 3 4 5 6 7 8 9 10
<?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}
View function-file_size_format.php
1 2 3 4 5 6 7 8 9 10
<?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
Something went wrong with that request. Please try again.