Skip to content

Instantly share code, notes, and snippets.

View endurtech's full-sized avatar

Manny Rodrigues endurtech

View GitHub Profile
@endurtech
endurtech / Block Facebook Crawler facebookexternalhit 1.1.txt
Created June 23, 2024 18:46
The facebookexternalhit/1.1 is a user agent used by Facebook to crawl and index web pages for its various services, such as Facebook, Instagram, and WhatsApp. This crawler is responsible for retrieving content, images, and other metadata to improve Facebook's search functionality and provide users with relevant results. However, the facebookexte…
# BLOCK Facebook Crawler
# https://endurtech.com/block-facebook-crawler-facebookexternalhit/
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit/1\.1 [NC]
RewriteRule ^ - [F,L]
# BLOCK Facebook Crawler END
@endurtech
endurtech / disable-subscriber-wordpress-admin-bar.php
Created March 28, 2024 18:03
Disables the WordPress Admin Bar and WordPress Admin Backend access for Subscribers. Insert into functions.php
<?php
// Disable Subscriber WordPress Admin Bar
// Disables the WordPress Admin Bar and WordPress Admin Backend access for Subscribers.
// https://endurtech.com/disable-subscriber-wordpress-admin-bar/
add_action( 'init', 'disable_admin_bar_for_subscribers' );
function disable_admin_bar_for_subscribers()
{
if ( current_user_can( 'subscriber' ) )
@endurtech
endurtech / rumble.bashr
Created May 11, 2023 23:09
A bash function I stumbled upon online. To be defined in .bashrc or just pasted into bash before exe. download. Once function is installed, run it via: |rumble <URL>|. Tested on Ubuntu 18.04lts and confirmed working.
rumble() {
youtube-dl --no-check-certificate -f mp4-480p/webm-480p/mp4-360p/mp4-720p/mp4-1080p $(curl -s "$1" | tr -d '\n'|awk -F "embedUrl" '{print $2}'|awk -F '"' '{print $3}');
}
@endurtech
endurtech / gravity-forms-auto-delete-wp-user.php
Created March 2, 2023 08:49
The following code, when inserted into a custom plugin or your child theme's functions.php file, will automatically delete the associated WordPress "Users" account when deleting a User from the "Trash" tab.
<?php
// GF Auto Delete User from WP Upon Form Entry Deletion
// If user entry (in members form) is trashed, then deleted from trash, they are also deleted from WP Users table.
// https://endurtech.com/delete-associated-wp-user-when-deleting-gravity-forms-entry/
add_action( 'gform_delete_entry', function ( $entry_id )
{
if ( ! function_exists( 'gf_user_registration' ) )
{
@endurtech
endurtech / wordpress-header-specific-page-hook.php
Last active January 16, 2023 07:04
Insert this code into the functions.php file within your WordPress child-theme to inject any custom code into the HEADER area of a specific page on your WordPress website.
<?php
// Inserting Header Script on Specific Page with WordPress
// https://endurtech.com/insert-script-into-wordpress-header/
add_action( 'wp_head', 'custom_header_page_scripts', 2 );
function custom_header_page_scripts()
{
if( is_page( 123 ) ) //set page number to your page number
{
@endurtech
endurtech / disable-wordpress-commenting.php
Last active January 11, 2023 21:13
The following snippets should help you disable commenting within WordPress.
<?php
// Disable Commenting in WordPress
// https://endurtech.com/how-to-completely-disable-comments-in-wordpress/
add_action( 'admin_init', function ()
{
// Redirect any user trying to access comments page
global $pagenow;
if ( $pagenow === 'edit-comments.php' )
@endurtech
endurtech / remove-protected-private-from-wordpress-titles.php
Created November 16, 2022 13:39
Remove Protected and Private from titles
<?php
// Remove Protected: and Private: from Titles in WordPress
// https://endurtech.com/remove-protected-private-from-title-in-wordpress/
add_filter( 'the_title', 'the_title_trim' );
function the_title_trim( $title )
{
$title = attribute_escape( $title );
$findthese = array(
@endurtech
endurtech / media-library-upload-gravity-forms.php
Last active November 16, 2022 13:43
The following code, when inserted into a custom plugin or your child theme’s functions.php file will forward all file uploads (images and documents) to your Media Library within your WordPress website. As originally seen on: https://infinitesynergysolutions.com/learning-center/add-gravity-forms-file-uploads-and-image-uploads-to-the-media-library/
<?php
// Uploading to the Media Library Using Gravity Forms
// https://endurtech.com/upload-to-the-media-library-using-gravity-forms/
add_action( 'gform_after_submission', 'iss_gf_after_submission', 10, 2 );
function iss_gf_after_submission( $entry, $form )
{
// Walk through form fields, find file upload fields
foreach( $form['fields'] as $field )
@endurtech
endurtech / wordpress-avada-body-hook.php
Created September 19, 2022 20:42
Insert this code into the functions.php file within your WordPress Avada child-theme to inject any custom code into the beginning portion of your WordPress website just after the opening <body> tag.
<?php
// Inserting a Script into Start of WordPress Avada Theme Body
// https://endurtech.com/insert-script-into-wordpress-body/
add_action( 'avada_before_body_content', 'GA4TAGMGR' );
function GA4TAGMGR()
{
echo '<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-YOURMEASURMENTIDHERE" height="0" width="0" style="display:none;visibility:hidden;"></iframe></noscript>
@endurtech
endurtech / wordpress-body-hook.php
Created September 3, 2022 10:53
Insert this code into the functions.php file within your WordPress child-theme to inject any custom code into the BODY of your WordPress website just after the opening <body> tag.
<?php
// Inserting a Script into WordPress Body
// https://endurtech.com/insert-script-into-wordpress-body/
// wp_body_open action hook to inject a script
add_action( 'wp_body_open', 'custom_body_scripts', 10 );
function custom_body_scripts()
{
echo '<script>alert( "This is triggered from within the body of your website." );</script>';