This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); | |
function theme_enqueue_styles() { | |
// Grab CSS and JS urls. | |
$theme_styles = "/css/child-theme.css"; | |
$theme_scripts = "/js/child-theme.js"; | |
// Use filetime() as the version number - so each time you rebuild the CSS or JS, you get a new version number to bust the browser cache | |
// Note: we use the local path with filetime(), not a url | |
$css_vers = filemtime( get_stylesheet_directory() . $theme_styles ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Disable updates to a plugin - solution found on https://wordpress.stackexchange.com/questions/397326/how-do-i-disable-an-update-for-a-specific-plugin | |
// | |
function AS_disable_plugin_updates( $value ) { | |
//create an array of plugins you want to exclude from updates ( string composed by folder/main_file.php) | |
$pluginsNotUpdatable = [ | |
'plugin1/plugin.php', | |
'plugin2/plugin2.php' | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'gform_phone_formats', 'nz_phone_format' ); | |
// NZ phone format - 8, 9 or 10 digits long | |
function anz_phone_format( $phone_formats ) { | |
$phone_formats['nz'] = array( | |
'label' => 'New Zealand', | |
'mask' => '99 9999 99?99', | |
'regex' => '/^(?:(?:\+?64[2-9]|0[2-9])\d{6,7}|(?:\+?642\d{1}|02\d{1})\d{6,8}|(?:(?:\+?64800|0800)|(?:\+?64508|0508))\d{6,8})$/', | |
'instruction' => 'New Zealand phone numbers.', | |
); | |
return $phone_formats; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Wordpress - Support for iframes being called for a specific page. Add this to functions.php | |
// In this case, the URL $allowed_url will be allowed to pull the contents of the 'my-embed' page | |
// | |
add_action( 'send_headers', 'add_header_xframe', 99 ); | |
function add_header_xframe() { | |
if ( is_page('my-embed') ) { | |
$allowed_url = 'http://test.local'; | |
header( 'Content-Security-Policy: frame-ancestors '.$allowed_url ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Hook the Ninja forms before submitting | |
// | |
add_filter( 'ninja_forms_submit_data', 'my_ninja_forms_submit_data' ); | |
// | |
// This function hooks the Ninja submission step | |
// Thanks to https://stackoverflow.com/questions/61440656/ninja-forms-server-side-validation-not-working | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Shop Order Form - Allow shop products to be added to the GF on the fly. | |
// | |
// Products are defined in an ACF CPT. These products may be purchased via a Gravity Form. | |
// The base form should have all fields required, except without products. | |
// The product fields will be added immediately above the Shipping field. | |
// | |
add_filter( 'gform_pre_render_7', 'populate_shop_products' ); | |
add_filter( 'gform_pre_validation_7', 'populate_shop_products' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', 'ingeni_add_posts_menuorder' ); | |
function ingeni_add_posts_menuorder() { | |
add_post_type_support( 'post, page', 'page-attributes' ); | |
add_post_type_support( 'page', 'excerpt' ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Take the URL of a local file in the WP Uploads folder and check that it does actually exist | |
function uploaded_file_exists( $url ) { | |
$local_exists = false; | |
if ( $url ) { | |
$uploads = wp_upload_dir(); | |
$local_path = str_replace( $uploads['baseurl'], $uploads['basedir'], $url ); | |
$local_exists = file_exists($local_path); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Custom WP menu container - thanks to https://gist.github.com/nikolov-tmw/8698598 | |
// | |
// Add a custom container to your | |
// | |
add_action( 'admin_head-nav-menus.php', 'custom_register_menu_metabox' ); | |
function custom_register_menu_metabox() { | |
$custom_param = array( 0 => 'mega_col' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Add a Custom Yoast Variable | |
// | |
add_action('wpseo_register_extra_replacements', 'add_yoast_supercharge_variables'); | |
function add_yoast_supercharge_variables() { | |
if (function_exists ('wpseo_register_var_replacement')){ | |
wpseo_register_var_replacement('%%BRAND%%', 'supercharge_yoast_brand', 'advanced', 'Supercharge Brand' ); | |
} | |
} |
NewerOlder