Skip to content

Instantly share code, notes, and snippets.

View lucanos's full-sized avatar

Luke Stevenson lucanos

View GitHub Profile
@lucanos
lucanos / CreateWordpressUser.php
Last active June 21, 2022 04:37 — forked from jawinn/CreateWordpressUser.php
Create WordPress Admin User from PHP
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
$user = false;
$errors = array();
if( isset( $_POST ) ){
@lucanos
lucanos / wordpress_reset.sql
Last active September 26, 2020 14:15
WordPress Database Clean Sweep
-- ----------------------------------------------------------------------------
--
-- WordPress Database Clean Sweep
-- ==============================
--
-- NOTE: This SQL Script will completely delete any data in the Wordpress Tables
-- starting with "wp_". Perform a backup before running this script.
--
-- A New Admin User will be created by this script, with the following details:
-- Username - new_admin
@lucanos
lucanos / emergency.php
Created May 21, 2020 05:09
Wordpress Emergency Password Reset
<?php
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@lucanos
lucanos / functions.php
Last active November 30, 2022 12:00 — forked from adeel-raza/functions.php
Get LearnDash next lesson link or first lesson link if course not started
function ld_next_lesson_link( $course_id = null ) {
global $post;
$user = _wp_get_current_user();
if( is_null( $course_id ) ) {
$course_id = learndash_get_course_id( $post );
}
if( !$course_id || !isset( $user->ID ) ) {
// User Not Logged In OR No Course Identified
@lucanos
lucanos / lucanos_learndash_classes.php
Created May 22, 2019 03:37
Adds Classes to Learndash Lessons and Topics based on whether the User has Completed Them or Not
function lucanos_learndash_classes( $classes ) {
global $post;
if( in_array( $post->post_type , array( 'sfwd-lessons' , 'sfwd-topic' ) ) ){
$classes[] = 'learndash';
$progress = learndash_get_course_progress( null, $post->ID );
$classes[] = 'learndash-progress-'.( $progress['this']->completed != 1 ? 'in' : '' ).'complete';
}
return $classes;
}
@lucanos
lucanos / gist:c886043e8eacad6b32ca
Last active March 22, 2016 16:35 — forked from ebinnion/gist:2346560
Gravity Forms Pre-Submission and Notification
// http://www.gravityhelp.com/forums/topic/simple-calculations
// change the 41 here to your form ID
add_action('gform_pre_submission_41', 'ch_awesomeness_rating');
function ch_awesomeness_rating($form) {
// set up one array for each step of the form
// each array contains the input IDs of the fields we want to sum on each page
// IDs do not need to be consecutive using this method
$step_groups = array(
38 => array( 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ) ,