Instantly share code, notes, and snippets.

View vs-code-settings.json
{
// App behaviour.
"workbench.startupEditor": "newUntitledFile",
"workbench.list.openMode": "doubleClick",
"workbench.quickOpen.closeOnFocusLost": false,
"explorer.openEditors.visible": 0,
"explorer.confirmDragAndDrop": false,
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,
"workbench.settings.editor": "json",
View isset_ternary.php
<?php
// really old way
if ( isset( $_GET['user'] ) ) {
$username = $_GET['user'];
} else {
$username = 'nobody';
}
// old way
$username = isset( $_GET['user'] ) ? $_GET['user'] : 'nobody';
View vs-code-ext.txt
code --install-extension aaron-bond.better-comments
code --install-extension agauniyal.vscode-caniuse
code --install-extension ahmadawais.shades-of-purple
code --install-extension alefragnani.Bookmarks
code --install-extension alefragnani.project-manager
code --install-extension bmewburn.vscode-intelephense-client
code --install-extension BriteSnow.vscode-toggle-quotes
code --install-extension christian-kohler.npm-intellisense
code --install-extension claudiosanches.wpcs-whitelist-flags
code --install-extension codezombiech.gitignore
View Enable-Jetpack-Module.php
<?php
//...
require_once( JETPACK__PLUGIN_DIR . 'modules/lazy-images/lazy-images.php' );
add_filter( 'lazyload_is_enabled', function() { return true; } );
add_action( 'wp', array( 'Jetpack_Lazy_Images', 'instance' ) );
// different for each module, some require other assets/dependencies.
View dropdownmove.js
// if the sub-navigation is off-screen we want to bump it left
const parentsli = document.querySelectorAll( 'ul > li.page_item_has_children' );
for ( let parent of parentsli ) {
const children = parent.querySelector( 'ul.children' );
parent.addEventListener( 'mouseenter', evt => {
// compare with width, to dropdown offset, to width of drop down
const windowWidth = document.documentElement.clientWidth;
View google-query-calendar.php
<?php
require_once ('/Google/autoload.php'); // see https://github.com/google/google-api-php-client
require_once ('/Google/Service/Calendar.php');
$client = new Google_Client();
// $client settings and auth
$service = new Google_Service_Calendar($client);
$calendarId = 'username@gmail.com';
$optParams = array(
View functions.php
/**
* Home Page Slideshow: add meta box to home page
*/
add_action( 'add_meta_boxes', function () {
if (get_the_ID() !== intval(get_option('page_on_front'))) {
return;
}
add_meta_box(
'homepage_slideshow',
'Home Page SlideShow',
View wp-pass-php-into-js-alt.php
<?php
wp_scripts()->add_data(
'my_js_theme',
'my_theme_data',
sprintf(
'var my_theme_data = %s;',
wp_json_encode( [
'nonce' => wp_create_nonce( 'wp_rest' ),
'path' => $path,
'blogname' => get_option( 'blogname' ),
View wp-pass-php-into-js.php
<?php
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_script(
'my_js_theme',
get_template_directory_uri() . '/my_app.js?=' . time(),
false,
'',
true
);
View section-sticky-buttons.css
#events {
overflow: hidden;
position: relative;
}
#events .show {
width: 30.3%;
background: white;
float: left;
padding: 150px 0;
margin: 20px 1.5%;