Skip to content

Instantly share code, notes, and snippets.

@fldtrace
fldtrace / functions.php
Last active July 3, 2021 18:26
Better, Faster, Responsive Images for Divi – Upload in Divi child theme.
<?php
// enable divi functions
add_action( 'wp_enqueue_scripts', 'my_enqueue_assets' );
function my_enqueue_assets() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
//add 1440px image size
add_image_size('image_1440', 1440, 9999, false);
@spivurno
spivurno / gp-unique-id-wait-for-payment-3rd-party.php
Last active April 30, 2020 04:52
Gravity Perks // GP Unique ID // Add Wait-for-payment Support for 3rd-party Payment Gateways
<?php
/**
* Gravity Perks // GP Unique ID // Add Wait-for-payment Support for 3rd-party Payment Gateways
* http://gravitywiz.com/documentation/gp-unique-id/
*/
// 1 - Indicate that waiting for payments is enabled.
add_filter( 'gpui_wait_for_payment', '__return_true' );
// 2 - Fetch the applicable payment feed for your gateway.
@zeikeland
zeikeland / calculate-mortage.js
Last active April 29, 2017 15:24
Calculate mortage payments pr month
/**
* Function for calculating loan ammount.
* Sum is without fees and additional costs.
*/
function calculate_mortage( totalammount, ownmoney, interest, years ) {
/**
* Formula M = P * ( J / (1 - (1 + J)^-N))
* M = Payment monthly
* P = Loan ammount
* J = Effective intrest in decimal (x% / 100) / 12 months
@tomazzaman
tomazzaman / README.md
Last active March 31, 2021 06:30
Simple WordPress Optin form with CURL support

Simple Optin form example for WordPress

This is a simplified showcase of how you can easily build your own Optin form in WordPress.

It can connect to any API that supports cURL (most of them do). There is no error reporting implemented. It uses exit intent detection script called Ouibounce, which needs to be enqueued in your functions.php

See the tutorial here: How to build your own WordPress email form

@gunjanpatel
gunjanpatel / amazon-ec2-ftp.md
Last active October 10, 2023 15:31
amazon ec2 LAMP and FTP installation and setup
@tomazzaman
tomazzaman / class-watermark-image.php
Created April 7, 2015 19:30
Watermarking uploads in WordPress with Imagemagick
function register_watermarked_size() {
add_image_size( 'watermarked', 550, 550, true ); // This is what should be uploaded
}
add_action( 'init', 'register_watermarked_size' );
class Watermark_Image {
// The attachment meta array
public $meta = array();
@tomazzaman
tomazzaman / functions.php
Created February 18, 2015 23:57
Insert image in WordPress with HTML5 <figure> tag and caption
<?php
// Don't include the opening tag
function html5_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
$src = wp_get_attachment_image_src( $id, $size, false );
$html5 = "<figure id=\"post-$id media-$id\" class=\"align-$align\">";
if ( $url ) {
$html5 .= "<a href=\"$url\" class=\"image-link\"><img src=\"$src[0]\" alt=\"$alt\" /></a>";
} else {
@evo42
evo42 / .htaccess
Last active April 29, 2017 15:20
due payment reminder for WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .(wp-login)\.php*
RewriteCond %{HTTP_REFERER} !.*(no.payment|what.the.fuck).* [OR]
RewriteRule (.*) /pay-due-invoice-to-login.htm [R=301,L]
</ifModule>
@r-a-y
r-a-y / bp-footer-debug.php
Last active November 19, 2022 00:34
A BuddyPress debug plugin that outputs some useful BuddyPress global variables in the footer.
@wpscholar
wpscholar / functions.php
Last active March 1, 2021 13:26
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/