Skip to content

Instantly share code, notes, and snippets.

View salvatorecapolupo's full-sized avatar
🎯
Focusing

Salvatore Capolupo salvatorecapolupo

🎯
Focusing
View GitHub Profile
@salvatorecapolupo
salvatorecapolupo / WordPress analysis without login data
Created March 5, 2020 13:29
Using basic REST API in WordPress for getting some data for SEO website audit, security checks etc.
You can use REST API, i.e mybeatifulwebsite.com
- mybeatifulwebsite.com/wp-json/wp/v2/users will give all users in JSON format (no emails included)
- mybeatifulwebsite.com/wp-json/wp/v2/categories will list all categories list in JSON format
- mybeatifulwebsite.com/wp-json/wp/v2/tags will list all tags list in JSON format
- wp-json/wp/v2/posts will lists latest posts, very similar to /rss or /feed but in JSON
- wp-json/wp/v2/media will list all media files (images, ecc.) in JSON format
Source: https://developer.wordpress.org/rest-api/
/*
Plugin Name:
Plugin URI: http://capolooper.it
Description:
Version: 1.0
Author: Salvalupo Capotore
Author URI: http://capolooper.it
License: GPLv2
*/
<?PHP
// hide all errors / warning in WP, useful for production websites
// file: wp-config.php
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
@salvatorecapolupo
salvatorecapolupo / gist:8ea42445d9fe1cce5991250876fd5b0d
Created December 8, 2019 08:30
Most common script JS/ CSS styles loaded by wordpress plugins and theme. Mantain them on every page just if really needed. Useful while using i.e Assets Cleanup plugin for improving PageSpeed Insights
- Handle: cookie-law-info, cookie-law-info-gdpr - CSS/JS for Cookie Privacy plugin
- Handle: jetpack-photon: Jetpack CDN
- to be continued
@salvatorecapolupo
salvatorecapolupo / Ebook gratuiti per SEO e web-marketing in italiano
Last active July 18, 2021 12:36
Ebook per studiare la SEO ed il web marketing, in italiano. Lista aggiornata al 21 novembre 2019. Suggerisci una risorse (purchè sia gratuita) a s.capolupo@gmail.com, se ti va ;-)
We couldn’t find that file to show.
@salvatorecapolupo
salvatorecapolupo / referrer-basis-redirect
Created September 21, 2019 10:09
This is useful for some backlinks "recovery".
<?PHP
function smart_seo_redirect(){
if ( isset($_SERVER['HTTP_REFERER']) ){
$referrer = $_SERVER['HTTP_REFERER'];
$parse = parse_url($referrer);
$referrer = $parse['host'];
$matches = [];
$matches[]= preg_match('/cool_referral_name/', $referrer, $matches);
@salvatorecapolupo
salvatorecapolupo / FAQPage-rich-snippets.php
Created September 21, 2019 07:13
Dynamic WordPress FAQPage Rich Snippets - use this in a plugin or functions.php
<?PHP
function add_rich_snippets_content( $content ) {
global $post;
$post_ID = $post->ID;
$page_title = get_the_title ( $post_ID );
$page_object = get_post( $post_ID );
$page_excerpt = wp_strip_all_tags ( $page_object->post_content );
$page_excerpt = preg_split ("/\s/", $page_excerpt);
@salvatorecapolupo
salvatorecapolupo / siti-guest-post
Last active March 5, 2021 10:44
Siti che ammettono guest post (aggiornata al 15 settembre 2019)
- fai.informazione.it (basta registrarsi gratuitamente)
- recesiti.wordpress.com (info s.capolupo@gmail.com)
- leultime.info (info s.capolupo@gmail.com)
- medium.com (basta registrarsi)
- linkedin.com (c'è un blog pubblico che si può attivare)
- comunicati.net (basta registrarsi)
- contenutigratis.altervista.org (basta registrarsi, soggetto a moderazione)
- comunicati-stampa.net (basta registrarsi, soggetto a moderazione)
@salvatorecapolupo
salvatorecapolupo / Useful RESTful API for WordPress
Created September 2, 2019 12:19
Enumerate users, plugins, and so on
* Enumerate Users
wp-json/wp/v2/users
- Example
curl https://example.com/wp-json/wp/v2/users
@salvatorecapolupo
salvatorecapolupo / track-click-analytics.js
Created September 1, 2019 10:58
Simple way to add utm_medium / utm_source to any inner link inside your website, as described well here: https://support.google.com/analytics/answer/1033867?hl=en
jQuery(document).ready(function( $ ){
//track single link
var original_link1 = jQuery("a#single").attr('href');
jQuery(elem).attr('href', original_link + '?utm_source=A&utm_medium=B&utm_campaign=C');
//track multi-links
var link_group_identifier = 'a.group';
jQuery( link_group_identifier ).each(function(i, elem) {
var original_link = jQuery(elem).attr('href');