This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove the LearnDash related scripts / styles from the homepage. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'child_manage_learndash_styles', 99 ); | |
function child_manage_learndash_styles() { | |
// Check if LearnDash exists to prevent fatal errors. | |
if ( class_exists( 'SFWD_LMS' ) ) { | |
// Make sure we are on the front page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'genesis_post_date_shortcode', 'example_custom_date_shortcode' ); | |
function example_custom_date_shortcode( $atts ) { | |
$custom_date = the_date( 'Y-m-d', '<p class="custom-date">', '</p>' ); | |
$atts = array( | |
'after' => '', | |
'before' => '', | |
'format' => $custom_date, | |
'label' => '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_add_to_cart_redirect', 'example_redirect_to_checkout' ); | |
function example_redirect_to_checkout() { | |
$redirect_url = WC()->cart->get_checkout_url(); | |
if ( is_product() && has_term( 'Trial', 'product_cat' ) ) { | |
return $redirect_url; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, WordPress has hooks and filters available to add columns and rows to screens. ie: plugin, post, pages, etc. | |
Add custom columns hook: manage_{screen->id}_columns | |
Add custom row data filter: manage_plugins_custom_column | |
However, to make those columns sortable you must reference the key-value entries manage_{screen->id}_columns | |
in get_sortable_columns() for the specific screen. ie: class-wp-plugins-list-table.php Line 263 shown below. | |
The only way to modify that value is to edit core. I believe we should filter the returned array. That will | |
allow developers to specify whether or not their custom columns are sortable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Usage: | |
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL | |
if ( !$frag->output() ) { // NOTE, testing for a return of false | |
functions_that_do_stuff_live(); | |
these_should_echo(); | |
// IMPORTANT | |
$frag->store(); | |
// YOU CANNOT FORGET THIS. If you do, the site will break. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_prevent_admin_access', 'sfwd_check_admin_access' ); | |
function sfwd_check_admin_access( $redirect_to ) { | |
$user = wp_get_current_user(); | |
$allowed_roles = array ( 'administrator', 'group_leader' ); | |
if( is_array( $user->roles ) && in_array( $allowed_roles[0] , $user->roles ) || in_array( $allowed_roles[1] , $user->roles ) ) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
mongoose.connect('mongodb://localhost/test'); | |
var Cat = mongoose.model('Cat', { name: String }); | |
var kitty = new Cat({ name: 'Zildjian' }); | |
kitty.save(function (err) { | |
if (err) | |
console.log('meow'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* Module dependencies. | |
*/ | |
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema; | |
/** | |
* Article Schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a new Comment | |
*/ | |
exports.create = function(req, res) { | |
var comment = new Comment(req.body); | |
comment.poll = req.poll._id; | |
// if user |