Fabrizio Cocchi: differenze tra le versioni

Da Webmobili Wiki.
 
(28 versioni intermedie di 4 utenti non mostrate)
Riga 10: Riga 10:
</pre>
</pre>


== Personalizzazioniplugin lista notte ==
== Configurazione Gmail ==
Per poter usare il form contatti e spedire email dal sito, seguire guida https://wpmailsmtp.com/it/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/
 
== Personalizzazioni plugin lista notte ==


Plugin -> nm-gift-registry
Plugin -> nm-gift-registry
Riga 19: Riga 22:
non cliccabile il prodotto -> Includes/Table/iItemsTable.php riga 224
non cliccabile il prodotto -> Includes/Table/iItemsTable.php riga 224


traduzioni
</pre>
</pre>
=== Plugin A pagamento ===
<pre>
PRO Direct checkout
License-key:
gMjubMTJaOKp6ihTc5y35GM+Ey2L0n2peBNDZIFp+7YRzIPqda/co4rhpcS6LPhUnypLh3WLg44ZMAX/fRY184qDVw3Wam6gCNfCOkykY46ity2o6MYf8WodjPKgb5QJ1ezG1bgFK3zovgBOV71bzF134YtV+Pi8bDlZdaslCZ+3fi4mReSAu3Hx3or2RNR3D8SmuG+Y6vJUgKrQy2aWYHFPsBwNjFsEO/ve7W13RVhZ5RDUoF69yJood5vv2FpYQb7R4/+G/oPC3LwEXQKlz56MtMktK2EkzhbF8PVwbaWkjs4ehvC5vYK13NlMA/4sqDglQ0bqd1SiSTSS98D2FuPYEyISIoLBxx1srMIRPbPTonOE2Avmj5RZoQt0g6i6UDnI55ddgcmYQgaK6AAqKdjT/Uo1wNLiLqT4+EFx2bKIDHtecHPQL91CRf0XTK2DTWDVOgNoqqr2sB8iasesYw==
</pre>
=== Traduzioni ===
Inserire i file delle traduzioni creati con PoEdit a mano qui: <code>listanozze.fabriziococchi.com/wp-content/languages/plugins</code>
I file sono <code>nm-gift-registry-it_IT.po</code> e <code>nm-gift-registry-it_IT.mo</code>


=== Aggiunta Cadauno al prezzo ===
=== Aggiunta Cadauno al prezzo ===
Riga 29: Riga 45:
ob_start();
ob_start();
$item = $this->get_row_object();
$item = $this->get_row_object();
 
$controllo_cad = $item->get_quantity() > 1 ? " (cad)" : "";
$cost_per_item_text = nmgr()->is_pro ?
$cost_per_item_text = nmgr()->is_pro ?
__( 'Cost per item', 'nm-gift-registry' ) :
__( 'Cost per item', 'nm-gift-registry' ) :
__( 'Cost per item', 'nm-gift-registry-lite' );
__( 'Cost per item', 'nm-gift-registry-lite' );
?>
?>
 
<div class="nmgr-tip" title="<?php echo esc_attr( $cost_per_item_text ); ?>">
<div class="nmgr-tip" title="<?php echo esc_attr( $cost_per_item_text ); ?>">
<?php echo wp_kses_post( $item->get_cost( true )." (cad.)" ); ?>
<?php echo wp_kses_post( $item->get_cost( true ).$controllo_cad ); ?>
</div>
</div>
<?php
<?php
Riga 43: Riga 59:
</syntaxhighlight >
</syntaxhighlight >


=== Rimozione Link Lista Nozze ===
Aggiunto campo QTA se più di 1 pezzo disponibile e rimosso valore iniziale a 1 negli altri casi:
Modificato file del plugin <code>nm-gift-registry\includes\Lib\Single.php</code>
<syntaxhighlight lang="php">
<div class="quantity" style="width:100%"><?php echo $max_qty === 1 ? '' : 'QTA'?>
<input type="<?php echo ( int ) $max_qty === 1 ? 'hidden' : 'number'; ?>"
step="1"
autocomplete="off"
size="4"
class="input-text qty text"
value=""
name="quantity"
min="1"
max="<?php echo esc_attr( $max_qty ); ?>"
    autocomplete="off"
/>
</div>
</syntaxhighlight >


