Skip to content

Instantly share code, notes, and snippets.

View JudeRosario's full-sized avatar

Jude Rosario JudeRosario

View GitHub Profile
@JudeRosario
JudeRosario / jetpack.php
Last active June 18, 2018 13:13
Jetpack + Keyy
<?php
/*
Plugin Name: Keyy compat fix for Jetpack
*/
add_action('plugins_loaded', 'keyy_compat');
function keyy_compat() {
if ( is_multisite() && ! is_main_site() ) {
switch_to_blog( $this->get_main_blog_id() );
class PRELOAD_FULLPAGE_CACHE
{
function __construct() {
add_action( 'wp_insert_post', array( $this, 'preload_desktop' ), 900, 3 ); // let's fetch the post very late
add_action( 'wp_insert_post', array( $this, 'preload_mobile' ), 990, 3 ); // let's fetch mobile version even later
add_action( 'wp_insert_post', array( $this, 'preload_amp' ), 999, 3 ); // let's fetch AMP version at last; only works on posts
}
// verison to fetch: desktop
// user-agent: Chrome 62 on a macOS Sierra 10.12.6
<?php
class Staged_Sleep_Task extends Updraft_Task_1_0 {
public function initialise() {
$sleep_for = $this->get_random_time_intervals();
$this->update_option('sleep_for', $sleep_for);
}
public function run() {
$trie = new Trie();
$start = microtime(true);
for ( $i = 0 ; $i < 20000000 ; $i++ ) {
$sid = bin2hex(openssl_random_pseudo_bytes(8));
$collision = $trie->search($sid) ;
if ( is_null($collision) ) {
$trie->add($sid, 1);
} else {
echo "\n" ."Collision with previous Hash" ."\n" ;
}
<?php
$j = 0;
$start = microtime(true);
for ( $i = 0 ; $i < PHP_INT_MAX ; $i++ ) {
$j++;
}
echo $j . "\n" ;
$time_elapsed_secs = microtime(true) - $start;
19:27:39.793 TypeError: 'insertCell' called on an object that does not implement interface HTMLTableRowElement.
Stack trace:
e@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24986
dc@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24871
dc@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24894
dc@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24894
dc@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24894
dc/<@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24782
each@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:2879
dc@https://updraftplus.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:4:24738
add_action( 'wp_footer', function() {
if( 'membership_signup' == $_POST['action'] )
{
$membership_id = $_POST['membership_id'];
$membership = MS_Factory::load( 'MS_Model_Membership', intval( $membership_id ) );
$prefix = str_replace( ' ', '_', strtolower( $membership->name ) ) . '_';
$username = $prefix . rand( 1000 , 9999 );
?>
<script type="text/javascript">
@JudeRosario
JudeRosario / 1-instructions.txt
Created December 7, 2016 13:51 — forked from bappi-d-great/1-instructions.txt
Add custom field in M2 registration form (Basic) WPMU Membership2
### We are adding telephone number as custom field
1. Go to /wp-content/plugins/membership/app/view/templates/ and copy all 4 files.
2. Go to /wp-content/themes/YOUR_CURRENT_THEME/ and create a new folder called membership2, then paste all 4 files inside the new created membership2 folder
3. Open membership_registration_form.php and put the following: membership_registration_form.php
4. Now open the membership_account.php file and put the following: membership_account.php
5. Finally need to add some code: mu-plugin.php
## You can add those codes in your functions.php in the theme,
## if you think your theme won’t be changed. Otherwise mu-plugins is the best solution.
jQuery(document).ready(function($) {
var setText = function() {
$('.app_timetable:visible div.app_timetable_cell:nth(0)').contents().filter(function() {
return this.nodeType == 3;
})
.replaceWith("Morning") ;
$('.app_timetable:visible div.app_timetable_cell:nth(1)').contents().filter(function() {
add_shortcode('login-form', 'i332i_login_form_shortcode');
function i332i_login_form_shortcode( $attr ) {
if ( is_user_logged_in() )
return '';
/* Set up some defaults. */
$defaults = array(
'label_username' => 'Username',