Skip to content

Instantly share code, notes, and snippets.

View julian-stark's full-sized avatar

Julian Stark julian-stark

View GitHub Profile
@mbaersch
mbaersch / functions.php
Created March 25, 2020 11:39
send serverside conversions from a Wordpress shop (e. g. wooCommerce) to Google Analytics
<?php
// add one of the two following options to the functions.php of your child theme in order to send server side
// conversion data to Google Analytics
// NOTE: function store_gclid() is used by both variants
/***************************************************************************************************/
// send conversion to Analytics - Option 1: track success page as only pageview in the session and
// create a goal for path "/conversion/"
// adjust goal path (fragment) in $goalurl in order to fit your url structure
// comment out line below to deactivate
@RadGH
RadGH / rs_upload_from_url.php
Last active March 27, 2024 23:30
Upload a file from a URL to the WordPress media gallery. Supports images, PDFs, and other file types.
<?php
/**
* This function uploads a file from a URL to the media library, designed to be placed in your own theme or plugin.
* Metadata will be generated and images will generate thumbnails automatically.
*
* HOW TO USE:
* 1. Add the function below to your theme or plugin
* 2. Call the function and provide the URL to an image or other file.
* 3. If successful, the attachment ID will be returned.
@waqashassan98
waqashassan98 / bookings_in_date_range_woocommerce_bookings.php
Created January 28, 2018 14:56
This function can be used to get the booking details in a date range from Woocommerce Bookings plugin
get_bookings_in_date_range_wh( $next_monday, $next_friday, $product_id, true );
function get_bookings_in_date_range_wh( $start_date, $end_date, $product_or_resource_id = 0, $check_in_cart = true ) {
$args = array(
'status' => get_wc_booking_statuses(),
'object_type' => 'product_or_resource',
'date_between' => array(
'start' => $start_date,
'end' => $end_date,
),
@djrmom
djrmom / custom-hooks.php
Created October 27, 2017 13:28
facetwp date source converted to year
<?php
/**
* reindex after adding or updating this filter
*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'date_as_year' == $params['facet_name'] ) { // change date_as_year to name of your facet
$raw_value = $params['facet_value'];
$params['facet_value'] = date( 'Y', strtotime( $raw_value ) );
$params['facet_display_value'] = $params['facet_value'];
@sirbrillig
sirbrillig / functions.php
Last active January 24, 2024 15:46 — forked from UmeshSingla/functions.php
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);
@kstover
kstover / customDatePicker.js
Last active February 2, 2024 10:06
Customising Ninja Forms date picker field
/*
* When our date picker loads, we want to modify some of picker settings.
*
* We want to:
* 1) Modify our month labels with a different string.
* 2) Disable specific dates so that they can't be selected.
*
*
* This object will listen to date pickers as they initialize so that we can modify settings.
*/
@boffey
boffey / prevent-roboto.js
Last active October 1, 2022 12:01
Prevent Google Maps from loading the Roboto font.
var head = document.getElementsByTagName('head')[0];
// Save the original method
var insertBefore = head.insertBefore;
// Replace it!
head.insertBefore = function (newElement, referenceElement) {
if (newElement.href && newElement.href.indexOf('https://fonts.googleapis.com/css?family=Roboto') === 0) {
return;
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@mkolb
mkolb / var_dump-log.php
Last active January 3, 2023 14:53
var_dump into error log
<?php
ob_start();
var_dump($this);
error_log(ob_get_clean());
?>