Al fondo modificata la funzione e aggiunto link '''Vai al Carrello''':
=== Rimozione Link Lista Nozze e aggiunta Carrello===
Hook al file del plugin <code>nm-gift-registry\includes\Lib\Single.php</code>
 
nel tema figlio:
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
public static function show_copy_link( $wishlist ) {
<?php
$title = sprintf(
// Pulsante Vai al Carrello, nel listing prodotti
/* translators: %s: wishlist type title */
 
nmgr()->is_pro ? esc_attr__( 'Copy your %s url', 'nm-gift-registry' ) : esc_attr__( 'Copy your %s url', 'nm-gift-registry-lite' ),
add_action( 'nmgr_wishlist', 'vai_al_carrello', 51 ); // Sopra Griglia prodotti
esc_html( nmgr_get_type_title( '', 0, $wishlist->get_type() ) )
add_action( 'nmgr_wishlist', 'vai_al_carrello', 91 ); // Sotto griglia prodotti
);
 
function vai_al_carrello ($wishlist){
$items_count = WC()->cart->get_cart_contents_count();
?>
?>
<!--
<div class="wm-carrello">
<div class="nmgr-copy-wrapper nmgr-tip"
<?php
title="<?php echo esc_html( $title ); ?>"
$items_count = WC()->cart->get_cart_contents_count();
style="margin-top:7px;color:currentColor;cursor:pointer;display:inline-flex;align-items:center;">
 
<svg width="1.2em" height="1.2em" fill="currentColor" clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m6 18h-3c-.48 0-1-.379-1-1v-14c0-.481.38-1 1-1h14c.621 0 1 .522 1 1v3h3c.621 0 1 .522 1 1v14c0 .621-.522 1-1 1h-14c-.48 0-1-.379-1-1zm1.5-10.5v13h13v-13zm9-1.5v-2.5h-13v13h2.5v-9.5c0-.481.38-1 1-1z" fill-rule="nonzero"/></svg>
if ( $items_count > 0 ) : ?>
<div class="nmgr-copy" style="margin-left:6px;border-bottom:1px dashed currentColor;">
<div class="wm-carrello">
<?php echo esc_html( $wishlist->get_permalink() ); ?>
<svg fill="#000" class="nmgr-icon align-with-text" xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M24 3l-.743 2h-1.929l-3.474 12h-13.239l-4.615-11h16.812l-.564 2h-13.24l2.937 7h10.428l3.432-12h4.195zm-15.5 15c-.828 0-1.5.672-1.5 1.5 0 .829.672 1.5 1.5 1.5s1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5zm6.9-7-1.9 7c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5z"></path></svg>
</div>
<a href="<?php echo wc_get_cart_url(); ?>">Vai al carrello (<?php echo $items_count; ?>)</a>
</div>-->
</div>
<div>
<?php endif; ?>
<a href="<?php echo wc_get_cart_url(); ?>">Vai al carrello</a>
</div>
</div>
<?php
<?php
}
}
// Nascondere Link di condivisione della lista
add_action( 'after_setup_theme', 'remove_nmgr_wishlist_action_late', 100 );
function remove_nmgr_wishlist_action_late() {
$class = \NMGR\Lib\Single::class;
    // Controllo che la classe sia caricata
    if ( class_exists( $class ) ) {
        remove_action( 'nmgr_wishlist', array( $class, 'show_copy_link' ), 90 );
    }
}
<?php
}
</syntaxhighlight >
</syntaxhighlight >


== Css personalizzato ==
== Tema figlio ==
 
=== Functions.php ===
 
<syntaxhighlight lang="php">
<?php
// Disabilitare paginazione
add_filter( 'nmgr_items_per_page', '__return_null' );
 
// Ordinamento per Titolo Prodotto
add_filter( 'nmgr_table_default_props', function ( $page, $table ) {
    if ( 'items' === $table->get_id() ) {
        $page[ 'orderby' ] = 'title';
        $page[ 'order' ] = 'asc'; // optional
    }
    return $page;
}, 10, 2 );
 
// Pulsante Vai al Carrello, nel listing prodotti
 
add_action( 'nmgr_wishlist', 'vai_al_carrello', 51 ); // Sopra Griglia prodotti
add_action( 'nmgr_wishlist', 'vai_al_carrello', 91 ); // Sotto griglia prodotti
 
