Skip to content

Instantly share code, notes, and snippets.

<?php
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'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
<?php
add_action('wp', function() {
if( '1' == get_query_var('se_random_post') ) {
$count = count( get_posts() );
if( (int) $count <= 0 )
return; // no posts
<?php
add_action('init', function() {
// rewriting site.ext/index.php?se_random_post=1 to site.ext/random/
add_rewrite_rule(
'random/?$',
'index.php?se_random_post=1',
'top'
);
<?php
add_action('wp', function() {
if( get_query_var('se_random_post') ) {
$post = get_posts(array('posts_per_page' => 1, 'orderby' => 'rand'));
$post = array_shift($post);
if( $post && $post->ID ) {
wp_safe_redirect( get_permalink( $post->ID ) );
exit;
}
<?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
*/
<?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
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
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';