Skip to content

Instantly share code, notes, and snippets.

@titomus
titomus / is-bot.php
Created February 1, 2017 19:09
Detecter les bots par IP
<?php
/**
* Is_bot
* traque la présence d'un bot par plage d'ip
*
* @param string $ip
* @param array $array_bots
* @return string|false
*/
@titomus
titomus / functions.php
Last active February 1, 2017 19:11
Codes Wordpress pour monter un Silo Seo
<?php
#lier le logo en header à la catégorie
add_filter( 'genesis_seo_title', 'child_header_title', 10, 3 );
function child_header_title( $title, $inside, $wrap ) {
if(is_singular('post')){
$category_id = get_the_category();
$id = $category_id[0]->term_id;
@titomus
titomus / functions.php
Created February 2, 2017 16:04
Autoriser les shortcodes dans les tags html (pour les formulaires)
<?php
#shortcode dans input form
add_filter( 'wp_kses_allowed_html', 'allow_tag_in_input', 10, 2 );
function allow_tag_in_input( $allowedposttags, $context ) {
if ( $context == 'post' ) {
$allowedposttags['input']['value'] = 1;
}
return $allowedposttags;
}
@titomus
titomus / GoogleSerpsExtractor.js
Last active May 18, 2017 21:03
Bookmarklet pour Scraper Les Résultats Google
javascript: (function() {
function extractHostname(url) {
var hostname;
if (url.indexOf("://") > -1) {
hostname = url.split('/')[2];
}
else {
hostname = url.split('/')[0];
}
@titomus
titomus / autofollow.js
Last active June 29, 2017 07:18
Comment récupérer des followers sur Twitter en semi automatique... grâce à Chrome
setInterval(function() { window.scrollTo(0, document.body.scrollHeight); }, 5000);
__count__=0;
jQuery('.Grid-cell .not-following .follow-text').each(function (i, ele) {
ele = jQuery(ele);
if (ele.css('display')!='block') {
console.log('deja suivi:', i);
return;
} setTimeout(function () {
ele.click();
}, __count__++*500);
@titomus
titomus / spin.php
Created August 10, 2017 07:04
Fonction PHP pour spinner du contenu SEO
<?php
function spin($txt){
$pattern = '#\{([^{}]*)\}#msi';
$test = preg_match_all($pattern, $txt, $out);
if(!$test)
return $txt;
$a_trouver = array();
$a_remplacer = array();
@titomus
titomus / is_bot.php
Created August 10, 2017 07:11
Detecter les crawlers des moteurs de recherche
<?php
/**
* Is_bot
* traque la présence d'un bot par plage d'ip
*
* @param string $ip
* @param array $array_bots
* @return string|false
*/
@titomus
titomus / racine-referer.php
Created August 10, 2017 07:19
Récupérer la racine du referer
<?php
function racine_referer()
{
if (!isset($_SERVER['HTTP_REFERER'])){
return false;
}else{
$parser_url = parse_url(trim($_SERVER['HTTP_REFERER']));
return trim($parser_url[host] ? $parser_url[host] : array_shift(explode('/', $parser_url[path], 2)));
}
}
@titomus
titomus / get_site_kw.php
Last active August 10, 2017 07:24
Récupérer les mots clés d'un site web via sa balise meta keywords
<?php
function get_site_kw($url){
$meta = get_meta_tags($url);
$keywords = $meta['keywords'];
$keywords = @explode(',', $keywords );
$keywords = array_map( 'trim', $keywords );
$keywords = array_filter( $keywords );
return $keywords;
@titomus
titomus / scrape-links.php
Created August 10, 2017 07:26
Récupérer les liens présents sur une page