function vai_al_carrello ($wishlist){
$items_count = WC()->cart->get_cart_contents_count();
?>
<div class="wm-carrello">
<?php
$items_count = WC()->cart->get_cart_contents_count();
 
if ( $items_count > 0 ) : ?>
<div class="wm-carrello">
<svg fill="#000" class="nmgr-icon align-with-text" xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M24 3l-.743 2h-1.929l-3.474 12h-13.239l-4.615-11h16.812l-.564 2h-13.24l2.937 7h10.428l3.432-12h4.195zm-15.5 15c-.828 0-1.5.672-1.5 1.5 0 .829.672 1.5 1.5 1.5s1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5zm6.9-7-1.9 7c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5z"></path></svg>
<a href="<?php echo wc_get_cart_url(); ?>">Vai al carrello (<?php echo $items_count; ?>)</a>
</div>
<?php endif; ?>
</div>
<?php
}
 
// Nascondere Link di condivisione della lista
add_action( 'after_setup_theme', 'remove_nmgr_wishlist_action_late', 100 );
 
function remove_nmgr_wishlist_action_late() {
$class = \NMGR\Lib\Single::class;
    // Controllo che la classe sia caricata
    if ( class_exists( $class ) ) {
        remove_action( 'nmgr_wishlist', array( $class, 'show_copy_link' ), 90 );
    }
}
 
// N prodotti per pagina
//add_filter( 'nmgr_items_per_page', function ( $value, $section ) {
// if ( 'items' === $section ) {
// $value = 5;
// }
// return $value;
//}, 10, 2 );
 
// RECUPERO LISTA NOZZE - Da mostrare nel carrello
add_action('template_redirect', function () {
    if (strpos($_SERVER['REQUEST_URI'], '/lista-nozze/') !== false) {
        $current_url = home_url(add_query_arg([], $_SERVER['REQUEST_URI']));
        setcookie('lista_nozze_url', $current_url, time() + 3600, "/"); // 1 ora di durata
    }
});
 
add_action('wp_head', function () {
    if (is_cart() && isset($_COOKIE['lista_nozze_url'])) {
        $lista_url = esc_url($_COOKIE['lista_nozze_url']);
        echo '
        <style>
            .lista-nozze-banner {
                background-color: #f7f7f7;
                padding: 10px;
                text-align: center;
                font-size: 16px;
                border-bottom: 1px solid #ddd;
text-decoration:underline;
            }
        </style>
        <div class="lista-nozze-banner">         
            <a href="' . $lista_url . '" target="_self" rel="noopener">Torna alla lista nozze</a>
        </div>';
    }
});
 
 
</syntaxhighlight>
 
=== Css personalizzato ===
<syntaxhighlight lang="css">
<syntaxhighlight lang="css">
/*Opzioni visualizzazione lista/griglia articoli*/
/*Opzioni visualizzazione lista/griglia articoli*/
Riga 106: Riga 244:
#copyright{
#copyright{
display:none;
display:none;
}
/*Elementi in Griglia con bottone Carrello al fondo della card*/
#nmgr_table_items.nmgr-items-view.grid > div{
display: flex;
  flex-direction: column;
  justify-content: space-between;
}
/*link Carrello*/
.wm-carrello{
text-align:center;
margin-bottom:1rem;
}
/*Larghezza griglia*/
.e-con{
    --container-max-width: 1145px;
}
}
</syntaxhighlight >
</syntaxhighlight >

Versione attuale delle 11:18, 14 lug 2025

Info

[modifica]

Account su Register. Abbiamo creato un sottodominio listanozze e puntato al nostro Apache su AWS.

Register

[modifica]
AFC288-EURO
Fabrizio2020!

Configurazione Gmail

[modifica]

Per poter usare il form contatti e spedire email dal sito, seguire guida https://wpmailsmtp.com/it/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/

Personalizzazioni plugin lista notte

[modifica]

Plugin -> nm-gift-registry

griglia default -> Includes/lib/Setup + css personalizzato -> .nmgr-display-modes {display: none;}

non cliccabile il prodotto -> Includes/Table/iItemsTable.php riga 224

Plugin A pagamento

