Skip to content

Instantly share code, notes, and snippets.

View mikeott's full-sized avatar
😀
Greetings programs. See you on the grid.

Michael Ott mikeott

😀
Greetings programs. See you on the grid.
View GitHub Profile
@mikeott
mikeott / WordPress plugin Sanitise and Validate settinhgs fields.php
Created January 2, 2024 00:37
WordPress plugin Sanitise and Validate settinhgs fields
<?php
// In the main plugin file:
/* Register settings */
function my_cool_plugin_settings_init() {
register_setting (
'my_cool_plugin_settings',
'my_cool_plugin_settings',
'my_cool_plugin_settings_validate'
@mikeott
mikeott / WooCommerce Add something to my account page.php
Last active November 13, 2023 05:11
WooCommerce: Add something to my account page
add_action( 'woocommerce_account_content', 'action_woocommerce_account_content' );
function action_woocommerce_account_content( ) {
// Do something
};
@mikeott
mikeott / WordPress Enqueue jQuery.php
Created October 27, 2023 14:03
WordPress Enqueue jQuery
/* If jQuery is not enqueued, do it */
function enqueue_jquery() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'enqueue_jquery');
@mikeott
mikeott / Rocket Apps disable email reminders
Last active October 12, 2023 11:47
Rocket Apps: DIsable email reminders
<?php //Custom user profile checkbox:
/* Add custom user profile field */
function custom_user_profile_fields($user) {
?>
<h3>Custom User Fields</h3>
<table class="form-table">
<tr>
<th>
@mikeott
mikeott / Product names for use in Gravity Forms field.php
Last active October 11, 2023 07:20
Gravity Forms Product names for use in field
<?php /* Product names for use in Gravity Forms field */
function ra_all_product_names() {
$args = array(
'post_type' => 'product',
'orderby' => 'title',
'order' => 'asc',
'posts_per_page' => -1
);
$gchoice_count = 1;
$input_count = 1;
@mikeott
mikeott / gravity-forms-submenu-item.php
Last active September 25, 2023 01:48
Gravity Forms sub menu item
/* Add 'Entry Reports' to Gravity Forms 'Settings' form page */
add_filter( 'gform_form_settings_menu', 'gfer_form_settings_menu_item' );
function gfer_form_settings_menu_item( $menu_items ) {
$menu_items[] = array(
'name' => 'gfer_form_settings_page',
'label' => __('Entry Reports', 'gravity-forms-entry-reports'),
'title' => __('Entry Reports', 'gravity-forms-entry-reports'),
'menu_class' => 'gfer_settings_navigation',
@mikeott
mikeott / WordPress add paramater to function for CPT.php
Last active September 18, 2023 05:48
WordPress add paramater to function for CPT
<?php
/*
Funds list
Usage:
funds_list(false); // Include the images
or
funds_list(); // DOon't include the images
*/
function funds_list($output_images = true) {
@mikeott
mikeott / responsive-table.css
Created June 29, 2023 06:30
Responsive tables
@media screen and (max-width: 600px) {
table {
width: 100%;
border-collapse: collapse;
}
tr:nth-child(even) {
background-color: #f0f0f0;
}
@mikeott
mikeott / timezone.php
Created June 15, 2023 05:23
Timezone
<?php date_default_timezone_set('Australia/Perth'); ?>
@mikeott
mikeott / WordPress - make specific post always be the latest.php
Created June 12, 2023 02:19
WordPress - make specific post always be the latest
/*
Change the date of post ID 946 to the current date.
This is so the post is shown as the latest, thereby showing as the
latest post on the homepage and also as the latest post on the latest-news page.
*/
function update_post_date_daily() {
$post = get_post(946);