Skip to content

Instantly share code, notes, and snippets.

View endurtech's full-sized avatar

Manny Rodrigues endurtech

View GitHub Profile
@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>';
@endurtech
endurtech / wordpress-header-hook.php
Last active September 3, 2022 10:40
Insert this code into the functions.php file within your WordPress child-theme to inject any custom code into the HEADER of your WordPress website.
<?php
// Inserting a Script into WordPress Header
// https://endurtech.com/insert-script-into-wordpress-header/
// wp_head action hook to inject a script
add_action( 'wp_head', 'custom_header_scripts' );
function custom_header_scripts()
{
echo '<script>alert( "This is triggered from within the header of your website." );</script>';
@endurtech
endurtech / wordpress-footer-hook.php
Last active September 3, 2022 10:40
Insert this code into the functions.php file within your WordPress child-theme to inject any custom code into the FOOTER area of your WordPress website.
@endurtech
endurtech / .htaccess
Last active June 2, 2022 11:01
Redirect Visitors to Another Website
# Call RewriteEngine if you haven't already done so
RewriteEngine On
RewriteBase /
# Replace 1.2.3.4 with your IP Address and othersite.com.
RewriteCond %{REMOTE_ADDR} !^1.2.3.4
RewriteRule .* https://othersite.com [R=302,L]
@endurtech
endurtech / .htaccess
Last active June 2, 2022 11:00
Restrict Server Access by IP Address using .htaccess
# Restrict server access by IP address. Separate multiple addresses with a space.
# This example uses xxx as IP 1 and yyy as IP 2.
<RequireAll>
Require ip xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy
</RequireAll>
<?php
// update the number '1' to the ID number on your form
// https://endurtech.com/create-read-only-field-in-gravityforms/
add_filter( 'gform_pre_render_1', 'add_readonly_script' );
function add_readonly_script( $form )
{
?><script type="text/javascript">jQuery(document).ready(function() { jQuery("li.gf_readonly input[type=radio]").attr("onclick","return false;"); });</script><?php
return $form;
}
?>
<?php
// update the number '1' to the ID number on your form
// https://endurtech.com/create-read-only-field-in-gravityforms/
add_filter( 'gform_pre_render_1', 'add_readonly_script' );
function add_readonly_script( $form )
{
?><script type="text/javascript">jQuery(document).ready(function() { jQuery("li.gf_readonly input[type=checkbox]").attr("onclick","return false;"); });</script><?php
return $form;
}
?>
<?php
// update the number '1' to the ID number on your form
// https://endurtech.com/create-read-only-field-in-gravityforms/
add_filter( 'gform_pre_render_1', 'add_readonly_script' );
function add_readonly_script( $form )
{
?><script type="text/javascript">jQuery(document).ready(function() { jQuery("li.gf_readonly input").attr("readonly","readonly"); });</script><?php
return $form;
}
?>
<?php
// update the number '1' to the ID number on your form
// https://endurtech.com/create-read-only-field-in-gravityforms/
add_filter( 'gform_pre_render_1', 'add_readonly_script' );
function add_readonly_script( $form )
{
?><script type="text/javascript">jQuery(document).ready(function() { jQuery("li.gf_readonly textarea").attr("readonly","readonly"); });</script><?php
return $form;
}
?>