Skip to content

Instantly share code, notes, and snippets.

View mikewing94's full-sized avatar
:atom:

Mike Wing mikewing94

:atom:
View GitHub Profile
@jakebellacera
jakebellacera / ICS.php
Last active February 21, 2025 15:25
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@taterbase
taterbase / upload.php
Created May 13, 2012 15:03
Simple file upload in php
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
@spigotdesign
spigotdesign / user-profile-picture.php
Last active September 26, 2022 04:38
Add WordPress image uploader to user profile.
/*
* Add custom user profile information
*
*/
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
@didats
didats / nationality.html
Created December 28, 2013 00:00
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
@hlashbrooke
hlashbrooke / function.php
Last active October 3, 2019 14:52
Sensei - Remove user from course
<?php
function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) {
global $woothemes_sensei;
$course_id = intval( $course_id );
$user_id = intval( $user_id );
if( $course_id > 0 && $user_id > 0 ) {
// Get all course lessons
@cliffordp
cliffordp / functions.php
Last active September 23, 2023 06:22
Automatically login a single WordPress user upon arrival to a specific page.
<?php
/**
* Automatically login a single WordPress user upon arrival to a specific page.
*
* Redirect to home page once logged in and prevent viewing of the login page.
* Compatible with WordPress 3.9.1+
* Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead."
* Updated 2019-07-09 to reformat code, pass 2nd parameter to `do_action()`, and hook into priority 1.
*
@danjjohnson
danjjohnson / conditional-lesson-display.php
Last active September 25, 2019 10:18
Sensei - Display lessons on course page only for registered users
add_action( 'sensei_before_main_content', 'sensei_conditional_lesson_display', 10 );
function sensei_conditional_lesson_display() {
if( !is_singular('course') ) return;
global $post, $current_user, $woothemes_sensei;
$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
if ( ! ( $is_user_taking_course || sensei_all_access() ) ) {
remove_action( 'sensei_single_course_content_inside_after' , array( 'Sensei_Course','the_course_lessons_title'), 9 );
@james2doyle
james2doyle / simple-json-reponse.php
Last active March 7, 2024 06:02
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($code = 200, $message = null)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
@helgatheviking
helgatheviking / nav-menu-roles-toggle.php
Last active June 4, 2020 09:47
Give Nav Menu Roles priority over any competing Walkers
<?php
/*
Plugin Name: Nav Menu Roles Toggle
Plugin URI: https://gist.github.com/helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c
Description: Give NMR priority over any competing Walkers
Version: 0.2.0
Author: helgatheviking
Author URI: http://kathyisawesome.com
*/
@manlioma
manlioma / sensei_course_complete.php
Created January 12, 2017 23:33
Funzione Per Sensei Corso COmpletato da Lezione
// Controllo se l'utente ha completato il corso
$course_id = intval( get_post_meta( $post->ID, '_lesson_course', true ) ); // Id del corso di cui fa parte la lezione
$user_id = get_current_user_id(); // Id Utente
// Check if course is completed
$user_course_status = Sensei_Utils::user_course_status( $course_id, $user_id );
$completed_course = Sensei_Utils::user_completed_course( $user_course_status );
// Success message
if ( $completed_course ) { ?>