Skip to content

Instantly share code, notes, and snippets.

@machouinard
machouinard / wp-delete-trackbacks-pingbacks.php
Created April 9, 2022 07:08 — forked from kasparsd/wp-delete-trackbacks-pingbacks.php
Delete all WordPress trackbacks and pingbacks
<?php
$comments = get_comments( array(
'type' => 'pings',
'fields' => 'ids',
) );
foreach ( $comments as $no => $comment_id ) {
wp_delete_comment( $comment_id, true );
}
@machouinard
machouinard / budypress-xprofile-add-states.php
Created September 28, 2021 01:21 — forked from Garconis/budypress-xprofile-add-states.php
BuddyPress | xprofile add states as user dropdown field
<?php
/*
If you are using BP 2.1+, this will insert a State selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
Remove this function after the field is created.
*/
function bp_add_custom_state_list() {
@machouinard
machouinard / fd-clear-elementor-cache.php
Created September 11, 2020 06:59 — forked from heyfletch/fd-clear-elementor-cache.php
Clear Elementor Cache After a WP Migrate DB Pro Migration - Must Use Plugin (mu-plugins)
<?php
/*
Plugin Name: FD Clear Elementor Cache After WP Migrate DB Migration
Plugin URI: https://gist.github.com/heyfletch/769c64ad1fab8679032b076433afafd1
Description: Deletes CSS in uploads/elementor/css, which auto-regenerates on pageload. This clears the cache locally and remotely. Must-use plugin (mu-plugin).
Author: Fletcher Digital
Version: 0.1.1
Author URI: https://fletcherdigital.com
*/
@machouinard
machouinard / setup-phpunit.sh
Created November 6, 2019 01:22 — forked from keesiemeijer/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
@machouinard
machouinard / gist:fae9ec615d7e3dc8bd45d5dc0e708bef
Created March 11, 2017 20:27 — forked from bradp/gist:4999343
WordPress function to convert address to Lat/Long
<?php
function brrad_geocode($street_address,$city,$state){
$street_address = str_replace(" ", "+", $street_address); //google doesn't like spaces in urls, but who does?
$city = str_replace(" ", "+", $city);
$state = str_replace(" ", "+", $state);
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$street_address,+$city,+$state&sensor=false";
$google_api_response = wp_remote_get( $url );
@machouinard
machouinard / pe-customize-controls.css
Created February 14, 2017 07:33 — forked from OriginalEXE/pe-customize-controls.css
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@machouinard
machouinard / test.js
Created August 11, 2016 23:56 — forked from mgibbs189/test.js
FacetWP - intercept Genesis pagination
(function($) {
$(document).on('click', '.pagination a', function(e) {
e.preventDefault();
var matches = $(this).attr('href').match(/\/page\/(\d+)/);
if (null != matches) {
FWP.paged = parseInt(matches[1]);
}
FWP.soft_refresh = true;
FWP.refresh();
});
<?php
function my_facetwp_sort_options( $options, $params ) {
$options['rating'] = array(
'label' => 'Rating',
'query_args' => array(
'orderby' => 'meta_value_num', // sort by numerical custom field
'meta_key' => 'rating', // required when sorting by custom fields
'order' => 'DESC', // descending order
)

Last updated: 2015-08-11

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

<?php
/**
* Includes a few useful predicates in the bootstrapped `infiniteScroll` JS object
* that is served along with the rest of the document upon initial page request.
*/
add_filter( 'infinite_scroll_js_settings', 'mcsf_extra_js_settings' );
function mcsf_extra_js_settings( $js_settings ) {
$js_settings['query_args']['extra'] = array(
'is_home' => is_home(),