Skip to content

Instantly share code, notes, and snippets.

xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
percentComplete = (percentComplete.toFixed(2) * 100);
// add a progress bar container
if ( $('#upload-progress',container).length == 0 ) {
$(container).append('<div id="upload-progress" style="background: rgba(255, 186, 186, 0.32); width: 0; overflow: hidden; padding: 4px;"></div>');
}
@elhardoum
elhardoum / WordPress Transients - Helper Class.php
Created August 28, 2016 14:19
WordPress Transients - Helper Class - for handling WordPress Transients and caching data and keeping things simple as they should
<?php
/**
* WordPress Transients - Helper Class
*
* Makes it easier to store transients and call them and all in like 4 lines of code
* Helps you save large amounts of data (arrays) without the confusing proccess of
* chunking data into batches, and joining later upon getting all the data and also
* deleting all of these batches correctly. This class does it all for you.
*
<?php
/**
* Plugin Name: Restrict mail TLD registration
* Plugin URI: http://samelh.com
* Description: Allow/disallow user registration for email TLD
* Author: Samuel Elh
* Author URI: http://samelh.com
* Version: 0.1
*/
<?php
/**
* Plugin Name: No Spam Registration with JavaScript
* Plugin URI: http://blog.samelh.com
* Description: Prevents spam registration on your WordPress blog/website by adding a necessary form field with JavaScript on document load
* Author: Samuel Elh
* Author URI: http://samelh.com
* Version: 0.1
*/
<?php
add_action('admin_init', function() {
// Specify here the plugin name and that's all
$requested_name = 'AJAX File Upload';
function se_plugin_has_update( $name ) {
if ( ! function_exists( 'get_plugin_updates' ) ) {
require_once ABSPATH . 'wp-admin/includes/update.php';
<?php
function se_bbpm_add_spam_check() {
/**
* add spam check for users with bbp_spectator and bbp_participant roles
* Add more roles in the $targetRoles line or replace existing ones to match
* your targeted users
*/
<?php
add_action('bbpm_conversation_form_additional_fields', function() {
/**
* Follows is just an example on how to implement a simple captcha,
* You can set the answer in a cookie or database option and fetch
* it with a unique key, or store it somewhere else, use honeypot and
* spam hidden traps, reCaptcha, or simply a captcha image..
*/
<?php
function se_bbpm_add_spam_check() {
/**
* add spam check for users with bbp_spectator and bbp_participant roles
* Add more roles in the $targetRoles line or replace existing ones to match
* your targeted users
*/
<?php
/*
Plugin Name: Users Table Last Seen
Plugin URI: http://samelh.com
Description: updates users last seen status each time they browse the front-end and adds last seen to users table with user last seen time difference
Author: Samuel Elh
Version: 0.1
Author URI: http://samelh.com
*/
<?php
/*
Plugin Name: WordPress Hashtags
Plugin URI:
Description: WordPress Hashtags allows you to automatically fetch your blog content and detect hashtags and set them as links
Author: Samuel Elh
Version: 0.3.1
Author URI: http://samelh.com
*/