em, $args));
$class_names = ' class="' . esc_attr($class_names) . '"';
$id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
$id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
$output .= $indent . '
';
$attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
$attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
$attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
$attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
$active_class = ($item->current || $item->current_item_ancestor) ? 'active' : '';
$attributes .= ($args->walker->has_children) ? ' class="nav-link ' . $active_class . ' dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"' : ' class="nav-link ' . $active_class . '"';
$item_output = $args->before;
$item_output .= ($depth > 0) ? '' : '';
$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
$item_output .= '';
$item_output .= $args->after;
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
}
// register a new menu
register_nav_menu('main-menu', 'Menú Principal');
function dcms_agregar_nueva_zona_widgets() {
register_sidebar( array(
'name' => 'Main Sidebar',
'id' => 'sidebar',
'description' => 'sidebar',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'dcms_agregar_nueva_zona_widgets' );
//Para un theme cualquiera
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Opciones del tema',
'menu_title' => 'Opciones del tema',
'menu_slug' => 'theme-general-settings',
));
}
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'id' => 'options',
'title' => '' . __('Opciones del tema'),
'href' => admin_url( 'admin.php?page=theme-general-settings'),
'meta' => false ,
));
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
function my_theme_block_category( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'theme-blocks',
'title' => __( 'Bloques del tema', 'theme-blocks' ),
),
)
);
}
add_filter( 'block_categories', 'my_theme_block_category', 10, 2);
require_once get_stylesheet_directory() . '/blocks/register_blocks.php';
function my_theme_setup() { add_theme_support( 'woocommerce' ); } add_action( 'after_setup_theme', 'my_theme_setup' );
function body_classes( $class = '' ) {
// Separates classes with a single space, collates classes for body element
echo 'class="' . join( ' ', get_body_class( $class ) );
echo ' lang-' .ICL_LANGUAGE_CODE;
echo '"';
}
// si mensaje por zona de envio
// add_action( 'woocommerce_cart_totals_after_shipping' , 'mostrar_mensaje_zona_envio' );
// add_action( 'woocommerce_review_order_after_shipping' , 'mostrar_mensaje_zona_envio' );
// function mostrar_mensaje_zona_envio() {
// $targeted_zones_names = array('Uruguay'); //Zonas de envío configuradas
// // Zona de envío seleccionada por el usuario
// $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); // Método de envío seleccionado
// $chosen_method = explode(':', reset($chosen_methods) );
// $shipping_zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $chosen_method[1] );
// $current_zone_name = $shipping_zone->get_zone_name();
// $message = "Si eligió envío a domicilio el costo de envío de coordinará según indique la apicación de envío";
// if( in_array( $current_zone_name, $targeted_zones_names ) ){
// echo '
// ' . $message . ' |
//
';
// }
// }
add_action( 'woocommerce_cart_totals_after_shipping' , 'dl_abrir_mensaje_seleccionando_envio' );
add_action( 'woocommerce_review_order_after_shipping' , 'dl_abrir_mensaje_seleccionando_envio' );
function dl_abrir_mensaje_seleccionando_envio() {
$chosen_method = WC()->session->get( 'chosen_shipping_methods' );
$chosen_method = explode(':', reset($chosen_method) );
if ( $chosen_method[0] == 'flat_rate' ){
echo '
El costo de envío de coordinará según indique la apicación de envío |
';
}
}
/*******************************************************************************************/
//20240423 : FZSM - Add custom field for color to product
add_action('woocommerce_product_options_general_product_data', 'add_color_custom_field');
function add_color_custom_field() {
// Text field for color
woocommerce_wp_text_input(
array(
'id' => 'color_custom_field',
'label' => __('Color', 'woocommerce'),
'placeholder' => __('Color del producto?', 'woocommerce'),
'desc_tip' => 'true',
'description' => __('Ingrese el color del producto.', 'woocommerce')
)
);
}
// Save custom field value
add_action('woocommerce_process_product_meta', 'save_color_custom_field');
function save_color_custom_field($post_id) {
$color = $_POST['color_custom_field'];
if (!empty($color)) {
update_post_meta($post_id, 'color_custom_field', esc_attr($color));
}
}
/***************************************************************************************************/
// Display custom field (color) on the product page
add_action('woocommerce_single_product_summary', 'display_color_custom_field', 25);
function display_color_custom_field() {
global $product;
// Get the color custom field value
$color = get_post_meta($product->get_id(), 'color_custom_field', true);
// Display the color if available
if (!empty($color)) {
echo '';
echo '' . __('Color:', 'woocommerce') . ' ' . esc_html($color);
echo '
';
}
}
?> XML-RPC server accepts POST requests only.