Skip to content

Instantly share code, notes, and snippets.

@remoharsono
remoharsono / request.php
Created February 10, 2019 03:00
PHP cURL - Set User Agent as Google Bot
<?php
// taken from: https://github.com/izniburak/google-bot-curl/blob/master/google-bot.php
function googleBot($url)
{
$header = array();
$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Content-Type: text/html; charset=utf-8';
$header[] = 'Transfer-Encoding: chunked';
@webercoder
webercoder / wp-author-import-auto-select.js
Created June 4, 2012 20:33
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
$(this).find('select').first().children('option').each(function(){
if ($(this).html() == name) {
console.log('Comparing ' + $(this).html() + ' to ' + name + ".\n");
$(this).attr('selected', 'selected');
@chrisle
chrisle / gist:2252209
Created March 30, 2012 15:15
CURL as GoogleBot 2.1
curl --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" -v $@
@wpscholar
wpscholar / wp-snapshot-shortcode.php
Last active May 20, 2020 15:51
Shortcode displays snapshots of remote sites on your WordPress site.
<?php
/**
* This shortcode will allow you to create a snapshot of a remote website and post it
* on your WordPress site.
*
* [snapshot url="http://www.wordpress.org" alt="WordPress.org" width="400" height="300"]
*/
add_shortcode( 'snapshot', function ( $atts ) {
$atts = shortcode_atts( array(