Skip to content

Instantly share code, notes, and snippets.

// quando campo 'valor-doacao' (checkbox) for marcado com o valor 'outro-valor' E o campo 'outro-valor' (text) estiver vazio o campo 'outro-valor' se torna obrigatório
// o tipo de filtro precisa ser igual ao do campo que vai receber a validação (campo do tipo 'text' recebe 'wpcf7_validate_text')
add_filter( 'wpcf7_validate_text', 'my_conditional_required', 10, 2 );
add_filter( 'wpcf7_validate_text*', 'my_conditional_required', 10, 2 );
function my_conditional_required($result, $tag) {
$name = $tag->name;
if ( $name == 'outro-valor') {
if('' == $_POST['outro-valor'] && 'outro-valor' == $_POST['valor-doacao']) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
// envia email para o usuário que comprar o produto Mapa Astral quando o status do pedido for 'processando'
add_action("woocommerce_order_status_changed", "my_awesome_publication_notification");
function my_awesome_publication_notification($order_id, $checkout=null) {
global $woocommerce;
$order = new WC_Order( $order_id ); // envia apenas se o pedido conter um produto específico
if($order->status === 'processing' ) {
$items = $order->get_items();
foreach ( $items as $item_id => $item ) {
/**
* @snippet Add custom placeholders to WooCommerce email subject
* @author WP Authors
* @compatible WooCommerce 3.2+
* @donate https://www.buymeacoffee.com/wpauthors
* @param [string] $string
* @param [object] $email
* @return string
*/
function wpa_filter_email_format_string( $string, $email ) {
<link href="<?php echo get_stylesheet_directory_uri() ?>/assets/img/favicon.png" rel="icon" media="(prefers-color-scheme: light)" />
<link href="<?php echo get_stylesheet_directory_uri() ?>/assets/img/favicon-dark.png" rel="icon" media="(prefers-color-scheme: dark)" />
@LeoLopesWeb
LeoLopesWeb / .html
Last active February 24, 2023 14:30
// create a text field that takes the value of the chosen taxonomy via javascript
// functiom.php
function webroom_add_custom_js_file_to_admin( $hook ) {
wp_enqueue_script( 'admin-js', get_stylesheet_directory_uri() . '/assets/js/admin-js.js' );
}
add_action('admin_enqueue_scripts', 'webroom_add_custom_js_file_to_admin');
// admin-js.js
(function ($) {
//js
$(window)
.resize(function () {
$('iframe[src*="youtube.com"]').each(function () {
if (!$(this).parents(".video-container").length) {
$(this).wrap("<div class='video-container'></div>");
}
});
})
.resize();
-ms-overflow-style: none;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
@LeoLopesWeb
LeoLopesWeb / .php
Last active February 13, 2023 19:26
// testa se o campo CPF (Contact form 7) já existe no banco de dados na tabela 'wp_cf7_vdata_entry' (plugin: Advanced Contact form 7 DB)
add_filter( 'wpcf7_validate_text', 'alphanumeric_validation_filter', 20, 2 );
add_filter( 'wpcf7_validate_text*', 'alphanumeric_validation_filter', 20, 2 );
function alphanumeric_validation_filter( $result, $tag ) {
$tag = new WPCF7_Shortcode( $tag );
if ( 'your-cpf' == $tag->name ) {
$cpf = $_POST['your-cpf'];
global $wpdb;
/**
* Set up the new field in the media module.
*
* @return void
*/
function additional_gallery_settings() {
?>
<script type="text/html" id="tmpl-custom-gallery-setting">
<span>Estilo</span>
function nossa_gente() {
ob_start();
$args = array (
'post_type' => 'post',
'posts_per_page' => -1,
'order' => 'DESC',
'orderby' => 'meta_value',
'post_status' => 'publish',
);