Skip to content

Instantly share code, notes, and snippets.

@groucho75
groucho75 / alo_easymail_dialog.php
Created May 29, 2014 07:17
Prompt ALO EasyMail in a dialog: put this php into /wp-content/mu-plugins
<?php
/*
// -------------------------------------------------------------------------------
// EXTRA: add the "open-easymail-popup" class to have a link that opens newsletter dialog
// -------------------------------------------------------------------------------
<a href="" class="open-easymail-popup">Newsletter</a>
*/
@groucho75
groucho75 / qtranslate_forks.php
Last active August 29, 2015 14:06
Integrate zTranslate, qTranslate Plus and qTranslate-X in ALO EasyMail - put this file in /wp-content/mu-plugins - report test here: http://wordpress.org/support/topic/qtranslate-versus-ztranslate
<?php
/**********************************************************************
* zTranslate integration
**********************************************************************/
function alo_em_ztrans_set_plugin( $multilang_plugin ){
if ( function_exists('ztrans_init') )
@groucho75
groucho75 / sanitize_whitelist
Last active August 29, 2015 14:06
GUMP example: sanitize whitelist
#!/usr/bin/php -q
<?php
require "../gump.class.php";
$validator = new GUMP();
$_POST = array(
'first_name' => 'Joe',
'last_name' => 'Black',
@groucho75
groucho75 / wp-cli-setup.sh
Last active August 29, 2015 14:17
Create and setup a new WP blog using interactive wp-cli script
#!/bin/bash
# Check wp-cli installed
type wp >/dev/null 2>&1 || { echo >&2 "This script requires wp-cli but it's not installed. Aborting."; exit 1; }
printf "\e[32mLet's go installing WP...\n\e[0m"
printf "\nTo install in a subfolder, write the folder name.\n"
echo "Otherwise leave empty to install in root:"
@groucho75
groucho75 / gist:2bc76fa13a0961e786c9
Last active August 29, 2015 14:21
WP: remove custom post type slug from post url and make unique post slugs among post types
/**
* Register your custom post type: write all the settings you like in $args.
*
* Note the 'slug' set to '/' to remove custom post type slug from url e.g.
* "/post-slug" instead of default "/custom-type-slug/post-slug"
*/
public function register_my_custom_type() {
$args = array(
/* ... */
<?php
/*
* Plugin name: Test Rewrite Plugin
* Source: https://jeremyfelt.com/2015/07/17/flushing-rewrite-rules-in-wordpress-multisite-for-fun-and-profit/
* */
add_action( 'admin_bar_menu', 'toolbar_link_to_mypage', 999 );
function toolbar_link_to_mypage( $wp_admin_bar ) {
@groucho75
groucho75 / custom_avatar_tooltip.php
Last active December 10, 2015 22:29
Avatar Tooltip plugin customization: How to show only user bio and social links. Put this file in /wp-content/mu-plugins folder
<?php
/**
* Customization for Avatar Tooltip plugin, for WordPress
* How to show only user bio and social links. Put this file in /wp-content/mu-plugins folder
*
* More info and screenshot:
* http://www.eventualo.net/blog/2013/01/avatar-tooltip-plugin-how-to-show-only-user-bio-and-social-links/
*
* Avatar Tooltip plugin:
* http://wordpress.org/extend/plugins/avatar-tooltip/
@groucho75
groucho75 / maintenance.php
Last active December 11, 2015 20:38
Quick maintenance mode in WordPress. Only admin can browse the blog, other people get a maintenance message. Put this php file in /mu-plugins.php
<?php
/**
* Quick maintenance mode in WordPress, using a bit of custom css and html
*
* Only admin can browse the blog, other people get a maintenance message
*
* Put this file in /wp-content/mu-plugins folder
*/
function alo_maintenance_mode() {
@groucho75
groucho75 / db_escape.php
Last active December 17, 2015 00:29
Minimal security for Database Queries and Results: MySQLi Prepared Statement & XSS Mitigation functions. Based on: https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet
<?php
/**
* DB Configuration
*/
$Host ='localhost';
$Username = 'root';
$Password = 'root';
$DatabaseName = 'test';
@groucho75
groucho75 / alo-cf7-integration.php
Last active June 11, 2016 01:17
ALO-CF7 Integration - Updated
function my_easymail_add_subscriber ( $cf7 ) {
$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();
$fields['email'] = $data["your-email"];
$fields['name'] = $data["your-name"];
if ( function_exists ('alo_em_add_subscriber') && is_email( $fields['email'] ) )
{
alo_em_add_subscriber( $fields, 1, alo_em_get_language(true) );