Skip to content

Instantly share code, notes, and snippets.

View lkoudal's full-sized avatar

Lars Koudal lkoudal

View GitHub Profile
@lkoudal
lkoudal / private-debug-log.php
Created November 27, 2016 18:02 — forked from webaware/private-debug-log.php
Enable WordPress debug log to a private folder not accessible from the web. See http://wordpress.stackexchange.com/q/84132/24260 for details and motivations. NB: currently needs to be manually edited to specify the private folder path;
<?php
/*
Plugin Name: Private Debug Log
Description: Enable debug log to a private folder not accessible from the web
Version: 0.0.1
Author: WebAware
Author URI: http://www.webaware.com.au/
*/
/*
@lkoudal
lkoudal / CreateWordpressUser.php
Created November 24, 2016 23:45 — forked from jawinn/CreateWordpressUser.php
Create WordPress Admin User from PHP
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// ----------------------------------------------------
@lkoudal
lkoudal / test_wp_mail.php
Created July 31, 2016 06:47 — forked from strangerstudios/test_wp_mail.php
Help Debug wp_mail in WordPress
function test_wp_mail($args)
{
$debug = "<pre>" . var_export($args, true) . "</pre>";
wp_die($debug);
}
add_filter('wp_mail', 'test_wp_mail');
@lkoudal
lkoudal / wp-config.php
Created June 12, 2016 18:09
WordPress: Prevent WordPress sending any emails
<?php
// I did this simple hack on a private WordPress Multisite blog, to stop it
// sending me emails every time I created a new blog. It's definitely overkill
// to stop all emails, but unfortunately I couldn't find any hooks that let me
// be more specific! (I didn't need any of the other emails - but you shouldn't
// use this code if you do!)
// I put the code in wp-config.php. You could create a plugin instead, or
// putting it in your theme's functions.php might work (I haven't tested it).
@lkoudal
lkoudal / functions.php
Created June 5, 2016 19:31 — forked from yratof/functions.php
Visual Composer and Relevanssi showing shortcodes in search
<?php
// Issue with showing VC shortcodes in search results
// Strip out Visual Composer specific shortcodes
add_filter('relevanssi_pre_excerpt_content', 'rlv_trim_vc_shortcodes');
function rlv_trim_vc_shortcodes($content) {
$content = preg_replace('/\[\/?vc_.*?\]/', '', $content);
return $content;
}
@lkoudal
lkoudal / wc-hide-coupons-cart-checkout.php
Created March 14, 2016 00:46 — forked from maxrice/wc-hide-coupons-cart-checkout.php
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
@lkoudal
lkoudal / .gitignore
Created January 27, 2016 21:52 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
<?php
/*
This code shows pagination for WooCommerce shortcodes when it's embeded on single pages.
Include into functions.php. DO NOT include the first line <?php twice in function.php (line 33) otherwise this will break the code
*/
if ( ! is_admin() ) {
// ---------------------- FRONTPAGE -------------------
if ( defined('WC_VERSION') ) {
@lkoudal
lkoudal / mobileUA.php
Last active August 29, 2015 14:22 — forked from dcondrey/mobileUA.php
<?php
class Mobile_Detect {
protected $accept;
protected $userAgent;
protected $isMobile = false;
protected $isAndroid = null;
protected $isBlackberry = null;
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/"
>