Skip to content

Instantly share code, notes, and snippets.

fixing Date/Time in WordPress core

Andrey Savchenko Rarst

fixing Date/Time in WordPress core
Block or report user

Report or block Rarst

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Rarst
Rarst / wp-email-log.php
Created Mar 31, 2019
A simple mu–plugin snippet for overriding and logging WP emails in development.
View wp-email-log.php
<?php
class R_Mailer {
function Send() {
error_log( wp_debug_backtrace_summary() );
}
}
add_action( 'phpmailer_init', function( &$mailer ) {
$mailer = new R_Mailer();
@Rarst
Rarst / github-release-download.php
Last active May 13, 2019
Quick and dirty WP endpoint to redirect to a download of attached file for a latest GitHub release.
View github-release-download.php
<?php
declare( strict_types=1 );
new class( 'Rarst', [ 'laps' ] ) {
private $owner, $repos;
private $endpoint = 'download';
public function __construct( string $owner, array $repos ) {
@Rarst
Rarst / getpatch.cmd
Last active Jun 29, 2018
Download a patch file from a GitHub branch. Arguments: repo name, branch name (e.g. `getpatch Rarst/wp-date trac-38771`).
View getpatch.cmd
curl https://github.com/%1/compare/master...%2.diff > patches/%2.diff
@Rarst
Rarst / jekyll.md
Created Jan 9, 2018
What worked for me to install GitHub Pages (Jekyll) on Windows 7x64.
View jekyll.md

GitHub Pages (Jekyll) installation on Windows 7x64

Main install

  1. Install Ruby 2.4.3 via RubyInstaller (not 2.5, conflicts with things later)
  2. Let it install MSYS2 or do it yourself.
  3. gem install bundler
  4. gem install github-pages (this includes jekyll itself and is where things break most)
  5. jekyll -v (3.6.2 at the time of writing, a little behind latest 3.7)
  6. jekyll new myblog
  7. Edit myblog/Gemfile to comment out jekyll line and uncomment github-pages line.
@Rarst
Rarst / .scrutinizer.yml
Last active Feb 2, 2018
Scrutinizer config to install PHPUnit on the fly, without shipping in project dependencies.
View .scrutinizer.yml
filter:
excluded_paths:
- 'tests/*'
checks:
php: true
build:
environment:
php:
version: 7.2
dependencies:
View php-72-crash.php
<?php
add_action( 'template_redirect', function () {
if ( ! isset( $_GET['crash'] ) ) {
return;
}
$urls = [];
@Rarst
Rarst / headings.less
Created Jul 14, 2017
Less mixin to calculate vertical rhythm styling for headings [in Bootstrap]. Don’t ask me how this works because I don’t remember and this made my brain hurt enough.
View headings.less
.heading-line-height( @line-height ) when ( @line-height < 1 ) {
line-height: unit(@line-height * 2, em);
}
.heading-line-height( @line-height ) when ( @line-height >= 1 ) {
line-height: unit(@line-height, em);
}
.heading-rhythm ( @font-size-base, @font-size-increase ) {
@heading-font-size: @font-size-base * @font-size-increase;
@Rarst
Rarst / dumper.php
Last active Dec 11, 2016
Dump included PHP files from specific path.
View dumper.php
<?php
add_action( 'shutdown', function () {
if ( ! defined( 'WPSEO_PATH' ) ) {
return;
}
$path = str_replace( '\\', '/', WPSEO_PATH );
$includes = array_reduce( get_included_files(), function ( $plugin_includes, $include_path ) use ( $path ) {
View query-bench.php
<?php
$bench = new Ubench();
$total = 15000;
$count = 10;
$sql = "
SELECT l.ID, post_title, post_content, post_name, post_parent, post_author, post_modified_gmt, post_date, post_date_gmt
FROM (
SELECT {$wpdb->posts}.ID
@Rarst
Rarst / RoboFile.php
Last active Apr 28, 2019
Robo command to build a release zip for Composer package.
View RoboFile.php
<?php
class RoboFile extends \Robo\Tasks {
/**
* Creates release zip
*
* @param string $package Composer package in vendor/name format.
* @param string $version Version to build.
*/
You can’t perform that action at this time.