This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Product Attributes - Bulk Modifier | |
* Description: Bulk update 'custom product attributes' to 'taxonomy product attributes'. Supports the GET variables, like: wpq_mode=run&wpq_from=colour&wpq_to=pa_colour&wpq_ppp=10&wpq_offset=0&wpq_post_type=product&wpq_post_status=any. WARNING: Backup DB first!!! | |
* Plugin Author: birgire | |
* Plugin URI: https://gist.github.com/birgire/0ed300ae4436fcaf508c | |
* Version: 0.0.2 | |
*/ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace all {project} with project name | |
name: wp-{project} | |
recipe: wordpress | |
config: | |
php: '7.4' | |
via: nginx # Nginx or apache | |
webroot: . | |
database: mariadb # Mariadb or mysql | |
xdebug: true | |
config: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your .env file change MAIL configurations to the following to make mailhog work | |
MAIL_MAILER=smtp | |
MAIL_HOST=sendmailhog | |
MAIL_PORT=1025 | |
MAIL_USERNAME=null | |
MAIL_PASSWORD=null | |
MAIL_ENCRYPTION=null | |
MAIL_FROM_ADDRESS=test@test.nl | |
MAIL_FROM_NAME="${APP_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
/** | |
* Throw exception if not found or is unreadable | |
*/ | |
if ( !file_exists( __DIR__ . '/.env' ) || !is_readable( __DIR__ . '/.env' ) ) { | |
throw new Exception( 'The .env file is not found or unreadable.' ); | |
} | |
/** | |
* Get the .env file, ignore new and empty lines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_form_field_checkbox', 'changeCheckboxFormField', 10, 4 ); | |
/** | |
* Input fields are placed in labels by default by WooCommerce. | |
* We want to make sure the label is placed after the input field so :before pseudo class for +checked labels | |
* can be attached to create custom checkboxes in CSS. For this to happen within the filter, | |
* a part of the function from woocommerce_form_field needs to be copied so we can | |
* re-create the Field HTML with the necessary variables and change the order in the $field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_add_error', 'woocommerceAddError' ); | |
/** | |
* Remove billing from the validation message | |
* @see wc_add_notice | |
* | |
* @param $error | |
* @return string|string[] | |
*/ | |
function woocommerceAddError ( $error ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_head', function () { | |
if ( isset( $_GET[ 'bulk-edit-canonical-url' ] ) ) { | |
$args = [ | |
'post_type' => 'post', | |
'suppress_filters' => true, | |
'posts_per_page' => -1, | |
'post_status' => [ 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit' ], | |
]; | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Text field | |
add_filter('woocommerce_form_field_text', function ($field, $key, $args, $value) { | |
if ($key === 'billing_first_name') { | |
$field .= 'here text <a href="/">with link</a>'; | |
} | |
return $field; | |
}, 10, 4); | |
// Phone field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add BudyPress fields to the WooCommerce checkout page by using the xprofile_get_field function from BudyPress | |
* | |
* @see xprofile_get_field() | |
*/ | |
add_filter( 'woocommerce_checkout_fields', function ( $checkout_fields ) { | |
// text field example | |
$bp_field = xprofile_get_field( '211' ); // Get BudyPress field with Field ID | |
$bp_field_wc_id = sanitize_title( 'bp_field_' . $bp_field->name ); // Field ID to identify through the WooCommerce checkout process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'template_redirect', function () { | |
global $wp_query; | |
if ( is_archive() ) { | |
$queried_object = get_queried_object(); | |
if ( | |
isset( $queried_object->taxonomy ) && | |
isset( $queried_object->term_id ) && | |
$queried_object->taxonomy === 'product_cat' && | |
count( get_term_children( $queried_object->term_id, 'product_cat' ) ) === 1 ) { |
OlderNewer