Skip to content

Instantly share code, notes, and snippets.

View danmeade's full-sized avatar

Dan Meade danmeade

View GitHub Profile
@yanknudtskov
yanknudtskov / .htaccess
Created December 4, 2018 07:56
Noindex PDF files in .htaccess
#Noindex PDF
<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex"
</Files>
#Noindex PDF
@yanknudtskov
yanknudtskov / functions.php
Created November 13, 2018 16:41
Create a WordPress Admin user through functions.php - Remember to remove the codesnippet after the user has been created.
<?php
add_action( 'init', function () {
$username = 'USER NAME HERE';
$password = 'PASSWORD HERE';
$email_address = 'EMAIL HERE';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
$user = new WP_User( $user_id );
@yanknudtskov
yanknudtskov / functions.php
Created August 26, 2018 16:36
Allow SVG upload in WordPress
<?php
/**
* Allow SVG Upload
*/
add_filter('upload_mimes', 'yanco_mime_types');
function yanco_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
@yanknudtskov
yanknudtskov / functions.php
Created May 2, 2018 11:37
How to remove decimal points for products in #woocommerce where they end on 0 (zero)
<?php
/*
* Trim zeros in price decimals
*/
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
@yanknudtskov
yanknudtskov / admin-column-user-registered-date.php
Created April 19, 2018 14:52
Add a column to the Users overview in WordPress Admin to display the registration date
<?php
/*
* Create a column. And maybe remove some of the default ones
* @param array $columns Array of all user table columns {column ID} => {column Name}
*/
add_filter( 'manage_users_columns', 'yanco_modify_user_table' );
function yanco_modify_user_table( $columns ) {
// unset( $columns['posts'] ); // maybe you would like to remove default columns
$columns['registration_date'] = 'Registreret'; // add new
@yanknudtskov
yanknudtskov / functions.php
Last active October 7, 2021 20:25
Remove Heading from the WordPress Editor #tinymce #removeheadings
<?php
/**
* Remove the h4 to h6 tag from the WordPress editor.
*
* @param array $settings The array of editor settings
* @return array The modified edit settings
*/
function remove_headings_from_editor( $settings ) {
// Default as example
// $settings['block_formats'] = 'Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre;';
@yanknudtskov
yanknudtskov / wc-remove-zoom-galleries.php
Created March 9, 2018 12:04
Remove Zoom from WooCommerce Galleries
<?php
/*
* Remove Zoom from WooCommerce Galleries
*/
add_action( 'after_setup_theme', 'yanco_after_setup_theme', 100 );
function yanco_after_setup_theme() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
@yanknudtskov
yanknudtskov / wp-reset-password-emails.php
Created February 5, 2018 05:36
WordPress Password Reset mails filter, because gmail sometimes removes the link, this fixes it. #passwordreset #wpmail
<?php
add_filter('retrieve_password_message', 'yanco_custom_password_reset', 99, 4);
function yanco_custom_password_reset($message, $key, $user_login, $user_data ) {
$message = __('Someone has requested a password reset for the following account:') . "<br><br>";
$message .= network_home_url( '/' ) . "<br><br>";
$message .= sprintf(__('%s'), $user_data->user_email) . "<br><br>";
$message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "<br><br>";
$message .= __('To reset your password use the link below:') . "<br><br>";
<html>
<head>
<title>API Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var accessToken = "<your agent's client access token>";
var baseUrl = "https://api.api.ai/v1/";
@yanknudtskov
yanknudtskov / gravityforms-auto-trigger-next-previous.js
Last active October 7, 2021 20:03
jQuery example to trigger next/previous buttons on GravityForms #gravity-forms
// This is the initial GravityForms binding, it will be lost upon a page change with next/previous
// Thus we make a bind on gform_page_loaded event also
if( jQuery('.custom-form').length > 0 ) {
jQuery('.gfield_radio input[type=radio]').bind("click", function() {
//console.log('Clicked: ' + jQuery( this ).closest('.gform_page').find('.gform_page_footer .gform_next_button.button') );
jQuery(this).closest('.gform_page').find('.gform_page_footer .gform_next_button.button').click();
});
}
jQuery(document).bind('gform_page_loaded', function(event, form_id, current_page){