change generatepress color palette

previous solution

// change gp color palette

add_filter( 'generate_default_color_palettes', 'tu_custom_color_palettes' );
function tu_custom_color_palettes( $palettes ) {
  $palettes = array(

    '#351C4D', /* brand */
    '#FEBF7B', /* accent */
    '#FF7E5F', /* action */
    '#765285', /* hover */
    '#C1c1c1', /* light */
    '#fe7b84', /* midtone */
    '#000000', /* black */
    '#FFFFFF', /* white */
  );
  
  return $palettes;
}

block eric jones form spam

// Validate if Email field is spam from ERIC JONES

add_action( 'elementor_pro/forms/validation/email', function( $field, $record, $ajax_handler ) {
    // Looking if email found in spam array, you can add to the array
  $spamemails = array("[email protected]", "[email protected]", "[email protected]", "[email protected]");
    if ( in_array( $field['value'] , $spamemails) ) {
        $ajax_handler->add_error( $field['id'], 'אנחנו לא אוהבים ספאם, נסו מייל אחר' );
    }
}, 10, 3 );

security headers

// security headers

<IfModule mod_headers.c>
  Header always set Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'"
  Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set X-Xss-Protection "1; mode=block"
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "no-referrer"
  Header add Access-Control-Allow-Origin: "https://yourwebsiteurl.com/"
  Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>

use images from live site on stage


// use images from live site on stage https://johnoleksowicz.com/serve-wordpress-images-different-domain-htaccess/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(wp-content/uploads/\d+/.*)$ https://www.livedomainurl.com/$1 [R=301,NC,L]
</IfModule>

gp featured post excerpt length

// gp blog - featured post excerpt length
add_filter( 'excerpt_length', function( $length ) {
    global $wp_query;
    if ( 0 === $wp_query->current_post && !wp_is_mobile() ) {
        // Set Length of first post on desktop
        $length = 50;
    } else {
        // Set Length of other posts and all posts on mobile
        $length = 20;
    }
	return $length;
}, 200);

woo omit categories from shop

// woo - omit categories from shop page

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if it is a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( 'uncategorized', 'sessions', 'programs' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

woo autocomplete virtual orders

/**
 * Auto Complete all WooCommerce virtual orders.
 * 
 * @param  int 	$order_id The order ID to check
 * @return void
 */
function custom_woocommerce_auto_complete_virtual_orders( $order_id ) {

	// if there is no order id, exit
	if ( ! $order_id ) {
		return;
	}

	// get the order and its exit
	$order = wc_get_order( $order_id );
	$items = $order->get_items();

	// if there are no items, exit
	if ( 0 >= count( $items ) ) {
		return;
	}

	// go through each item
	foreach ( $items as $item ) {

		// if it is a variation
		if ( '0' != $item['variation_id'] ) {

			// make a product based upon variation
			$product = new WC_Product( $item['variation_id'] );

		} else {

			// else make a product off of the product id
			$product = new WC_Product( $item['product_id'] );

		}

		// if the product isn't virtual, exit
		if ( ! $product->is_virtual() ) {
			return;
		}
	}

	/*
	 * If we made it this far, then all of our items are virual
	 * We set the order to completed.
	 */
	$order->update_status( 'completed' );
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_virtual_orders' );