Skip to content

Instantly share code, notes, and snippets.

View joshuacharleslake's full-sized avatar

Josh Lake joshuacharleslake

View GitHub Profile
@joshuacharleslake
joshuacharleslake / wordpress-dropdown.css
Created July 29, 2015 09:32
Wordpress Dropdown Menu CSS
.menu-header-menu-container li,
div.menu li {
float: left;
position: relative;
}
.menu-header-menu-container ul ul {
display: none;
position: absolute;
top: 38px;
@joshuacharleslake
joshuacharleslake / wordpress-create-user.php
Created July 29, 2015 10:53
Create wordpress user through functions.php
function admin_account(){
$user = 'AccountID';
$pass = 'AccountPassword';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','admin_account');
@joshuacharleslake
joshuacharleslake / wordpress-disqus-shortcode.php
Last active November 16, 2020 05:08
Add Shortcode for disqus embed.
function disqus_embed($disqus_shortname) {
global $post;
wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
echo '<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = "'.$disqus_shortname.'";
var disqus_title = "'.$post->post_title.'";
var disqus_url = "'.get_permalink($post->ID).'";
var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
</script>';
@joshuacharleslake
joshuacharleslake / wordpress-remove-action-wp-head
Created July 31, 2015 09:45
remove actions wordpress for wp_head
remove_action( 'wp_head', 'feed_links_extra', 3 ); // This is the main code that removes unwanted RSS Feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Removes Post and Comment Feeds
remove_action( 'wp_head', 'rsd_link' ); // Removes link to RSD + XML
remove_action( 'wp_head', 'wlwmanifest_link' ); // Removes the link to Windows manifest
remove_action( 'wp_head', 'index_rel_link' ); // Removes the index link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Remove relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' ); // Remove the XHTML generator link
<?php
$url = $_SERVER['REQUEST_URI'];
if(stristr($url,"/carpets")){
echo '<meta name="robots" content="NOINDEX,FOLLOW" />';
} ?>
@joshuacharleslake
joshuacharleslake / youtube-video-schema
Created August 3, 2015 11:47
Video Schema for YouTube videos.
<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">
<iframe class="video2" width="755" height="425" src="https://www.youtube.com/embed/uNDZTcmPfnU?showinfo=0"></iframe>
<meta itemprop="name" content="Welcome To Floor Factory">
<meta itemprop="thumbnailUrl" content="http://www.floor-factory.co.uk/wp-content/themes/floor_fact/images/thumbnail.png">
<meta itemprop="description" content="A short video displaying the Floor Factory Derby branch, with a rundown of facilities and range of products provided.">
<meta itemprop="uploadDate" content="2014-05-09">
<meta itemprop="duration" content="T0M44S">
</div>
@joshuacharleslake
joshuacharleslake / time-delay-pop-up-box
Created August 3, 2015 16:19
Pop up box which will display after a time limit.
<div id="popupbox">
<a id="closebox" onclick="document.getElementById('popupoffer').style.display = 'none';">&times;</a>
</div>
<script type="text/javascript">
function show() {
document.getElementById("popupbox").style.display = "block";
}
$(function() {
@joshuacharleslake
joshuacharleslake / google-map-api
Last active August 29, 2015 14:26
Custom google map that displays location pin and coverage radius area.
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?sensor=false">
</script>
<div class="mapcontainer"><div id="map-canvas"></div></div>
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(52.074530, 1.141600);
var mapOptions = {
@joshuacharleslake
joshuacharleslake / flash-animation.css
Created August 9, 2015 01:18
Flash CSS Animation
<span class="flash">This Will Flash</span>
<style>
.flash {
-webkit-animation-name: flash;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-name: flash;
-moz-animation-duration: 1s;
@joshuacharleslake
joshuacharleslake / google-analytics-click-tracking-event
Created August 11, 2015 10:22
Click tracking code for universal analytics
<script type="text/javascript">
$(document).ready(function(e) {
e(".phone").on("click", function() {
ga("send", "event", "link", "click", "Phone Number")
}
)
}
);
</script>