Skip to content

Instantly share code, notes, and snippets.

View Matteo182's full-sized avatar

Matteo Ragusa Matteo182

View GitHub Profile
@Matteo182
Matteo182 / content.php
Created June 28, 2019 08:16
WordPress Loop in Made theme Google structured Data
<?php
/**
* Post rendering content according to caller of get_template_part.
*
* @package understrap
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
@Matteo182
Matteo182 / call-api.php
Last active July 4, 2019 15:45
use curl for call API in php
/****************************************** */
// Funzione per richiamare le API
/****************************************** */
// Method: POST, PUT, GET etc
// Data: array("param" => "value") ==> index.php?param=value
function CallAPI($method, $url, $data = false){
$url_c = 'http://95.110.166.40/API/v1'.$url;
@Matteo182
Matteo182 / string_manipulation.php
Last active July 25, 2019 08:55
Funzione per manipolare le stringhe
/****************************************** */
// Funzione per manipolare le stringhe
/****************************************** */
function tdm_get_string_between($string, $start, $end){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
@Matteo182
Matteo182 / autologin.php
Created July 4, 2019 15:42
Funzione per l'autologin
/****************************************** */
// Funzione per l'autologin
/****************************************** */
function autologin($user_name){
$user = get_user_by('login', $user_name );
// Redirect URL //
if ( !is_wp_error( $user ) )
@Matteo182
Matteo182 / social_widget.php
Created July 12, 2019 09:39
Social share button widget for Wordpress
<?php
/************************** */
// social media sharing button
/************************** */
//creao una widget area
function tdm_social_post_widgets_init() {
register_sidebar( array(
'name' => __( 'Social in post', 'tdm_social' ),
@Matteo182
Matteo182 / book-filter.php
Created August 1, 2019 09:03
Plugin per WordPress per creare filtri per prodotti di Woocommerce con custom field, genera uno short code.
<?php
/*
Plugin Name: Book Filter
Description: Crea uno short code per applicare i filtri alla pagina Biblioteca
Version: 1.0
*/
/* Includo js in wordpress */
function enqueue_scripts(){
@Matteo182
Matteo182 / add_class_menu.php
Last active August 27, 2019 14:13
Add class activ in wp_menu
/* Aggiungo classe activ nel menu di navigazione di WP */
add_filter('nav_menu_css_class' , 'tdm_special_nav_class' , 10 , 2);
function tdm_special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
@Matteo182
Matteo182 / active-menu-bar.js
Created September 12, 2019 10:40
Add class Active in navbar menu
$(function(){
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/,'') + "$"); // create regexp to match current url pathname and remove trailing slash if present as it could collide with the link in navigation in case trailing slash wasn't present there
// now grab every link from the navigation
$('#box-menu a').each(function(){
// and test its normalized href against the url pathname regexp
if(urlRegExp.test(this.href.replace(/\/$/,''))){
$(this).addClass('active');
}
@Matteo182
Matteo182 / cascade-select-comuni.html
Last active July 3, 2024 08:48
Select cascade Province italiane e comuni jquery
<-- Esempio parte in HTML -->
<div style="margin-top:3rem;" class="row">
<label for="billing_address">(È richiesto indirizzo completo)*</label>
<!-- select delle province -->
<div class="col-md-4 ">
<div class="form-group">
<select class="select form-control user-success" placeholder="Provincia" required="required" id="address_state">
@Matteo182
Matteo182 / .htaccess
Created December 5, 2019 15:36
REDIRECT PER LA CARTELLA /web di BEDROCK
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# REDIRECT PER LA CARTELLA /web di BEDROCK # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Add directives
RewriteEngine on
# Change root directory to “web” folder
RewriteCond %{THE_REQUEST} ^GET\ /web/
RewriteRule ^web/(.*) /$1 [L,R=301]
RewriteRule !^web/ web%{REQUEST_URI} [L]