[modifica]
PRO Direct checkout
License-key:
gMjubMTJaOKp6ihTc5y35GM+Ey2L0n2peBNDZIFp+7YRzIPqda/co4rhpcS6LPhUnypLh3WLg44ZMAX/fRY184qDVw3Wam6gCNfCOkykY46ity2o6MYf8WodjPKgb5QJ1ezG1bgFK3zovgBOV71bzF134YtV+Pi8bDlZdaslCZ+3fi4mReSAu3Hx3or2RNR3D8SmuG+Y6vJUgKrQy2aWYHFPsBwNjFsEO/ve7W13RVhZ5RDUoF69yJood5vv2FpYQb7R4/+G/oPC3LwEXQKlz56MtMktK2EkzhbF8PVwbaWkjs4ehvC5vYK13NlMA/4sqDglQ0bqd1SiSTSS98D2FuPYEyISIoLBxx1srMIRPbPTonOE2Avmj5RZoQt0g6i6UDnI55ddgcmYQgaK6AAqKdjT/Uo1wNLiLqT4+EFx2bKIDHtecHPQL91CRf0XTK2DTWDVOgNoqqr2sB8iasesYw==

Traduzioni

[modifica]

Inserire i file delle traduzioni creati con PoEdit a mano qui: listanozze.fabriziococchi.com/wp-content/languages/plugins

I file sono nm-gift-registry-it_IT.po e nm-gift-registry-it_IT.mo

Aggiunta Cadauno al prezzo

[modifica]

Modificato file originale del plugin nm-gift-registry\includes\Tables\ItemsTable.php

public function get_item_cost() {
		ob_start();
		$item = $this->get_row_object();
		$controllo_cad = $item->get_quantity() > 1 ? " (cad)" : "";
		$cost_per_item_text = nmgr()->is_pro ?
			__( 'Cost per item', 'nm-gift-registry' ) :
			__( 'Cost per item', 'nm-gift-registry-lite' );
		?>

		<div class="nmgr-tip" title="<?php echo esc_attr( $cost_per_item_text ); ?>">
			<?php echo wp_kses_post( $item->get_cost( true ).$controllo_cad ); ?>
		</div>
		<?php
		return ob_get_clean();
	}

Aggiunto campo QTA se più di 1 pezzo disponibile e rimosso valore iniziale a 1 negli altri casi:

<div class="quantity" style="width:100%"><?php echo $max_qty === 1 ? '' : 'QTA'?>
	<input type="<?php echo ( int ) $max_qty === 1 ? 'hidden' : 'number'; ?>"
			 step="1"
			 autocomplete="off"
			 size="4"
			 class="input-text qty text"
			 value=""
			 name="quantity"
			 min="1"
			 max="<?php echo esc_attr( $max_qty ); ?>"
		     autocomplete="off"
		/>
</div>
[modifica]

Hook al file del plugin nm-gift-registry\includes\Lib\Single.php

nel tema figlio:

<?php
	// Pulsante Vai al Carrello, nel listing prodotti

add_action( 'nmgr_wishlist', 'vai_al_carrello', 51 ); // Sopra Griglia prodotti
add_action( 'nmgr_wishlist', 'vai_al_carrello', 91 ); // Sotto griglia prodotti

function vai_al_carrello ($wishlist){
		$items_count = WC()->cart->get_cart_contents_count();
		?>
		<div class="wm-carrello">
			<?php
				$items_count = WC()->cart->get_cart_contents_count();

				if ( $items_count > 0 ) : ?>
					<div class="wm-carrello">
						<svg fill="#000" class="nmgr-icon align-with-text" xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M24 3l-.743 2h-1.929l-3.474 12h-13.239l-4.615-11h16.812l-.564 2h-13.24l2.937 7h10.428l3.432-12h4.195zm-15.5 15c-.828 0-1.5.672-1.5 1.5 0 .829.672 1.5 1.5 1.5s1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5zm6.9-7-1.9 7c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5z"></path></svg>
						<a href="<?php echo wc_get_cart_url(); ?>">Vai al carrello (<?php echo $items_count; ?>)</a>
					</div>
			<?php endif; ?>	
		</div>	
		<?php
	}

// Nascondere Link di condivisione della lista
add_action( 'after_setup_theme', 'remove_nmgr_wishlist_action_late', 100 );

function remove_nmgr_wishlist_action_late() {
	$class = \NMGR\Lib\Single::class;
    // Controllo che la classe sia caricata
    if ( class_exists( $class ) ) {
        remove_action( 'nmgr_wishlist', array( $class, 'show_copy_link' ), 90 );
    }
}

<?php
}

Tema figlio

[modifica]

Functions.php

[modifica]
<?php
// Disabilitare paginazione
add_filter( 'nmgr_items_per_page', '__return_null' );

