Skip to content

Instantly share code, notes, and snippets.

View mikewing94's full-sized avatar
:atom:

Mike Wing mikewing94

:atom:
View GitHub Profile
@mikewing94
mikewing94 / ICS.php
Created March 17, 2020 17:01 — forked from jakebellacera/ICS.php
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.
*
<?php
global $wpdb;
global $woothemes_sensei;
$current_uid = $_GET['uid'];
$all_lessons = $wpdb->get_results("SELECT * FROM `wp_posts` WHERE `post_type` = 'lesson'");
<?php
session_start();
// Start the session
//header file
$language = $_GET['lang'];
$languagestart = '?lang=';
$newlanguage = $languagestart.$language;
@mikewing94
mikewing94 / simple-json-reponse.php
Created September 10, 2019 07:16 — forked from james2doyle/simple-json-reponse.php
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($message = null, $code = 200)
{
// 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");
@mikewing94
mikewing94 / insert-posts.php
Created July 8, 2018 19:14
Insert a post into WordPress from an external script
<?php
// Load WordPress
require_once 'path/to/www/wp-load.php';
require_once ABSPATH . '/wp-admin/includes/taxonomy.php';
// Set the timezone so times are calculated correctly
date_default_timezone_set('Europe/London');
// Create post
@mikewing94
mikewing94 / deletecert.php
Created November 29, 2017 11:09
Delete from a custom table in WordPress PHP
<?php
//DELETE SCRIPT CUSTOM TABLE
//CERTIFICATE UPLOADS
$uid = $_GET['uid'];
$cert = $_GET['cert'];
$table = 'wp_certdatabase';
$wpdb->delete( $table, array( 'filename' => $cert ) );
echo "Delete successful!";
@mikewing94
mikewing94 / functions.php
Created August 31, 2017 09:16
Sensei Display course certificate on quiz pages
add_action( 'sensei_before_main_content', 'senseiBeforeMainContent', 10 );
function senseiBeforeMainContent() {
if( !is_singular('quiz') ) return;
global $post, $current_user;
if(isset($post->post_parent) && $post->post_parent != 0) {
$lessonPost = get_post($post->post_parent);
$courseID = get_post_meta($lessonPost->ID, '_lesson_course', true);
@mikewing94
mikewing94 / .php
Last active March 8, 2017 16:21
class-woothemes-sensei-email-learner-graded-quiz.php backup
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WooThemes_Sensei_Email_Learner_Graded_Quiz' ) ) :
/**
* Learner Graded Quiz
*
* An email sent to the learner when their quiz has been graded (auto or manual).
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WooThemes_Sensei_Email_Learner_Completed_Course' ) ) :
/**
* Learner Completed Course
*
* An email sent to the learner when they complete a course.
jQuery(document).ready(function(){
jQuery('input[name=hidden_email_field]').attr('id', 'hidden_email_field'); // matches exactly 'hidden_email_field'
jQuery('#username, #first_name, #last_name, #company, #other_company, #password, #hidden_email_field, #lang, #language').bind('keypress blur', function() {
jQuery('#first_name, #last_name').keyup(function () {
this.value = this.value.replace(/ /g, "_");
});
jQuery('#user_email').val(jQuery('#first_name').val() + '' +
jQuery('#last_name').val() + '' +
jQuery('#company').val() + '' +
jQuery('#password').val() + '' +