Skip to content

Instantly share code, notes, and snippets.

@firasd
firasd / functions.php
Created May 24, 2018 21:52
Remove 'Mark Complete' button from lesson pages in Learndash course
<?php
add_filter('learndash_mark_complete', function($return, $post) {
$course_hide_markcomplete = 0;
if(learndash_get_course_id($post->ID) == $course_hide_markcomplete) {
$return = '';
}
return $return;
}, 10, 2);
@firasd
firasd / functions.php
Created May 16, 2018 04:09
Redirect WordPress user from LearnDash course page to first lesson page
<?php
add_action('template_redirect', function () {
if (is_user_logged_in()) {
$q_object = get_queried_object();
if (($q_object) && (is_a($q_object, 'WP_Post')) && ($q_object->post_type == 'sfwd-courses')) {
if (sfwd_lms_has_access($q_object->ID)) {
$steps = learndash_get_course_steps($q_object->ID);
if (count($steps)) {
wp_redirect(get_permalink($steps[0]));
@firasd
firasd / singleton.php
Last active February 12, 2018 05:46
PHP Singleton
<?php
class scriptmem {
public static $cache;
public static function init() {
if(self::$cache === null) {
self::$cache = array();
}
return self::$cache;
}
@firasd
firasd / gist:df2fb55dc8f8b75db33ab5441c71a88b
Created September 21, 2017 00:51
wget without file output
wget -O - "http://example.com/?query=1" > /dev/null 2>&1
.top-timeline-tweetbox .tweet-form.condensed .rich-editor.notie div {
display: none;
}
.top-timeline-tweetbox .tweet-form.condensed .rich-editor.notie:after {
content: "WHAT IS HAPPENING";
}
.top-timeline-tweetbox .tweet-form div.rich-editor.is-showPlaceholder:before {
content: "WHAT IS HAPPENING"
}