Skip to content

Instantly share code, notes, and snippets.

@jaimeguaman
jaimeguaman / gist:eba17813b218696993e7f7d543b9c20d
Created July 16, 2020 23:35 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@jaimeguaman
jaimeguaman / pmt.js
Created September 15, 2019 14:43 — forked from maarten00/pmt.js
Excel PMT in PHP and JavaScript
/**
* Copy of Excel's PMT function.
* Credit: http://stackoverflow.com/questions/2094967/excel-pmt-function-in-js
*
* @param rate_per_period The interest rate for the loan.
* @param number_of_payments The total number of payments for the loan in months.
* @param present_value The present value, or the total amount that a series of future payments is worth now;
* Also known as the principal.
* @param future_value The future value, or a cash balance you want to attain after the last payment is made.
* If fv is omitted, it is assumed to be 0 (zero), that is, the future value of a loan is 0.
/***************************************
Responsive Helper
Usage:
.my-box {
padding: 10px;
@include for-size(tv) {
padding: 80px;
}
@include for-size(desktop-up) {