// Ordinamento per Titolo Prodotto
add_filter( 'nmgr_table_default_props', function ( $page, $table ) {
    if ( 'items' === $table->get_id() ) {
        $page[ 'orderby' ] = 'title';
        $page[ 'order' ] = 'asc'; // optional
    }
    return $page;
}, 10, 2 );

// Pulsante Vai al Carrello, nel listing prodotti

add_action( 'nmgr_wishlist', 'vai_al_carrello', 51 ); // Sopra Griglia prodotti
add_action( 'nmgr_wishlist', 'vai_al_carrello', 91 ); // Sotto griglia prodotti

function vai_al_carrello ($wishlist){
		$items_count = WC()->cart->get_cart_contents_count();
		?>
		<div class="wm-carrello">
			<?php
				$items_count = WC()->cart->get_cart_contents_count();

				if ( $items_count > 0 ) : ?>
					<div class="wm-carrello">
						<svg fill="#000" class="nmgr-icon align-with-text" xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M24 3l-.743 2h-1.929l-3.474 12h-13.239l-4.615-11h16.812l-.564 2h-13.24l2.937 7h10.428l3.432-12h4.195zm-15.5 15c-.828 0-1.5.672-1.5 1.5 0 .829.672 1.5 1.5 1.5s1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5zm6.9-7-1.9 7c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5z"></path></svg>
						<a href="<?php echo wc_get_cart_url(); ?>">Vai al carrello (<?php echo $items_count; ?>)</a>
					</div>
			<?php endif; ?>	
		</div>	
		<?php
	}

// Nascondere Link di condivisione della lista
add_action( 'after_setup_theme', 'remove_nmgr_wishlist_action_late', 100 );

function remove_nmgr_wishlist_action_late() {
	$class = \NMGR\Lib\Single::class;
    // Controllo che la classe sia caricata
    if ( class_exists( $class ) ) {
        remove_action( 'nmgr_wishlist', array( $class, 'show_copy_link' ), 90 );
    }
}

// N prodotti per pagina
//add_filter( 'nmgr_items_per_page', function ( $value, $section ) {
//	if ( 'items' === $section ) {
//		$value = 5;
//	}
//	return $value;
//}, 10, 2 );

// RECUPERO LISTA NOZZE - Da mostrare nel carrello
add_action('template_redirect', function () {
    if (strpos($_SERVER['REQUEST_URI'], '/lista-nozze/') !== false) {
        $current_url = home_url(add_query_arg([], $_SERVER['REQUEST_URI']));
        setcookie('lista_nozze_url', $current_url, time() + 3600, "/"); // 1 ora di durata
    }
});

add_action('wp_head', function () {
    if (is_cart() && isset($_COOKIE['lista_nozze_url'])) {
        $lista_url = esc_url($_COOKIE['lista_nozze_url']);
        echo '
        <style>
            .lista-nozze-banner {
                background-color: #f7f7f7;
                padding: 10px;
                text-align: center;
                font-size: 16px;
                border-bottom: 1px solid #ddd;
				text-decoration:underline;
            }
        </style>
        <div class="lista-nozze-banner">           
            <a href="' . $lista_url . '" target="_self" rel="noopener">Torna alla lista nozze</a>
        </div>';
    }
});

Css personalizzato

[modifica]
/*Opzioni visualizzazione lista/griglia articoli*/
.nmgr-display-modes {display: none;}

/*Bottone Aggiungi al carrello*/
.nmgr_add_to_cart_button.button {
  display: inline-block;
  font-weight: 400;
  color: #fff;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  background-color: #000;
  border: 1px solid #000;
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1;
  border-radius: 0.375rem;
  transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
  text-decoration: none;
}

.nmgr_add_to_cart_button.button:hover {
  background-color: #9e9e9e;
  border-color: #9e9e9e;
}

.nmgr_add_to_cart_button.button:active {
  background-color: #000;
  border-color: #000;
}
/*nascondere Footer Colibri*/
#copyright{
	display:none;
}
/*Elementi in Griglia con bottone Carrello al fondo della card*/
#nmgr_table_items.nmgr-items-view.grid > div{
	display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/*link Carrello*/
.wm-carrello{
	text-align:center;
	margin-bottom:1rem;
}

/*Larghezza griglia*/
.e-con{
    --container-max-width: 1145px;
}