Skip to content

Instantly share code, notes, and snippets.

View estevan-ulian's full-sized avatar
🏠
Working from home

Estevan Ulian estevan-ulian

🏠
Working from home
View GitHub Profile
@estevan-ulian
estevan-ulian / auto_scroll.js
Created December 4, 2025 10:27
This code snippet makes a web page scroll smoothly from top to bottom. Adjust the `speed` variable according to your preference. Copy and paste it into your browser console to start.
(function(){
let speed = 1;
function autoScroll(){
window.scrollBy(0,speed);
if((window.innerHeight+window.scrollY)<document.body.offsetHeight){
requestAnimationFrame(autoScroll);
}
}
autoScroll();
})();
@estevan-ulian
estevan-ulian / disable_wp_comments.php
Last active November 19, 2025 11:07
This code snippet completely disables WordPress comments. Insert it into your theme's functions.php file.
<?php
// Disables support for comments and trackbacks on all post types
function disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
@estevan-ulian
estevan-ulian / cf7_base_config.md
Last active November 3, 2025 11:14
A base config for Contact Form 7

PHP

The snippets below should be inserted into your WordPress theme's functions.php file or via a plugin that does this for you. I particularly like Code Snippets.

Disable paragraph tags

The following filter prevents CF7 from rendering multiple <p> tags in your form, improving custom styling.

add_filter('wpcf7_autop_or_not', '__return_false');
@estevan-ulian
estevan-ulian / getDeviceType.js
Created May 6, 2025 19:58
Verify type of userAgent
function getDeviceType() {
const ua = navigator.userAgent.toLowerCase();
const tablet = /ipad|android(?!.*mobile)|tablet|playbook|silk/;
const mobile = /iphone|ipod|android.*mobile|blackberry|bb10|opera mini|windows phone/;
if (tablet.test(ua)) {
return "tablet";
}
if (mobile.test(ua)) {
return "mobile";
}
@estevan-ulian
estevan-ulian / update_wp_urls.sql
Last active September 27, 2024 10:56
Updates URLs in the database of a wordpress site
SET @prefix = 'wp_'; -- DEFINE TABLES PREFIX
SET @old_url = 'http://old-site.com'; -- DEFINE THE OLD/CURRENT URL
SET @new_url = 'http://new-site.com'; -- DEFINE THE NEW URL
SET @query1 = CONCAT('UPDATE ', @prefix, 'options SET option_value = REPLACE(option_value, ''', @old_url, ''', ''', @new_url, ''') WHERE option_name = ''home'' OR option_name = ''siteurl''');
PREPARE stmt1 FROM @query1;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
SET @query2 = CONCAT('UPDATE ', @prefix, 'posts SET post_content = REPLACE(post_content, ''', @old_url, ''', ''', @new_url, ''')');
@estevan-ulian
estevan-ulian / rel-get-items-by-relation.php
Last active April 24, 2024 17:12 — forked from Crocoblock/rel-get-items-by-relation.php
JetEngine Related Items by Sibling Relation Macro
<?php
add_action( 'jet-engine/register-macros', function(){
class Related_Items_By_Sibling_Relation extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'rel_get_items_by_relation';
}
@estevan-ulian
estevan-ulian / elementor_widgets.xml
Created March 19, 2024 15:42
Register Custom Elementor Widgets in wpml translation - jet accordion and jet tricks hotspots
<wpml-config>
<elementor-widgets>
<widget name="jet-accordion">
<fields-in-item items_of="toggles">
<field type="Classic Accordion: Title" editor_type="LINE">item_label</field>
<field type="Classic Accordion: Editor Content" editor_type="VISUAL">item_editor_content</field>
</fields-in-item>
</widget>
<widget name="jet-hotspots">
<fields-in-item items_of="hotspots">
@estevan-ulian
estevan-ulian / jet-engine-cct-api.php
Created February 28, 2024 17:16 — forked from MjHead/jet-engine-cct-api.php
API to interact with JetEngine CCT from directly PHP code
<?php
/**
* JetEngine CCT-related API functions to use in theme or plugin
*
* Theme usage - include get_theme_file_path( 'jet-engine-cct-api.php' );
* Plugin usage - include PLUGIN_PATH . 'path-to-file-inside-plugin/jet-engine-cct-api.php';
*/
/**
@estevan-ulian
estevan-ulian / add_content_footer.php
Last active February 7, 2024 14:48
Este snippet adiciona trechos de código html logo antes da tag </body> em um site Wordpress.
@estevan-ulian
estevan-ulian / only_numbers_mask.js
Created February 7, 2024 14:42
Mascara para receber somente números no valor do input
function onlyNumbersMask (event) {
let value = event.target.value;
let mask = '';
mask = value.replace(/\D/g, '');
event.target.value = mask;
}