Skip to content

Instantly share code, notes, and snippets.

View markoheijnen's full-sized avatar

Marko Heijnen markoheijnen

View GitHub Profile
@markoheijnen
markoheijnen / requirements.txt
Created July 19, 2024 16:12
Sync Patch Feed to Title Editor
asn1crypto
function get_props( description ) {
var users = [];
// Cleanup for easier parsing.
description = description.toLowerCase().replace( /[\n|, ]fixes(.*)/i, '' ).replace( /(\n|. )see(.*)/i, '' );
// Place enter to fix cases where it otherwise would fail. See changeset 22094
if ( '.' != description.substr(description.length - 1) ) {
description += '.';
}
@markoheijnen
markoheijnen / creator.php
Last active August 29, 2015 14:23
Favicon generator
<?php
class WP_Site_Icon_Creator {
private $file;
public function __construct() {
$this->file = dirname( __FILE__ ) . '/512px_Icon.png';
$this->generate();
}
@markoheijnen
markoheijnen / gist:aeae3d938d3b88608291
Last active August 29, 2015 14:10
Remove duplicated originals
<?php
require_once dirname( dirname( __FILE__ ) ) . '/gp-load.php';
class GP_Script_Remove_Duplicated_Originals extends GP_CLI {
var $usage = "<path>";
public function run() {
if ( empty( $this->args ) ) {
$this->usage();
@markoheijnen
markoheijnen / gist:9337dc054e1224f9ba5b
Created November 19, 2014 20:11
qTranslate to Babble
- Set default language and all languages to WordPress/Babble
- Loop over all posts and load the translations inside post_content to an array
- Loop the array and skip the default language.
- Babble_Jobs->create_post_jobs( (object) $curren_post, (array) $language_codes )
- You will get post ids back and need to call the next function.
- Babble_Post_Public->initialise_translation( $original_post, $lang_code )
- For the behaviour it's best to look at Babble_Jobs->save_job() which is called by the save_post hook
- when successful the default language content should become post_content
### Keybase proof
I hereby claim:
* I am markoheijnen on github.
* I am markoheijnen (https://keybase.io/markoheijnen) on keybase.
* I have a public key whose fingerprint is AEB9 B624 EABB AAC7 A40B 829E EAF4 86C8 5AE8 04C8
To claim this, I am signing this object:
@markoheijnen
markoheijnen / gist:41a17182c4a7d2608f62
Created September 23, 2014 19:17
Allow only one session per user.
<?php
add_action( 'wp_login', 'wp_destroy_other_sessions' );
@markoheijnen
markoheijnen / gist:1fb8aef0b3069d813ec7
Last active August 29, 2015 14:06
Cleaning up deprecated options in php.ini. Add this file in the root directory and call it from a browser. This script does the rest.
<?php
class PHP_Ini_Fixes {
private $deprecated_options = array(
// Can result in issue in different PHP versions
'browscap',
//PHP 5.4 removed
'register_globals', 'register_long_arrays',
'magic_quotes_gpc', 'magic_quotes_runtime', 'magic_quotes_sybase',
'allow_call_time_pass_reference',
@markoheijnen
markoheijnen / mysql_error_catcher.php
Last active December 20, 2015 15:59 — forked from kurtpayne/mysql_error_catcher.php
Custom error handler for catching MySQL errors
<?php
function wp_set_error_handler() {
if ( defined( 'E_DEPRECATED' ) )
$errcontext = E_WARNING | E_DEPRECATED;
else
$errcontext = E_WARNING;
set_error_handler( function( $errno, $errstr, $errfile ) {
if ( 'wp-db.php' !== basename( $errfile ) ) {
@markoheijnen
markoheijnen / gist:6129265
Last active February 5, 2016 11:07
Fantastich ElasticSearch: add numeric meta key
<?php
class My_Elasticsearch {
public function __construct() {
add_filter( 'elasticsearch_config_facets', array( $this, 'add_facets' ) );
add_filter( 'elasticsearch_config_fields', array( $this, 'add_fields' ) );
add_filter( 'elasticsearch_indexer_map_field', array( $this, 'indexer_map_field' ), 10, 2 );
add_filter( 'elasticsearch_indexer_build_document', array( $this, 'indexer_build_document' ), 10, 2 );
}