Skip to content

Instantly share code, notes, and snippets.

View kbcarte's full-sized avatar

K.B. Carte kbcarte

View GitHub Profile
@kbcarte
kbcarte / disable_xmlrpc.php
Created September 23, 2022 13:56
WordPress filter to remove XML-RPC functionality, add this to functions.php
<?php
add_filter( ‘xmlrpc_enabled’, ’_return_false’ );
@kbcarte
kbcarte / disable_comments.php
Last active August 23, 2022 13:57
WordPress disable all commenting.
<?php
/*
Force disable all commenting in WordPress
Place this in your functions.php file
Yoink: https://gist.github.com/mattclements/eab5ef656b2f946c4bfb
*/
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
@kbcarte
kbcarte / FZ_dont_use_keys.md
Created August 22, 2022 14:23
FileZilla FATAL ERROR type 11 WPEngine fix

The issue is, on Ubuntu, FileZilla is trying multiple ssh keys even when set to use username/pass for sftp connections. This causes WPEngine to drop the connection after the first one or two attempts with bad keys.

To fix this, we can set the SSH_AUTH_SOCK env variable before launching filezilla. This does require opening FileZilla from the cli, but we can make an alias for it.

In my .bashrc file, I add this alias at the end.

  • alias fz="SSH_AUTH_SOCK=null filezilla &"

Now the cli command fz will open FileZilla and work as expected.

@kbcarte
kbcarte / mp42webm.sh
Last active July 26, 2022 14:32
Use ffmpeg to convert mp4 videos to webm with better keyframe spacing for smooth scroll animations.
# OG Yoink: https://stackoverflow.com/a/33855249
# -g 8, was chosen based on this: https://docs.microsoft.com/en-us/windows/win32/wmformat/configuring-video-streams-for-seeking-performance?redirectedfrom=MSDN
ffmpeg -i input_video.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis -g 8 output_video.webm;
@kbcarte
kbcarte / upload-set-featured-image.php
Created July 19, 2022 14:49
Wordpress function to upload and set a posts featured image with php.
@kbcarte
kbcarte / functions.php
Created June 27, 2022 15:21
WordPress show page template being used
<?php
// Yoink: https://mekshq.com/which-wordpress-template-file-used/
//For example, you can paste this into your theme functions.php file
function meks_which_template_is_loaded() {
if ( is_super_admin() ) {
global $template;
print_r( $template );
}
}
@kbcarte
kbcarte / functions.php
Last active November 22, 2023 20:34
WordPress insert into head and body (GTAG, Analytics)
<?php
// Insert code snippits to the <head> and <body> tags
// Useful for gtag and analytics
function insert_in_head() {
?>
<!-- Google Tag Manager -->
<!-- SCRIPT FOR GTAG -->
<!-- End Google Tag Manager -->
@kbcarte
kbcarte / google_font_weight_conversion.md
Last active June 17, 2022 18:04
Google font weight conversion
@kbcarte
kbcarte / find-contact-form-7.md
Created May 6, 2022 15:36
Find all posts and pages in WordPress containing contact form 7

For ALL contact form 7

SELECT `guid`, `post_title` FROM `wp_posts` WHERE `post_content` LIKE '%[contact-form-7%'

For contact form 7 form by ID

Replace <ID HERE> with the id number found in wp-admin

SELECT `guid`, `post_title` FROM `wp_posts` WHERE `post_content` LIKE '%[contact-form-7 id="<ID HERE>"%'
@kbcarte
kbcarte / update_yoast_index.md
Last active August 23, 2022 14:05
Update all pages/posts Yoast SEO Advanced settings to be index by google

Update all pages/posts to be index by google. This is a global update and will set all posts/pages to be indexed.

UI found in post/page in the Yoast SEO setction, under Advanced

Run this query in phpmyadmin, adminer, or what ever db client you are using.

UPDATE `wp_postmeta` SET `meta_value`='2' WHERE `meta_key`='_yoast_wpseo_meta-robots-noindex'