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 | |
/** | |
* 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 | |
*/ |
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 | |
/** | |
* 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 | |
*/ |
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 | |
/** | |
* 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. | |
* |
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
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>'); | |
} |
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 | |
/* | |
* Smarty plugin | |
* ------------------------------------------------------------- | |
* Type: modifier | |
* Name: relative_date | |
* Version: 1.1 | |
* Date: November 28, 2008 | |
* Author: Chris Wheeler <[email protected]> |
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 | |
if ( defined('BM_CUSTOM_LOAD') && isset($BM_Loader) && method_exists($BM_Loader, "init") ) { | |
if ( true /* my custom preferences */ ) { | |
$BM_Loader->init(); | |
} | |
} |
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 | |
/** @link https://samelh.com/blog/2016/12/22/add-custom-fields-bbpress-profile/ **/ | |
// add field to bbP profile edit | |
add_action( "bbp_user_edit_after_contact", "se_add_city_field" ); | |
function se_add_city_field() { | |
// a random selection of cities | |
$cities = array( "Seoul", "Mexico City", "Amsterdam", "Mumbai", "Agadir", "Egypt" ); | |
// selected city, if any |
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 | |
/** | |
* @link https://github.com/bainternet/PHP-Hooks | |
*/ | |
function hooks() { | |
global $hooks; | |
if ( !isset($hooks) || !($hooks instanceof \Hooks) ) { | |
$hooks = new \Hooks; |
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 hashScrollFix = function() { | |
var hash = location.hash | |
, menu = $('.main-navi.fixed') // your fixed menu selector | |
, itm; | |
// I added menu.position().top >= 0 because I fade my menu to above viewport | |
// with a negative top position | |
if ( menu.is(':visible') && menu.position().top >= 0 ) { | |
itm = $(hash); |
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 | |
/** | |
* Get client IP | |
*/ | |
function whatismyip() { | |
if (isset($_SERVER['HTTP_CLIENT_IP'])) | |
$ipaddress = $_SERVER['HTTP_CLIENT_IP']; | |
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; |