Skip to content

Instantly share code, notes, and snippets.

View AndreaBarghigiani's full-sized avatar

Andrea Barghigiani AndreaBarghigiani

View GitHub Profile
@AndreaBarghigiani
AndreaBarghigiani / custom_table_component.html.erb
Created July 30, 2021 06:28
Flexible rows for TableComponent
<tr>
<td class="border p-3">
<%= tag.p tag.strong @data.name %>
<%= tag.p @data.description %>
</td>
<td class="border p-3"><%= @data.qty %></td>
<td class="border p-3"><%= @data.tax %></td>
<td class="border p-3"><%= @data.unit_cost %></td>
</tr>
@AndreaBarghigiani
AndreaBarghigiani / table_component.html.erb
Created July 30, 2021 06:04
Simple Table with ViewComponents
<table class="<%= classes %>">
<thead class='bg-gray-300 font-medium'>
<% head %>
</thead>
<tbody>
<% body %>
</tbody>
</table>
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created February 18, 2020 14:12
Aggiungere voce "Esci" nel menu nella theme_location primary. https://skillsandmore.org
<?php
add_filter( 'wp_nav_menu_items', 'sam_logout_menu', 10, 2 );
function sam_logout_menu( $items, $args ) {
if ( 'primary' == $args->theme_location ) {
$items .= '<li class="menu-item logout"><a href="'. wp_logout_url(home_url()) . '" >Esci</a></li>';
}
}
return $items;
}
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created February 18, 2020 14:00
WordPress aggiungere script e calcolare totale da cella di una tabella.
<?php
add_action('wp_enqueue_scripts', 'sam_load_scripts');
function sam_load_scripts(){
wp_enqueue_script( 'slug-tuo-script', get_bloginfo( 'stylesheet_directory' ) . '/js/tuo-script.js', array( 'jquery' ), '1.0.0' );
}
@AndreaBarghigiani
AndreaBarghigiani / hook.php
Created January 24, 2020 09:18
Recuperare una lista di autori WordPress con shortcode o con Hook. Impara a sviluppare con WordPress su: https://skillsandmore.org
<?php
// Aggiungo la lista autori agganciandomi a un Hook
add_action( 'il_tuo_hook', 'sam_recupero_autori' );
function sam_recupero_autori() {
$args = [
'role' => 'author',
'fields' => 'ID'
];
<?php
/**
* Plugin Name: Il mio primo CPT
*/
@AndreaBarghigiani
AndreaBarghigiani / 1_functions.php
Created January 2, 2020 09:35
Aggiungi tutti i Controlli che desideri al Theme Customizer: https://skillsandmore.org/aggiungi-controlli-theme-customizer/
<?php
//* Aggiungo la pagina d'esempio per i componenti
include_once( get_stylesheet_directory() . '/inc/theme-customizer/theme-customizer-demo.php' );
@AndreaBarghigiani
AndreaBarghigiani / 1_onboarding.php
Last active January 2, 2020 09:07
Raccolta di codici per azionare l'onboarding nei temi Genesis: https://skillsandmore.org/onboarding-genesis/
<?php
// Array di configurazione
return [
'dependencies' => [
'plugins' => [],
],
'content' => [],
'navigation_menus' => [],
'widgets' => [],
@AndreaBarghigiani
AndreaBarghigiani / package.json
Last active August 22, 2018 06:20
Raccolta dei codici pubblicati nell'articolo "Electron, sviluppa applicazioni desktop con i linguaggi web"
{
"name": "app-desktop",
"version": "1.0.0",
"description": "applicazione di esempio con Electron",
"main": "main.js",
"scripts": {
"run": "electron ."
},
"author": "Andrea Barghigiani",
"license": "ISC"
@AndreaBarghigiani
AndreaBarghigiani / llms.template.functions.php
Last active August 15, 2018 07:33
This code expand the capability of is_lifterlms() and is able to check if the sale page that is loaded is included in some course or membership.
<?php
// Espandend to use is_sales_page()
if ( ! function_exists( 'is_lifterlms' ) ) {
function is_lifterlms() {
return apply_filters( 'is_lifterlms', ( is_courses() || is_course_taxonomy() || is_course() || is_lesson() || is_membership() || is_memberships() || is_quiz() || is_sales_page() ) );
}
}
/**