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%;
View wp-image-filters.php
<?php
// Images in post content and galleries
add_filter( 'get_post_galleries', 'myplugin_filter_image_url', 999999 );
add_filter( 'widget_media_image_instance', 'myplugin_filter_image_url', 999999 );
// Core image retrieval
add_filter( 'image_downsize', 'myplugin_filter_image_url', 10, 3 );
// Responsive image srcset substitution
View wp-fix-tax-query.php
<?php
global $wp_taxonomies;
switch_to_blog($new);
if(!taxonomy_exists('my_missing_tax'))
$wp_taxonomies['my_missing_tax'] = 'delete';
// do `tax_query`'s in $new with `my_missing_tax`
View alfred-change-dev-pro.php
<?php // don't actually use the php in workflow
// get the result of Apple Script action
$url = '{query}';
$a = ['http:','.loc']; // dev
$b = ['https:','.com']; // production
// identify if production and invert if so
if (strstr($url,$b[1]))
View get_browser_url.as
tell application "System Events"
set myApp to name of first application process whose frontmost is true
if myApp is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of front window
else if myApp is "Opera" then
tell application "Opera" to return URL of front document
else if myApp is "Safari" then
tell application "Safari" to return URL of front document
else if myApp is "Firefox" then
tell application "System Events"
View wp-privacy-link-in-themes.php
View deploy.php
<?php
// just a pinch of authorization
$sig = hash_hmac('sha1', file_get_contents('php://input'), 'mywebhooksecrethere');
if (
$_POST['payload'] &&
$_SERVER['HTTP_X_GITHUB_EVENT'] == 'push' &&
$_SERVER['HTTP_X_HUB_SIGNATURE'] == 'sha1='.$sig
) {
$cmd = 'cd /var/www/path/to/repo && /usr/bin/git reset --hard HEAD 2>&1 && /usr/bin/git pull 2>&1';
$out = shell_exec( $cmd );
View pass-vars-into-hooks.php
<?php
// 🚫 Won't work:
add_shortcode('show_weather',function(){
$a = shortcode_atts( array(
'location' => 'Vancouver, BC',
), $atts, 'show_weather' );
$city = $a['location'];