Skip to content

Instantly share code, notes, and snippets.

View doubleedesign's full-sized avatar

Leesa Ward doubleedesign

View GitHub Profile
@eduwass
eduwass / aux-functions.php
Last active August 11, 2022 05:21
Programmatically adding a Page item to a Wordpress nav menu
<?php
/**
* Adds Page to a WordPress navmenu
* @param [int] $page_id The ID of the page you want to add
* @param [str] $page_title Title of menu item
* @param [int] $menu_id NavMenu ID
* @param [int] $parent (Optional) Menu item Parent ID
*/
function add_page_to_menu($page_id, $page_title, $menu_id, $parent = 0){
<?php
add_action( 'woocommerce_customer_changed_subscription_to_cancelled', 'customer_skip_pending_cancellation' );
/**
* Change 'pending-cancel' status directly to 'cancelled'.
*
* @param WC_Subscription $subscription
*/
function customer_skip_pending_cancellation( $subscription ) {
if ( 'pending-cancel' === $subscription->get_status() ) {
@jordanharper
jordanharper / gist:993034
Created May 26, 2011 12:29
HTTP authentication with a file_get_contents request
<?php
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);