Skip to content

Instantly share code, notes, and snippets.

View bookchiq's full-sized avatar

Sarah Lewis bookchiq

View GitHub Profile
@bookchiq
bookchiq / update_buddypress_avatar_from_external_url.php
Created June 5, 2023 17:46
Update a BuddyPress/BuddyBoss avatar from an external URL
<?php
/**
* Updates the avatar of a user based on the user's ID.
*
* This function downloads an image from an external URL and saves it
* as the user's avatar. If the image is not square, it crops it to a
* square shape before saving.
*
* @since 1.0.0
* @access public
@tabakerov
tabakerov / struthless-journaling-tips.md
Created August 5, 2021 13:47
Struthless' tips for journaling

https://www.youtube.com/watch?v=dArgOrm98Bk

Clarity

Just dump everything from mind

Breaking your mindset

  • Imagine 6 impossible things
  • How can I make someone else happy right now?
  • What's something in my immediate environment that I have never noticed?
@karlhillx
karlhillx / macos_big_sur_homebrew_apache_php_mariadb_2020.md
Last active May 10, 2024 03:16
macOS Big Sur 11.0 Setup: Homebrew + Apache + PHP + MariaDB (Regularly updated)

macOS Big Sur 11.0 Setup: Homebrew + Apache + PHP + MariaDB

This document helps get your macOS development environment up and running with the latest versions of Homebrew, Apache, PHP, and MariaDB.

@ben-heath
ben-heath / facetwp-template-display-if-facet-selected.php
Last active June 9, 2022 19:07
FacetWP - show template only if a facet is selected
<?php
/* This code goes into your child theme's function.php file
* Or it can use FacetWP's recommendation and use a plugin https://facetwp.com/how-to-use-hooks/
*
* I found that the tutorial on FacetWP's site didn't function how I wanted it to.
* https://facetwp.com/how-to-hide-the-template-until-facets-are-selected/
* Their method doesn't allow a template to show if you use a link with a url query, indicating a facet selection, it only works if
* if you 'click' on the page. So I came up with some JS that looks at the facet list, and looks for any 'checked' items.
* This way, whether it was clicked while on the page, or you linked to the page with a query string selection, it still works as I wanted.
*/
@FesoVel
FesoVel / WordPress - Insert HTML In Header
Created January 4, 2019 12:48
How to add html code to WordPress <head> using wp_head hook.
function insert_html_in_header() {
echo '<<< html here >>>';
}
/* Admin Dashboard */
add_action( 'admin_head', 'insert_html_in_header' );
/* Front End */
add_action( 'wp_head', 'insert_html_in_header' );
@akamyshanov
akamyshanov / gmail-auto-archive.js
Created September 18, 2018 09:29
GMail Auto Archive script for Google Scripts
function gmailAutoarchive() {
var threads = GmailApp.search("in:inbox label:auto-archive older_than:2d");
Logger.log("found " + threads.length + " threads:");
for(var i = 0; i < threads.length; i++) {
var thread = threads[i];
Logger.log((i+1) + ". " + thread.getFirstMessageSubject());
}
var batch_size = 100;
@dinvlad
dinvlad / pre_request.js
Last active April 11, 2024 02:57
Auto-generate Google Access and ID tokens from a Service Account key and save it in Postman
/* This script auto-generates a Google OAuth token from a Service Account key,
* and stores that token in accessToken variable in Postman.
*
* Prior to invoking it, please paste the contents of the key JSON
* into serviceAccountKey variable in a Postman environment.
*
* Then, paste the script into the "Pre-request Script" section
* of a Postman request or collection.
*
* The script will cache and reuse the token until it's within
@djrmom
djrmom / script.js
Created July 24, 2018 17:49
facetwp check if a facet is in use
<script>
(function($) {
/**
* check if a facet exists and has value(s), change 'categories' to name of the facet being checked
*/
$(document).on('facetwp-loaded', function() {
if ('undefined' !== typeof FWP.facets['categories'] && FWP.facets['categories'].length > 0 ) {
// do something if facet is in use
}
});
@tallesairan
tallesairan / README.md
Last active March 25, 2024 22:06
check if the post exists by slug and post type #wp

Tips

very useful when you can have an attachment with the same slug as a post record_exists_by_slug You can check the post if it exists as an attachment you can change, this way it is practically impossible to duplicate a post

@blakemiller99
blakemiller99 / wp-remove-posts-type
Last active November 23, 2022 13:52
Remove Posts from WordPress
// ************* Remove default Posts type since no blog *************
// Remove side menu
add_action( 'admin_menu', 'remove_default_post_type' );
function remove_default_post_type() {
remove_menu_page( 'edit.php' );
}
// Remove +New post in top Admin Menu Bar