Skip to content

Instantly share code, notes, and snippets.

View jonathanstegall's full-sized avatar

Jonathan Stegall jonathanstegall

View GitHub Profile
@jonathanstegall
jonathanstegall / reset-metabox-order.php
Created September 19, 2022 14:30
Allow WordPress users to reset the metabox order for the post edit screen.
<?php
/*
Plugin Name: Reset Metabox Order
Description: Allow WordPress users to reset the metabox order for the post edit screen.
Version: 0.0.1
Author: Jonathan Stegall
Author URI: https://code.minnpost.com
Text Domain: reset-metabox-order
License: GPL2+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
isFollow|fbclid|icid|fr|hilite|etype|_hsmi|redirect_to|unapproved|link_id|replytocom|embedded_webview|force_isolation|mc_cid|fs|src|emci|adlt|utm_name|lctg|utm_c|sc_wbt|_x_tr_sl|_x_tr_tl|_x_tr_hl|_x_tr_pto|page|ref|is_install_whatsapp|linkId|back|client|share|msclkid|fb_action_ids|sfmc_sub|ct=|url=|hl=|presentid|ocid|nstoken|fireglass_rsn|blm_aid|platform|RelatedContentIds|hss_channel|stream=|apcid|bxns|cldee|geo|p2=
<?php
/**
* Plugin Name: Environment Files
* Description: Load environment-specific config files
*
*/
if ( 'local' !== VIP_GO_ENV ) {
if ( file_exists( WPCOM_VIP_PRIVATE_DIR . '/' . VIP_GO_ENV . '-config.php' ) ) {
require_once( WPCOM_VIP_PRIVATE_DIR . '/' . VIP_GO_ENV . '-config.php' );

local installation of Elasticsearch for WordPress VIP Go infrastructure

Update, 11/2022:

Apparently none of this will work with Elasticsearch versions greater than 8.0. See elastic/homebrew-tap#126 (comment). The alternative seems to be to use Docker, or since it's a big system either way might as well switch to VVV.

Previous instructions

These are basic instructions, and I'm sure could be tightened up.

<?php
add_action( 'object_sync_for_salesforce_push_success', 'save_sf_id_acf', 10, 5 );
function save_sf_id_acf( $op, $response, $synced_object, $object_id, $wordpress_id_field_name ) {
// do things if the save succeeded
// $op is what the plugin did - Create, Update, Upsert, Delete
// $response is what was returned by the $salesforce class. sfapi->response
// $synced_object is an array like this:
/*
$synced_object = array(
docs/*,vendor/*,release/*
@jonathanstegall
jonathanstegall / process-salesforce-user.php
Last active February 1, 2021 15:35
process users in WordPress; delete user with a specific criteria
add_filter( 'object_sync_for_salesforce_pull_object_allowed', 'process_user', 10, 5 );
function process_user( $pull_allowed, $object_type, $object, $sf_sync_trigger, $salesforce_mapping ) {
if ( 'Contact' === $object_type && 'deletion' === $object['LastName'] ) {
$pull_allowed = false;
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}
if ( is_plugin_active( 'object-sync-for-salesforce/object-sync-for-salesforce.php' ) ) {
$salesforce = Object_Sync_Salesforce::get_instance();
$mapping_object = $salesforce->mappings->get_object_maps(

When a new version of PHP is installed, to keep up with the WordPress VIP Go environment locally we need to do a few things:

  1. pecl install gmagick
  2. If #1 fails with a beta warning, use pecl install channel://pecl.php.net/gmagick-2.0.6RC1 instead (replace with the correct version if necessary)
  3. pecl install memcache
  4. code /usr/local/etc/php/[version]/php.ini to open the ini file. Uncomment the lines extension="gmagick.so" and extension="memcache.so"
  5. valet restart

And to make curl stop complaining about the SSL, do this:

@jonathanstegall
jonathanstegall / ffmpeg.zsh
Created October 7, 2020 21:20
working ffmpeg command for resizing an mov video and converting to mp4
ffmpeg -i 10.04.20.mov -crf 23 -preset medium -movflags +faststart -c:a aac -s 960x540 10.04.20.mp4
@jonathanstegall
jonathanstegall / stories-by-category-and-date.sql
Created July 10, 2020 18:29
get a list of stories that are between a certain date range, and that are in a certain list of categories
SELECT ID, post_date, post_title
FROM wp_posts p
INNER JOIN wp_postmeta m ON p.ID = m.post_id
LEFT JOIN wp_term_relationships r ON (p.ID = r.object_id)
LEFT JOIN wp_term_taxonomy tax ON (r.term_taxonomy_id = tax.term_taxonomy_id)
WHERE post_date >= '2019-06-01' AND post_date < '2020-06-01' AND post_status = 'publish' AND tax.term_id IN (72513, 72511, 72514, 3003, 55565, 55831, 55634, 8389)
GROUP BY p.ID
ORDER BY post_date DESC
;