Skip to content

Instantly share code, notes, and snippets.

View theukedge's full-sized avatar

Dave Clements theukedge

View GitHub Profile
<?php
// LOGOUT LINK IN MENU
function diww_menu_logout_link( $nav, $args ) {
$logoutlink = '<li><a href="'.wp_logout_url().'">Logout</a></li>';
if( $args->theme_location == 'primary' ) {
return $nav.$logoutlink ;
} else {
return $nav;
<?php function add_conversion_tracking_code($button, $form) {
$dom = new DOMDocument();
$dom->loadHTML($button);
$input = $dom->getElementsByTagName('input')->item(0);
if ($input->hasAttribute('onclick')) {
$input->setAttribute("onclick","ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Mailing List Sign Up', eventLabel: 'Sidebar'});".$input->getAttribute("onclick"));
} else {
$input->setAttribute("onclick","ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Mailing List Sign Up', eventLabel: 'Sidebar'});");
}
return $dom->saveHtml();
# redirect http to https
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80; ## listen for ipv6
server_name dave.pe www.dave.pe;
return 301 https://dave.pe$request_uri;
}
<?php
// SEND ACCESS LEVEL TO GRAVITY FORMS
function get_access_level(){
global $user_ID;
$plan_id = rcp_get_subscription_id( $user_ID );
$access_level = rcp_get_subscription_access_level( $plan_id );
return $access_level;
}
<?php
// Don't email webmaster for comment moderation
function pref_dont_email_webmaster( $emails, $comment_id ) {
$webmaster_email = get_option('admin_email');
if ( $emails[0] == $webmaster_email )
unset($emails[0]);
return (array) $emails;
}
<?php function diww_add_post_content($content) {
if (is_single()) {
$content .= '<p><div id="newsletter-box">Please subscribe to <a title="Do More With WordPress" href="http://www.doitwithwp.com/go/newsletter">our newsletter</a></div></p>';
}
return $content;
}
add_filter ('the_content', 'diww_add_post_content', 0);
<?php
$show_after_p = 2;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
$contents = explode("</p>", $content);
$p_count = 1;
foreach($contents as $content)
{
echo $content;
<?php wp_footer(); ?>
<?php if (!$user_ID) : ?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9669661-12']);
_gaq.push(['_trackPageview']);
jQuery(document).ready(function($){
$(".gform_wrapper .disable input").attr('disabled','disabled');
});
<?php
// DISABLE CERTAIN FIELDS
function enqueue_gf_disable() {
wp_enqueue_script( 'gf-disable', plugins_url( '/scripts/gravity-forms-disable.js', dirname(__FILE__) ) );
}
add_action( 'wp_enqueue_scripts', 'enqueue_gf_disable' );