Fabrizio Cocchi: differenze tra le versioni

Da Webmobili Wiki.
Nessun oggetto della modifica
 
(18 versioni intermedie di 4 utenti non mostrate)
Riga 9: Riga 9:
Fabrizio2020!
Fabrizio2020!
</pre>
</pre>
== 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 ==
== Personalizzazioni plugin lista notte ==
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>
 
=== Plugin A pagamento ===
 
<pre>
PRO Direct checkout
License-key:
gMjubMTJaOKp6ihTc5y35GM+Ey2L0n2peBNDZIFp+7YRzIPqda/co4rhpcS6LPhUnypLh3WLg44ZMAX/fRY184qDVw3Wam6gCNfCOkykY46ity2o6MYf8WodjPKgb5QJ1ezG1bgFK3zovgBOV71bzF134YtV+Pi8bDlZdaslCZ+3fi4mReSAu3Hx3or2RNR3D8SmuG+Y6vJUgKrQy2aWYHFPsBwNjFsEO/ve7W13RVhZ5RDUoF69yJood5vv2FpYQb7R4/+G/oPC3LwEXQKlz56MtMktK2EkzhbF8PVwbaWkjs4ehvC5vYK13NlMA/4sqDglQ0bqd1SiSTSS98D2FuPYEyISIoLBxx1srMIRPbPTonOE2Avmj5RZoQt0g6i6UDnI55ddgcmYQgaK6AAqKdjT/Uo1wNLiLqT4+EFx2bKIDHtecHPQL91CRf0XTK2DTWDVOgNoqqr2sB8iasesYw==
</pre>
</pre>


=== Traduzioni ===
=== Traduzioni ===


Inserire i file delle traduzioni fatte a mano qui: <code>listanozze.fabriziococchi.com/wp-content/languages/plugins</code>
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 33: 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
return ob_get_clean();
return ob_get_clean();
}
}
</syntaxhighlight >
Aggiunto campo QTA se più di 1 pezzo disponibile e rimosso valore iniziale a 1 negli altri casi:
<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 >
</syntaxhighlight >


=== Rimozione Link Lista Nozze e aggiunta Carrello===
=== Rimozione Link Lista Nozze e aggiunta Carrello===
Modificato file del plugin <code>nm-gift-registry\includes\Lib\Single.php</code>
Hook al file del plugin <code>nm-gift-registry\includes\Lib\Single.php</code>


Al fondo aggiunta la funzione e aggiunto link '''Vai al Carrello''' e all'inizio del file:
nel tema figlio:
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
<?php
<?php
public static function run() {
// Pulsante Vai al Carrello, nel listing prodotti
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_images' ), 10 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_title' ), 20 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_display_name' ), 30 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_event_date' ), 40 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_description' ), 50 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'vai_al_carrello' ), 51 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_notices' ), 60 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_items' ), 70 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'show_share_links' ), 80 );
//add_action( 'nmgr_wishlist', array( __CLASS__, 'show_copy_link' ), 90 );
add_action( 'nmgr_wishlist', array( __CLASS__, 'vai_al_carrello' ), 91 );
}


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


public static function vai_al_carrello ($wishlist){
function vai_al_carrello ($wishlist){
$items_count = WC()->cart->get_cart_contents_count();
?>
?>
<div class="wm-carrello">
<div class="wm-carrello">
<a href="<?php echo wc_get_cart_url(); ?>">Vai al carrello</a>
<?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>
</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 >


Riga 80: Riga 122:


=== Functions.php ===
=== 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 ===
=== Css personalizzato ===
Riga 116: 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;
}