Skip to content

Instantly share code, notes, and snippets.

💭
Working remotely, as usual

Adam Silverstein adamsilverstein

💭
Working remotely, as usual
Block or report user

Report or block adamsilverstein

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
View version scripts
build.sh (gitlab)
sed -i "s/COMMITHASH/$CI_COMMIT_SHORT_SHA/g" functions.php
functions.php
define( 'MS_RESEARCH_ASSET_VERSION', 'COMMITHASH' );
View complete
╰─$ ./vendor/bin/phpcs src/*.php src/**/*.php --standard=WordPress --sniffs=WordPress.WP.I18n
FILE: develop.wordpress/src/wp-login.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
434 | ERROR | A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
View summary
╰─$ ./vendor/bin/phpcs src/*.php src/**/*.php --standard=WordPress --sniffs=WordPress.WP.I18n --report=summary
PHP CODE SNIFFER REPORT SUMMARY
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FILE ERRORS WARNINGS
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
develop.wordpress/src/wp-login.php 1 0
develop.wordpress/src/wp-admin/admin-footer.php 1 0
develop.wordpress/src/wp-admin/admin.php 1 0
develop.wordpress/src/wp-admi
View create-multiple-sites.sh
for i in {1..100}
do
wp site create --slug=site-$i
done
@adamsilverstein
adamsilverstein / nonce.php
Created Nov 21, 2018
shorten nonce lifetimes
View nonce.php
add_filter( 'nonce_life', function () { return 25; } );
View gist:4bfc76454656046b24f18b292da895f7
function wp_heartbeat_settings_3242( $settings ) {
$settings['interval'] = 15; //Anything between 15-120
return $settings;
}
add_filter( 'heartbeat_settings', 'wp_heartbeat_settings_3242' );
@adamsilverstein
adamsilverstein / workaround.php
Created Feb 2, 2018
Meta Revision timing workaround
View workaround.php
// do not save revision on post_updated since the meta fields are not saved yet.
remove_action( 'post_updated', 'wp_save_post_revision', 10 );
// readd wp_save_post_revision on save_post if needed.
add_action( 'post_updated', 'save_post_revision_on_save_post', 10 );
function save_post_revision_on_save_post() {
$mycustomfieldsplugin_save_post_priority = 10;
// wp_save_post_revision has to be executed after the plugin saves its meta fields (higher priority on save_post hook).
add_action( 'save_post', 'wp_save_post_revision', $mycustomfieldsplugin_save_post_priority + 1, 1 );
View demo-post.json
// 20180102142527
// http://developwordpress.localhost/wp-json/wp/v2/posts/336
{
"id": 336,
"date": "2018-01-02T14:24:26",
"date_gmt": "2018-01-02T19:24:26",
"guid": {
"rendered": "http://developwordpress.localhost/?p=336"
},
View blocksinpost.json
// 20170908135703
// http://developwordpress.localhost/wp-json/wp/v2/posts/40018
{
"content": {
"id": 40018,
"date": "2017-09-04T19:21:42",
"date_gmt": "2017-09-04T19:21:42",
"guid": {
"rendered": "http://developwordpress.localhost/?p=40018"
View wp-api-init-w-namespace.js
wp.api.init({
'versionString': '/custom/v1/'
}
).done( function( mySchema ) {
// mySchema contains your namespace models/collections
...
} );
You can’t perform that action at this time.