Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
robertuniqid / wpep-course-example.php
Created November 27, 2018 21:57
WordPress Clear oEmbed Cache Automatically on Post Save
<?php
add_action( 'save_post', function( $post_id ) {
if( get_post_type( $post_id ) != WPEP_POST_TYPE_COURSE )
return;
global $wpdb;
$wpdb->query( 'DELETE FROM `' . $wpdb->postmeta . '` WHERE `meta_key` LIKE "_oembed%" AND post_id = ' . $post_id );
});
@robertuniqid
robertuniqid / style.css
Created November 16, 2018 15:59
WPEP - Disable Index Page Transitions
.wpep-wrapper>.wpep-container .course-grid-container .wpep-course-grid-items-container>div.wpep-visible,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-ebook-grid-items-container>div.wpep-visible,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-list-item-grid-items-container>div.wpep-visible,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-offer-grid-items-container>div.wpep-visible,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-video-grid-items-container>div.wpep-visible,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-course-grid-items-container>div.wpep-hidden,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-ebook-grid-items-container>div.wpep-hidden,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-list-item-grid-items-container>div.wpep-hidden,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-offer-grid-items-container>div.wpep-hidden,
.wpep-wrapper>.wpep-container .course-grid-container .wpep-video-grid-items-contai
@robertuniqid
robertuniqid / sample-text.txt
Created November 1, 2018 17:59
5 Languages Sample Text
iPhone XR: The reviews are in
Reviewers around the world have put iPhone XR through its paces and are sharing their impressions of the newest member of the iPhone family. That includes everything from its 6.1-inch Liquid Retina display, advanced camera system that creates dramatic portraits using a single camera lens, all-day battery life and six beautiful finishes; white, black, blue, yellow, coral and (PRODUCT)RED.
Here are some of the reviewers’ reactions:
Digital Trends
“The colors are stunning, battery life is great, Face ID is still industry-leading technology, iOS gestures are intuitive, the camera is superb, and performance is fantastic. This is the iPhone to buy.”
Daring Fireball
@robertuniqid
robertuniqid / wpep-content-library-integration.php
Created October 31, 2018 21:56
WPEP_Content_Library_Integration
<?php
class WPEPContentLibraryIntegrationExample extends WPEP_Content_Library_Integration {
public $service_name = 'Integration Name';
public $meta_box_active = true; // If you want to integrate with the Content Library without the Metabox, simply set this to false.
public $meta_box_title = 'Integration Name';
public $default_purchase_cta = 'Upgrade Membership Plan';
@robertuniqid
robertuniqid / example.php
Created October 26, 2018 18:55
Sales Engine Access Rules PHP Example
<?php
// You'll want to get an User Access Rules Instance list this :
$user_access_rule = new WPEPAddOnSalesEngine\Entity\UserAccess( $user_id );
// Case 1 : Give Access to One-Time Purchases ( not Memberships )
// $post_id = Post Type, if it's a Membership, you can set an Expiration date also.
$user_access_rule->get_post_access_rules( $post_id )->give_access(); // when giving access it will save automatically.
@robertuniqid
robertuniqid / query.sql
Last active October 25, 2018 22:09
I would love to be able to take the first 8(?) words of the body and copy them over to the Title
UPDATE `wp_posts` SET `post_title` = SUBSTRING_INDEX(PREG_REPLACE('#<[^>]+>#',' ',`post_content`), ' ', 8)
WHERE DATE(`post_date`) > '2000-11-11' AND DATE(`post_date`) < '2007-11-11'
@robertuniqid
robertuniqid / custom-link.php
Created September 20, 2018 11:56
Redirect To Homepage / Custom Link After Password Reset
@robertuniqid
robertuniqid / example.php
Created September 11, 2018 18:32
WPEP Order Index Page by Publish Date
<?php
// Please ensure that WPEP -> Settings -> Index Page -> Grid Options -> Enforce Ordering Option is Disabled.
add_filter( 'wpep_primary_content_list_args', function($args) {
$args = [
'order' => 'DESC',
'orderby' => 'date',
];
@robertuniqid
robertuniqid / example.php
Last active August 12, 2018 14:58
Example on how the Gutenberg the_content filter for wpautop could've prevented breaking plugins that removed wpautop.
<?php
// How it is :
function gutenberg_wpautop( $content ) {
if ( gutenberg_content_has_blocks( $content ) ) {
return $content;
}
return wpautop( $content );
@robertuniqid
robertuniqid / example.php
Created July 31, 2018 16:56
Send an Email Notification when an Assessment has a Status Change.
<?php
add_action( 'wpep_user_set_assessment_data', function( $key, $value, $post_id, $question_id, $question_answer_id, $user_id ) {
if( $key != WPEP_USER_ASSESSMENT_STATUS )
return;
$student_name = wpep_content_user_profile_format_name( $user_id );
$status_label = wpep_get_setting_translated( 'assessment-status-label-' . $value );
$admin_url = wpep_admin_url_statistics( [
'tab' => 'assessments',