Skip to content

Instantly share code, notes, and snippets.

View rustam-swe's full-sized avatar
🎯

Rustam rustam-swe

🎯
View GitHub Profile
@rustam-swe
rustam-swe / recalculate-acf-locations.php
Created January 19, 2021 11:54 — forked from RadGH/recalculate-acf-locations.php
Get latitude and longitude for addresses saved in Advanced Custom Fields, using Google's GeoLocation API
<?php
global $acf_recalc_settings;
// IMPORTANT: Customize these settings for your website.
$acf_recalc_settings = array(
// How many updates to do each page load. As of November 2018, Google's GeoLocation API limit is 100 per second.
'posts_per_run' => 16,
@rustam-swe
rustam-swe / file-upload-handler.php
Created December 27, 2020 11:55 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');