Skip to content

Instantly share code, notes, and snippets.

View mbrughi's full-sized avatar

Marco Brughi mbrughi

View GitHub Profile
@mbrughi
mbrughi / gist:19a4682ed07fd78b6424661721628bb0
Last active July 6, 2023 14:06
Wordpress: Remove URL from comments.
/*
* Remove Comments URL
*
*/
add_filter('comment_form_default_fields', 'mb_remove_comments_url');
function mb_remove_comments_url($fields){
if(isset($fields['url']))
unset($fields['url']);
return $fields;
{
"quotes": [
{
"quote":"Fa più rumore un albero che cade di una foresta che cresce.","author":"Lao Tzu"},
{
"quote":"il bisogno di avere ragione è il segno di una mente volgare.","author":"Albert Camus"},
{
"quote":"Sbagliare è umano, perseverare è diabolico.","author":"Sant'Agostino"},
{
@mbrughi
mbrughi / apitest.php
Created December 14, 2022 08:08
Facebook API test
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
// Variabili
$vars = array (
ip => $_SERVER['REMOTE_ADDR'],
agent => $_SERVER['HTTP_USER_AGENT'],
current_page => (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]",
fbp => $_COOKIE[_fbp],
@mbrughi
mbrughi / functions.php
Created November 7, 2022 13:42
Wordpress: Check if plugin is active (various examples) (NB: do not copy the entire code but only the necessary snippet )
<?php
/**
* Detect if a WordPress plugin is active
* (various examples)
*/
/* When coding plugins that rely on another one, like Private Content for bbPress or Visual Attributes for WooCommerce,
you need to make if the WordPress Plugin is active to initialize your plugin routines or display a notice saying that
the required plugin must be activated. In this tutorial we’ll see how to detect whether a certain plugin is active in a
couple of ways.
@mbrughi
mbrughi / gist:b88fd3dbc9d7953cb148f1a471b4a946
Last active September 30, 2022 14:13 — forked from rutger1140/gist:8548548
Plesk Obsidian 18.0.46 nginx (tested) configuration settings for WordPress (not valid for all websites... please test first) | Put inside domain "Hosting & DNS" ---> "Apache & nginx settings"
# Source: https://www.websavers.org/how-to-speed-up-wordpress/
rewrite !\.(js|ico|gif|jpg|png|css|pdf|mov|mp3|eot|svg|ttf|woff|otf|txt|swf)$ /index.php break;
rewrite /wp-admin/$ /wp-admin/index.php break;
rewrite /$ /index.php break;
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
@mbrughi
mbrughi / functions.php
Created July 26, 2022 08:26
Removes link to comment author websites
/*
* Remove Comments Author's link
*
*/
function remove_commentauthorlink( $return, $author, $comment_ID ) {
return $author;
}
add_filter( 'get_comment_author_link', 'remove_commentauthorlink', 10, 3 );
function remove_commentauthorurl() {
@mbrughi
mbrughi / .htaccess
Last active May 5, 2022 14:05 — forked from jacobovidal/.htaccess
Upgrade Insecure Requests via .htaccess or meta tag to prevent mixed content
<ifModule mod_headers.c>
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>
@mbrughi
mbrughi / functions.php
Last active October 21, 2021 09:02
Widget sampte to test Checkbox field
class MY_Widget extends WP_Widget {
public function __construct() {
parent::__construct( 'my_widget', 'My Widget', array(
'classname' => 'my-widget',
'description' => 'Testing checkbox fields.',
) );
}
public function widget( $args, $instance ) {
@mbrughi
mbrughi / contact-form-7-bulma
Created September 22, 2021 06:56
Contact Form 7 - Bulma Css format
<div class="container my-5 mt-5 mx-5 px-5">
<div class="field">
<label class="label is-size-4 has-text-weight-light"> Il tuo Nome </label>
<div class="control has-icons-left">
[text* nome class:input placeholder "Nome"]
<span class="icon is-left">
<i class="fa fa-user"></i>
</span>
</div>
</div>
@mbrughi
mbrughi / functions.php
Created August 13, 2021 14:47
Wordpress: add Google Analytics. (NB: please change UA-69841290-2 with your own Google Analytics Code)
/*
* Add Google Analytics
*/
function mb_add_analytics() {
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-69841290-2"></script>