Skip to content

Instantly share code, notes, and snippets.

View cameronjonesweb's full-sized avatar
👨‍👦

Cameron Jones cameronjonesweb

👨‍👦
View GitHub Profile
@cameronjonesweb
cameronjonesweb / wc-account-login.php
Last active August 3, 2018 03:45
Update WooCommerce sites to use the account page to login rather than wp-login.php
<?php
add_filter( 'login_url', 'cameronjonesweb_use_woocommerce_login_page' );
/**
* If WooCommerce is active use the account page for logging in
* @param string $login_url The URL for login.
* @param string $redirect The URL to redirect back to upon successful login.
* @param bool $force_reauth
* @return string
@cameronjonesweb
cameronjonesweb / edd-account-login.php
Created August 8, 2018 03:11
Update Easy Digital Downloads sites to use an account page to login rather than wp-login.php
<?php
add_filter( 'edd_settings_general', 'cameronjonesweb_edd_login_page' );
add_filter( 'login_url', 'cameronjonesweb_use_edd_login_page', 10, 3 );
/**
* Adds an additional page to the EDD pages settings
* Make sure the [edd_profile_editor] or [edd_login] shortcode is on this page.
*
* @param array $settings The array of settings.
<?php
add_action( 'pricing_tables_for_edd_footer_end', 'cameronjonesweb_free_downloads_link_to_modal', 9 );
/**
* Changes the pricing tables link to use the modal if it's a free download
*
* @param array $args User defined data for the pricing table.
*/
function cameronjonesweb_free_downloads_link_to_modal( $args ) {
if ( class_exists( 'EDD_Free_Downloads' ) ) {
@cameronjonesweb
cameronjonesweb / hosts
Last active September 3, 2018 00:13
Spotify ad block
# Spotify ad block
0.0.0.0 adclick.g.doublecklick.net
0.0.0.0 adeventtracker.spotify.com
0.0.0.0 ads-fa.spotify.com
0.0.0.0 analytics.spotify.com
0.0.0.0 audio2.spotify.com
0.0.0.0 b.scorecardresearch.com
0.0.0.0 bounceexchange.com
0.0.0.0 bs.serving-sys.com
0.0.0.0 content.bitsontherun.com
@cameronjonesweb
cameronjonesweb / admin-menu-customizer-link.php
Last active September 28, 2018 13:23
Replaces a settings subpage link with a link to the customizer or external URL
@cameronjonesweb
cameronjonesweb / yoast-webmaster-tools-verification.php
Created October 1, 2018 03:52
Adds the Yoast SEO webmaster tools (and other sites) verification codes to all pages including the login page. This is helpful when running a membership site or similar that requires users being logged in to view the site.
<?php
add_action( 'init', 'cameronjonesweb_yoast_front_page_head' );
function cameronjonesweb_yoast_front_page_head() {
if ( class_exists( 'WPSEO_Frontend' ) ) {
add_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), 'webmaster_tools_authentication' ), 90 );
add_action( 'login_head', array( WPSEO_Frontend::get_instance(), 'webmaster_tools_authentication' ), 90 );
}
}
@cameronjonesweb
cameronjonesweb / remove-current-page-parent.php
Created October 24, 2018 22:43
Removes the `current_page_parent` class from the blog page link when not viewing a blog related page
<?php
/**
* Removes the `current_page_parent` class from the blog page link when not viewing a blog related page
*
* @param array $classes The CSS classes that are applied to the menu item's `<li>` element.
* @param WP_Post $item The current menu item.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
function cameronjonesweb_remove_current_page_parent( $classes, $item, $args, $depth ) {
@cameronjonesweb
cameronjonesweb / class-att-example.php
Created November 14, 2018 01:56
Generate a class attribute from an array of classes and sanitises the classes
<?php
// Example.
$myclasses = [ 'my-class', 'some-other-class', '<script>console.log(hi);</script>' ];
printf(
'<div %1$s>%2$s</div>',
cameronjonesweb_generate_class_attribute( $myclasses ),
'My content'
);
@cameronjonesweb
cameronjonesweb / jetpack-cookie-widget-without-widget-areas.php
Last active November 18, 2018 13:29
Display Jetpack's cookie notice on themes without a widget area
@cameronjonesweb
cameronjonesweb / fix-vide-js-safari.js
Created November 30, 2018 06:18
Fixes Vide.js videos not autoplaying on Safari
/**
* @link https://github.com/vodkabears/Vide/issues/206
*/
function cameronjoneswebAutoPlayVideo( video ) {
if ( video.readyState === 4 ) {
video.play();
} else {
setTimeout( cameronjoneswebAutoPlayVideo, 100, video );
}
}