Skip to content

Instantly share code, notes, and snippets.

View NorthTexasCreative's full-sized avatar

Carla Chalmers NorthTexasCreative

  • North Texas Creative, LLC
  • Stephenville, TX
View GitHub Profile
// Get WordPress site name via shortcode: [nf_site_name]
function nf_site_name_shortcode() {
return get_bloginfo('name');
}
add_shortcode('nf_site_name','nf_site_name_shortcode');
@NorthTexasCreative
NorthTexasCreative / functions.php
Created February 6, 2024 18:13
Change Post Labels
function cp_change_post_object() {
$get_post_type = get_post_type_object('post');
$labels = $get_post_type->labels;
$labels->name = 'Newsroom';
$labels->singular_name = 'Newsroom';
$labels->add_new = 'Add News';
$labels->add_new_item = 'Add News';
$labels->edit_item = 'Edit News';
$labels->new_item = 'News';
$labels->view_item = 'View News';
@NorthTexasCreative
NorthTexasCreative / Classified-Listing-Sample-data.json
Created November 5, 2023 11:57 — forked from radiustheme/Classified-Listing-Sample-data.json
How to import sample data for classified listing like categories & locations
{
"locations": [
{
"name": "New York",
"slug": "",
"description": "",
"meta": [
{"image_id" : 45},
{"_icon" : ""}
],
@NorthTexasCreative
NorthTexasCreative / tjkelly-screaming-frog-exclude-wordpress.txt
Created January 26, 2023 19:54 — forked from tjkelly/tjkelly-screaming-frog-exclude-wordpress.txt
WordPress URL Exclude List for Screaming Frog Spider
/**
* WordPress URL Exclude List for Screaming Frog Spider
* @author TJ Kelly - https://tjkelly.com
* @desc Full article — https://tjkelly.com/blog/screaming-frog-exclude-wordpress/
* @date 2021-07-08
*/
https://example.com/wp-content/.*
https://example.com/wp-content/mu-plugins/.*
https://example.com/wp-content/plugins/.*
@NorthTexasCreative
NorthTexasCreative / wsl2-ubuntu-lamp.md
Created November 15, 2022 02:08 — forked from abobija/wsl2-ubuntu-lamp.md
LAMP stack on WSL2 (Ubuntu 20.04) - Apache, MySQL, PHP, PhpMyAdmin

LAMP stack on WSL2 (Ubuntu 20.04) - Apache, MySQL, PHP, PhpMyAdmin

Apache

sudo apt-get update && sudo apt-get upgrade 
sudo apt-get install -y apache2

PHP

@NorthTexasCreative
NorthTexasCreative / functions.php
Last active October 26, 2022 15:30
Force add to cart quantity to 1 and disable +- quantity input
/**
* @snippet WooCommerce Display Separate Cart Items for Product Quantity > 1
* @author Carla Chalmers
* @testedwith WooCommerce 3.5.1
*/
// -------------------
// Split product quantities into multiple cart items
// Note: this is not retroactive - empty cart before testing
@NorthTexasCreative
NorthTexasCreative / wc-functions.php
Created October 25, 2022 21:22
WooCommerce Required Fields
/** Change obligatory-optional status on billing fields
* true = required
* false = optional
*/
add_filter('woocommerce_billing_fields', 'force_billing_fields', 1000, 1);
function force_billing_fields($fields) {
$fields['billing_first_name']['required'] = false; //First Name
$fields['billing_last_name']['required'] = false; //Last Name
$fields['billing_email']['required'] = false; //Email
$fields['billing_phone']['required'] = false; //Phone number
@NorthTexasCreative
NorthTexasCreative / functions.php
Created October 13, 2022 20:04
Fill in WooCommerce Order fields from user profile
add_filter( 'woocommerce_checkout_fields' , 'ahmadyani_checkout_field_defaults', 20 );
function ahmadyani_checkout_field_defaults( $fields ) {
$user = get_user_meta(get_current_user_id());
$first_name = $user ? $user['shipping_first_name'][0] : '';
$last_name = $user ? $user['shipping_last_name'][0] : '';
$company = $user ? $user['shipping_company'][0] : '';
$shipping_address_1 = $user ? $user['shipping_address_1'][0] : '';
$shipping_address_2 = $user ? $user['shipping_address_2'][0] : '';
$shipping_city = $user ? $user['shipping_city'][0] : '';
$shipping_state = $user ? $user['shipping_state'][0] : '';
@NorthTexasCreative
NorthTexasCreative / functions.php
Created October 2, 2022 22:06
Individual Cart Item Display
/**
* @snippet WooCommerce Display Separate Cart Items for Product Quantity > 1
* @author Carla Chalmers
* @testedwith WooCommerce 3.5.1
*/
// -------------------
// Split product quantities into multiple cart items
// Note: this is not retroactive - empty cart before testing
@NorthTexasCreative
NorthTexasCreative / hosts
Created September 26, 2022 19:00 — forked from monkishtypist/hosts
Nginx virtual host example for Windows Subsystem for Linux (WSL)
# Location: /mnt/c/windows/system32/drivers/etc/hosts
127.0.0.1 virtualhost.local www.virtualhost.local