Skip to content

Instantly share code, notes, and snippets.

@groucho75
groucho75 / nav-menu-exporter-importer.php
Created November 10, 2016 16:23 — forked from raynov/nav-menu-exporter-importer.php
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@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) );
@groucho75
groucho75 / merging_wp_queries.php
Last active March 1, 2023 09:43
Merging results of 2 WP_Query
<?php
/**
* Case: related news
*
* At first query for posts of same category, then, if it doesn't find enough posts, query for other posts and merge the 2 results.
*
* Put the following code inside a single template.
*
* @link Inspired by http://wordpress.stackexchange.com/questions/71576/combining-queries-with-different-arguments-per-post-type#answer-71582
<?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 / flush_rewites_on_multisite.php
Last active November 25, 2021 05:42
WP - How to Flush Rewrite Rules for all sites on Multisite
<?php
/**
* Flush permalink on EVERY site on a mulsitite, so you don't have to visit
* Permalink dashboard page of every single blog.
*
* How to use:
* - upload it in /wp-content/mu-plugins/
* - leave the file there for some days
* - then REMOVE the file!
*/
@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(
/* ... */
@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 / 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 / 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 / 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>
*/