Skip to content

Instantly share code, notes, and snippets.

View cdsaenz's full-sized avatar

charly cdsaenz

View GitHub Profile
@cdsaenz
cdsaenz / wp-config.php
Created February 26, 2025 14:58
WordPress wp-config.php settings for development (avoid logging deprecated and notices)
<?php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'FS_METHOD', 'direct' );
// Adjust as per your server/php memory
define( 'WP_MEMORY_LIMIT', '1024M' );
// Don't log deprecated errors etc
function csdev_error_handler($errno, $errstr, $errfile, $errline)
@cdsaenz
cdsaenz / removecptslug.php
Created January 31, 2025 17:30
WordPress Remove CPT Base URL and Ensure Unique Slug
<?php
/**
* Add in functions.php or in a specialized plugin
* Change 'location' to the desired CPT which should already exist
* (example created via ACF)
* Mostly extracted from https://wordpress.stackexchange.com/questions/203951/remove-slug-from-custom-post-type-post-urls
* By Matt Keys, arafatgazi and others
*/
// remove post type from permalinks
function remove_post_type( $post_link, $post, $leavename ) {
@cdsaenz
cdsaenz / Loader.php
Created January 23, 2025 16:35
WordPress Central Hooks Loader
<?php
/**
* Register all actions and filters for the main class
*/
namespace CSDev\PluginName;
class Loader {
@cdsaenz
cdsaenz / noemptyptags.php
Created January 14, 2025 21:18
trying no empty p tags
<?php
function hdbc_page_header( $atts, $content = '' ) {
// get the current URL params array.
$url_params_raw = hdbc_get_url_params( true );
$url_params = $url_params_raw;
// remove the base slug.
unset( $url_params[0] );
// get the URL parameters for this page.
@cdsaenz
cdsaenz / functions.php
Created December 4, 2024 18:50 — forked from unculturedswine/functions.php
Using Pardot and Formidable
<?php
add_action('frm_after_create_entry', 'sendToPardotFormHandler', 30, 2);
function sendToPardotFormHandler($entry_id, $form_id){
if($form_id == 3){ //replace 3 with the id of the form
$args = array();
if(isset($_POST['item_meta'][XX])) //change XX to the field ID
$args['firstName'] = $_POST['item_meta'][XX]; //change 'firstName' to the named parameter to send
if(isset($_POST['item_meta'][XX])) //change XX to the field ID
$args['lastName'] = $_POST['item_meta'][XX]; //change 'lastName' to whatever you need
if(isset($_POST['item_meta'][XX])) //change XX to the field ID
@cdsaenz
cdsaenz / lazy-load
Created October 30, 2024 20:54 — forked from keithdevon/lazy-load
Lazy loading WordPress images
// make sure this script is called in the footer of your document
function inView(image){
var $image = jQuery(image),
view_top = jQuery(window).scrollTop() - 300,
view_bottom = view_top + jQuery(window).height() + 600,
height = $image.height(),
_top = $image.offset().top,
_bottom = _top + height;
return height > 0 && _top <= view_bottom && _bottom >= view_top;
@cdsaenz
cdsaenz / 404.php
Created October 26, 2024 16:34
NadaPHP Minimal Framework
<!DOCTYPE html>
<html lang="en">
<head>
<?= partial('parts/head', ['title' => '404 Not Found']) ?>
</head>
<body>
<?= partial('parts/navbar') ?>
@cdsaenz
cdsaenz / website-field.php
Created September 5, 2024 18:16 — forked from cartpauj/website-field.php
Collect a website URL from users at signup in MemberPress. Allows you to store a different website URL with each user's subscription.
<?php
/*
Plugin Name: MemberPress Website Fields
Version: 1.0.0
Author: Caseproof, LLC
Author URI: http://caseproof.com
Description: Allow users to enter their website URL for each subscription they purchase
*/
//Signup form functions
@cdsaenz
cdsaenz / README.md
Created March 20, 2024 21:04 — forked from AmmarCodes/README.md
WordPress: link to specific elementor tab on a specific page

It's a quick ad-hoc solution to allow you to link to your page to a specific tab from elementor tabs widget.

Here's the catch, you need to replace the id of the specific tab you want to use to not contain the title- part.

Use https://your-website/#elementor-tab-1515

instead of: https://your-website/#elementor-tab-title-1515

@cdsaenz
cdsaenz / index.html
Created March 6, 2024 12:14 — forked from iosifnicolae2/index.html
Whatsapp Floating Button
<a href="https://wa.me/40123456789?text=hi" style="
position: fixed;
width: 60px;
height: 60px;
bottom: 32px;
right: 33px;
background-color: #25d366;
color: #FFF;
border-radius: 50px;
text-align: center;