Skip to content

Instantly share code, notes, and snippets.

<?php
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ( $current_url == 'http://example.com/example' ) {
// DO YOUR THING HERE, THEN REDIRECT
wp_redirect( 'http://example.com' ) );
exit;
}
?>
<?php
// Exit if accessed directly
if ( !defined('ABSPATH')) exit;
/**
* Pages Template
*
*
* @file page.php
$nationals = array(
'Afghan',
'Albanian',
'Algerian',
'American',
'Andorran',
'Angolan',
'Antiguans',
'Argentinean',
'Armenian',
@chrisdigital
chrisdigital / Frontend user profile in WordPress
Created May 6, 2013 13:27
Setting up a editable user profile in WordPress on the frontend.
//How to edit a user profile on the front end?
//http://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end
//Forcing nickname as display_name in custom edit profile template
//http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template
///////
<?php
@RalfAlbert
RalfAlbert / file_upload.php
Last active May 18, 2018 19:23
WordPress: Simple class to handle file uploads to the wp-content directory and creating an attachment post
<?php
class File_Upload
{
/**
* Index key from upload form
* @var string
*/
public $index_key = '';
/**
<?php
if ($_FILES['userfile']['size'] > 5 * 1024 * 1024) {
$error = 'File is too large.';
@unlink($_FILES['userfile']['tmp_name']) || $error .= $php_errormsg;
}
@QETHAN
QETHAN / navbar.css
Created April 27, 2013 02:57
Bootstrap_navbar_css
.navbar-fixed-top {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
}
.navbar-fixed-top .navbar-inner {
padding-left: 0;
padding-right: 0;
@jeremyboggs
jeremyboggs / convert_search_filters.php
Created April 23, 2013 13:48
Converts Omeka's advanced search output into acceptable input for findBy().
<?php
/**
* Converts the advanced search output into acceptable input for findBy().
*
* @see Omeka_Db_Table::findBy()
* @param array $query HTTP query string array
* @return array Array of findBy() parameters
*/
function neatlinetime_convert_search_filters($query) {
@tylerhall
tylerhall / index.php
Created April 21, 2013 20:51
Modified WordPress index.php to work with any domain name.
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
@shanebp
shanebp / gist:5391229
Created April 15, 2013 20:56
BuddyPress - add message button in members loop
function filter_message_button_link( $link ) {
$link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_get_member_user_id() ) );
return $link;
}
function display_private_message_button() {
if( bp_get_member_user_id() != bp_loggedin_user_id() ) {
bp_send_message_button();
add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 );