Skip to content

Instantly share code, notes, and snippets.

View mikeyarce's full-sized avatar

Mikey Arce mikeyarce

View GitHub Profile
@mikeyarce
mikeyarce / set-custom-role-after-checkout.php
Created November 30, 2023 18:39
Set role after checkout for WooCommerce
<?php
/**
* Set the default role to employer after checkout.
*
* @param int $order_id
* @return void
*/
function marce_set_employer_role_after_checkout( $order_id ) {
$order = new WC_Order( $order_id );
$user = $order->get_user();
@mikeyarce
mikeyarce / redirect-after-submit-resume.php
Created November 18, 2023 22:15
Redirect After Resume Submission
<?php
add_action( 'resume_manager_resume_submitted', 'wpjmres_final_redirect', 99);
function wpjmres_final_redirect(){
if ( is_admin() ) {
return;
}
wp_redirect('https://wpjm.local/test/');
exit();
}
@mikeyarce
mikeyarce / order-downloads.php
Last active April 12, 2022 22:42
Show filename in WooCommerce Downloads Page
<?php
/**
*
* This template has been modified to show the filename along with the title for each download
* Example: Download - filename.jpg
*
* Order Downloads.
*
* This template can be overridden by copying it to yourtheme/woocommerce/order/order-downloads.php.
*
@mikeyarce
mikeyarce / max-quantities-woocommerce.php
Created September 12, 2020 06:29
Set a maximum quantity for a product in WooCommerce
<?php // only add this line if it's at the top of a new PHP file
add_filter( 'woocommerce_add_to_cart_validation', 'validate_add_to_cart_action', 10, 3 );
function validate_add_to_cart_action( $valid, $product_id, $quantity ) {
// Set the product ID for the product you want to limit
$check_product_id = 121;
// We want to check two quantities, the current cart and how many you are currently adding. We're going to be adding them together into one variable called total_quantity.
$total_quantity = $quantity;
$maximum_quantity = 2;
@mikeyarce
mikeyarce / disable-wp-search.php
Last active November 7, 2019 17:33
Disable WordPress Search #core
<?php
function ma_vip_unresolve_search() {
global $wp_query;
if ( $wp_query->is_search ) {
$wp_query->is_404 = true;
}
}
add_action( 'template_redirect', 'ma_vip_unresolve_search' );
@mikeyarce
mikeyarce / vip_jetpack_search_es_query_args.php
Last active November 4, 2019 16:30
Modify ES query argument for Jetpack Search
<?php
add_filter( 'jetpack_search_es_query_args', function( $args, $query ) {
$args['date_range'] = array(
'field' => 'date',
'gte' => '2016-01-01',
'lte' => '2016-12-31',
);
return $args;
}, 10, 2 );
<?php
// Fuzzy search
add_filter( 'jetpack_search_es_query_args', 'es_fuzzy_search', 10, 2);
function es_fuzzy_search( $es_query_args, $query ) {
$query = get_search_query();
$es_query_args['query']['function_score']['query']['bool'] = array(
'must' => array(
array(
'multi_match' => array(
@mikeyarce
mikeyarce / vipgo-remove-jp-stas.php
Last active March 13, 2020 18:28
Disable and hide Jetpack Stats module
<?php
// Disable the Stats Jetpack Module
add_filter( 'jetpack_active_modules', 'vipgo_override_jp_modules', 99, 9 );
function vipgo_override_jp_modules( $modules ) {
$disabled_modules = array(
'stats',
);
foreach ( $disabled_modules as $module_slug ) {
@mikeyarce
mikeyarce / launch.json
Created August 21, 2018 15:40
vs code xdebug
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"pathMappings": { "/var/www/wp-content": "${workspaceRoot}/" },
"port": 9000
},
@mikeyarce
mikeyarce / storefront-before-header-hook.php
Created July 30, 2018 16:05
Add content to Storefront "before header" hook
<?php
add_filter('storefront_before_header', function() {
echo 'Hello';
});