Skip to content

Instantly share code, notes, and snippets.

private function rglob($pattern, $flags = 0)
{
if (strpos($pattern, '**') === false) {
$files = glob($pattern, $flags);
} else {
$position = strpos($pattern, '**');
$rootPattern = substr($pattern, 0, $position - 1);
$restPattern = substr($pattern, $position + 2);
$patterns = array($rootPattern . $restPattern);
$rootPattern .= '/*';
@rockschtar
rockschtar / windows-wsl2-docker-lando-php-xdebug.md
Last active June 4, 2024 16:38
Windows 10/11 + WSL2 + Docker + Lando + PHP XDebug (PHPStorm, IntelliJ & Visual Studio Code (vscode))
  1. Install WSL
  2. Install your preferred WSL Linux Distro vom Microsoft Store. In my case I used Ubuntu 20.04.
  3. Install Docker for Windows
  4. Enable Docker WSL2 Integration image
  5. Install Lando inside WSL
wget https://github.com/lando/lando/releases/download/v3.6.0/lando-x64-v3.6.0.deb
dpkg -i --ignore-depends=docker-ce lando-x64-v3.6.0.deb
@rockschtar
rockschtar / convert-unix-timestamp-to-wordpress-local-time.php
Created February 21, 2017 18:40
Convert UNIX Timestamp to WordPress Local Time
function convertTimestampToWPDateTime(int $timestamp) : \DateTime {
$tz = get_option('timezone_string');
if (!$tz) {
$offset = get_option('gmt_offset');
$tz = timezone_name_from_abbr('', $offset * 3600, false);
}
<?php
add_action('wp_print_styles', function () {
wp_dequeue_style('colormag_style');
}, 1000);
add_action('wp_head', function () {
$content = file_get_contents(get_stylesheet_directory() . '/style-inline.css');
$content = str_replace('{stylesheet_dir}', get_stylesheet_directory_uri(), $content);
$css_minify = new \MatthiasMullie\Minify\CSS();
$css_minify->add($content); ?>
@rockschtar
rockschtar / set-cookie.php
Created March 20, 2014 11:14
WordPress;: Set Cookie
@rockschtar
rockschtar / widget-save-callback.js
Last active August 29, 2015 13:57
WordPress: Hook into Widget save Javascript Callback
jQuery(document).ajaxSuccess(function(e, xhr, settings) {
var widget_id_base = 'my-widget-id-base';
if(settings.data && settings.data.search('action=save-widget') != -1 && settings.data.search('id_base=' + widget_id_base) != -1) {
//do something
}
});
@rockschtar
rockschtar / plugin-links
Last active August 29, 2015 13:57
WordPress: Add Links (Hrefs) to WordPress Plugin List Entry
@rockschtar
rockschtar / WP Plugin root
Created June 27, 2013 13:00
WordPress: Plugin Root/Header
<?php
/*
Plugin Name: Plugin name
Plugin URI: http://www.example.com
Description: Bla Bla
Author: Stevie
Version: 0.5 Beta
Author URI: http://www.example.de
*/