Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
robertuniqid / code.php
Created April 20, 2020 22:38
eLearnCommerce - Abstract WPEP_Content_Library_Integration
<?php
require_once( WPEP_BASE_PATH . "/lib/integrations/Content_Library/Administration.php" );
abstract class WPEP_Content_Library_Integration {
public $service_name = '';
public $control_access_based_display = [];
public $meta_box_active = false;
@robertuniqid
robertuniqid / example.php
Created April 14, 2020 20:03
WordPress - Example remove action registered with $this object reference.
<?php
class Foo {
public function __construct() {
add_action( 'init', [ $this, '_bar' ] );
}
public function _bar() {
exit( "Request Blocked, action was not removed" );
@robertuniqid
robertuniqid / sample.php
Created April 6, 2020 17:56
PHP : empty vs == vs ===
<?php
$t = '';
$before = microtime(true);
for ($i=0 ; $i<100000 ; $i++) {
$dummy = empty( $t );
}
@robertuniqid
robertuniqid / code.php
Created March 17, 2020 14:09
you.growlearnteach.com - hide all restrict_manage_posts actions except 1.
<?php
add_action( 'restrict_manage_posts', function() {
remove_all_actions( 'restrict_manage_posts' );
add_action( 'restrict_manage_posts', [ wpep_content_taxonomy(), '_content_type_filtering' ] );
}, -1 );
@robertuniqid
robertuniqid / security.php
Created February 17, 2020 09:12
WPEP \ eLearnCommerce - VCD Malware Pattern. - Instead of building a full-blown security scanner, in eLearnCommerce the plugin checks for patterns, the only compromised sites we encountered that generated a lot of issues where with the "VCD" pattern, and we'll just for it. This script is pretty simple.
<?php
namespace WPEP\PlatformHealth;
class Security {
public function is_compromised() {
$map = $this->get_map();
foreach( $map as $current_verification )
@robertuniqid
robertuniqid / file.php
Last active January 23, 2020 00:44
Wishlist Integration - Changes Over time.
<?php
/** 13 Sep 2016
* @param $user_id
* @param $post_id
* @param string $post_type
* @return bool
*/
function member_can_access($user_id, $post_id, $post_type = 'courses') {
if( !function_exists( 'wlmapi_get_member_levels' ) )
@robertuniqid
robertuniqid / style.css
Created January 15, 2020 12:12
Hide Jetpack Smiley Face CSS
/** Not elegant, but does the trick. **/
#wpstats {
opacity: 0;
float: left;
width: 0.1px;
height: 0.1px;
}
<?php
add_action( "init", function() {
if( get_option( "_temp_did_run_123456", false ) !== false )
return;
$product_id = 1;
$post_types = array_keys( wpep_content_type()->contentTypes );
@robertuniqid
robertuniqid / example.php
Created October 21, 2019 12:43
Example Affiliate WP External Tracking.
<?php
if( isset( $_GET['ref'] ) ) {
add_action( "wp_footer", function() {
echo '<iframe src="your-shop-domain-goes-here/?ec-ref=true&ref=' . intval( $_GET['ref'] ) . '" style="width:1px !important;height:1px !important;opacity:0 !important;"></iframe>';
});
}
@robertuniqid
robertuniqid / example.php
Created October 21, 2019 12:38
FilterHacks Trait
<?php
require_once( "trait.php" );
class Example {
use FilterHacks;
public function foo() {
$this->_filter_hack_deque( 'bar' );