Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrea Barghigiani AndreaBarghigiani

View GitHub Profile
View custom_table_component.html.erb
<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 Jul 30, 2021
Simple Table with ViewComponents
View table_component.html.erb
<table class="<%= classes %>">
<thead class='bg-gray-300 font-medium'>
<% head %>
</thead>
<tbody>
<% body %>
</tbody>
</table>
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created Feb 18, 2020
Aggiungere voce "Esci" nel menu nella theme_location primary. https://skillsandmore.org
View functions.php
<?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 Feb 18, 2020
WordPress aggiungere script e calcolare totale da cella di una tabella.
View functions.php
<?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 Jan 24, 2020
Recuperare una lista di autori WordPress con shortcode o con Hook. Impara a sviluppare con WordPress su: https://skillsandmore.org
View hook.php
<?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'
];
View 1_mio-primo-cpt.php
<?php
/**
* Plugin Name: Il mio primo CPT
*/
View 1_functions.php
<?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 Jan 2, 2020
Raccolta di codici per azionare l'onboarding nei temi Genesis: https://skillsandmore.org/onboarding-genesis/
View 1_onboarding.php
<?php
// Array di configurazione
return [
'dependencies' => [
'plugins' => [],
],
'content' => [],
'navigation_menus' => [],
'widgets' => [],
@AndreaBarghigiani
AndreaBarghigiani / package.json
Last active Aug 22, 2018
Raccolta dei codici pubblicati nell'articolo "Electron, sviluppa applicazioni desktop con i linguaggi web"
View package.json
{
"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 Aug 15, 2018
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.
View llms.template.functions.php
<?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() ) );
}
}
/**