Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 07:06 (UTC -04:00)
View GitHub Profile
wp post delete $(wp db query --skip-column-names --batch "select DISTINCT p1.ID from wp_posts p1
left join wp_posts p2 ON p1.post_parent = p2.ID
where p1.post_type = 'attachment'
AND p2.ID is NULL") --force
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_safe_redirect(admin_url());
exit;
}
// Remove comments metabox from dashboard
@davekuhar
davekuhar / git-version-control.markdown
Created October 2, 2021 19:49 — forked from albatrocity/git-version-control.markdown
Some basic Git instructions for Github for Mac and the command line

Using Git version control for code projects

Creating a new code repo from a local working copy

  1. From the repositories view in the app, drag the project folder to the bottom of the left sidebar.
  2. Hit "Yes" when it asks if you want to create a local git repository
  3. Go to "Changes" view (⌘2)
  4. Select the files that you want to commit their current state to the repository. You can view the changes of the file by clicking on the double up arrow on the file name bar.
wp search-replace "\[vc.*]|\[\/vc.*]" "" --precise --all-tables --regex

Please follow these instructions to add a global Facebook pixel to URLs on your subdomain, and to send events to Facebook. These modifications will allow all advertisers in the Stanford Univ. organization to have meaningful conversion events based on the stanford.edu domain to leverage as conversion events with Facebook ad sets that are in a conversion objective campaign.

Please note that custom events, custom conversions and custom audiences based on your current pixel(s) will survive these modifications. Once these modifications are made for most advertisers, after roughly a week’s data has collected against the global pixel, we’ll communicate planned changes to be made at a specific date / time to the AEM events list for stanford.edu. At that time we will be asking each advertiser transition to using standard events associated with the global pixel as their ad set conversion event

@davekuhar
davekuhar / bb-search.php
Created November 10, 2019 20:38 — forked from TwisterMc/bb-search.php
Beaver Builder - Add Search to Mobile
<?php
/**
* Add Search Box to Mobile
* Adds a search box to mobile, below the header.
* To move it above the header, change fl_after_header to fl_before_header
*/
function bbMenuPolish_addMobileSearch(){
if ( wp_is_mobile() ) {
get_search_form();
}
Make changes to searchform.php
See https://handcoded.ca/wordpress-custom-search-form/
rm -r ~/Library/QuickLook/DropboxQL.qlgenerator
touch ~/Library/QuickLook/DropboxQL.qlgenerator
qlmanage -r
/* remove pesky youtube links from post excerpts */
add_filter('wpv_filter_post_excerpt', 'xmit_remove_youtubelinks');
function xmit_remove_youtubelinks($excerpt){
return $excerpt = preg_replace('~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i', '', $excerpt);
}
@davekuhar
davekuhar / string-utils.js
Created June 28, 2019 16:17 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();