Skip to content

Instantly share code, notes, and snippets.

View alanef's full-sized avatar

Alan Fuller alanef

View GitHub Profile
@alanef
alanef / bodyid.php
Last active December 4, 2018 18:04
body id function for genesis
<?php
/**
* Plugin Name: Add IDs to body tag for Genesis
* Plugin URI: https://fullworks.net/products/custom-plugin-development/
* Description: Add IDs to body tag
* Version: 1.0.0
* Author: Alan Fuller
* Author URI: https://fullworks.net/products/custom-plugin-development/
* License: GPL-2.0+
*/
@alanef
alanef / getlink.html
Created January 17, 2019 19:43
Html to get latest post link
@alanef
alanef / functions.php
Last active January 21, 2019 10:42
gform spam filter whitelist
add_filter( 'gform_entry_is_spam', funtion($is_spam, $form, $entry) {
if ( in_whitelist() ) { // in white list is your own rules
return false;
}
return $is_spam;
}, 10, // might need to play with priority if using Akismet integration so it checks after Akismet
3 );
@alanef
alanef / functions.php
Last active January 23, 2019 09:32
Show CPT under CPT in admin
add_action( 'init', function () {
register_post_type( 'cpttop', array(
'labels' => array(
'name' => 'Top CPT',
'singular_name' => 'Top CPT',
),
'show_ui' => true
) );
} );
add_action( 'init', function () {
@alanef
alanef / functions.php
Created January 23, 2019 09:53
Change menu location and title of registered post type menu
add_filter( 'register_post_type_args', function ( $args, $post_type ) {
if ( $post_type == "sub" ) {
$args['show_in_menu'] = 'edit.php?post_type=top';
$args['labels']['all_items'] = __( 'All Sub Items', 'my-text-domain' );
}
return $args;
}, 11, 2 );
@alanef
alanef / functions.php
Created February 14, 2019 20:43
Disable specific author page
add_action( 'template_redirect', function() {
if ( is_author('nickname') ) { // change either nickname or user id see https://codex.wordpress.org/Function_Reference/is_author
status_header( 404 );
get_template_part( 404 );
exit();
}
});
@alanef
alanef / readme.md
Last active December 17, 2019 20:46

To create an admin user without database access you can use this code.

to use

create a file containing the code e.g. tempadmin.php

change the values of username, password and email

upload to wp-content/mu-plugins directory

find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r
@alanef
alanef / example.php
Last active April 3, 2019 13:04
Example api function call using wp functions
<?php
$result = my_api_func( 'https:api....', array( 'arg1' => 'value1' ), true );
if ( is_wp_error( $result ) ) {
// error
}
/**
* @param $url
* @param array $args
* @param bool $json_decode
@alanef
alanef / customcode.php
Last active April 16, 2019 10:18
Example custom code plugin to change header sizes set by theme
<?php
/**
*
* Plugin Name: Custom Code
* Plugin URI: https://fullworks.net/products/custom-plugin-development/
* Description: Custom Code
* Version: 0.0.0
* Author: Fullworks
* Author URI: http://fullworks.net/
* License: GPL-3.0+