public
Created

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
<?php
function gigaom_script_slug_swap( $pairs ) {
global $wpdb;
foreach ( $pairs as $pair ) {
$_temp_name = $pair[0] . '-gigaom-temp-123456789';
$slugs = "'" . implode( "', '", $pair ) . "'";
$ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_name IN( $slugs ) LIMIT 2" );
$wpdb->update( $wpdb->posts, array( 'post_name' => $_temp_name ), array( 'post_status' => 'publish', 'post_type' => 'post', 'post_name' => $pair[0] ) );
$wpdb->update( $wpdb->posts, array( 'post_name' => $pair[0] ), array( 'post_status' => 'publish', 'post_type' => 'post', 'post_name' => $pair[1] ) );
$wpdb->update( $wpdb->posts, array( 'post_name' => $pair[1] ), array( 'post_status' => 'publish', 'post_type' => 'post', 'post_name' => $_temp_name ) );
foreach ( $ids as $id )
clean_post_cache( $id );
}
return true;
}
 
$pairs = array(
array('is-pge-fiddling-while-the-grid-burns-1', 'is-pge-fiddling-while-the-grid-burns'),
array('bob-metcalfe-welcome-to-the-enernet-1', 'bob-metcalfe-welcome-to-the-enernet'),
array('the-top-10-most-controversial-ways-to-save-the-planet-1', 'the-top-10-most-controversial-ways-to-save-the-planet'),
array('how-green-is-your-caucus-1', 'how-green-is-your-caucus'),
array('faq-carbon-capture-sequestration-1', 'faq-carbon-capture-sequestration'),
array('tesla-ditches-its-two-speed-transmission-1', 'tesla-ditches-its-two-speed-transmission'),
array('tesla-ipo-likely-in-2009-1', 'tesla-ipo-likely-in-2009'),
array('brighter-screens-better-planet-1', 'brighter-screens-better-planet'),
array('carbon-hero-to-the-rescue-1', 'carbon-hero-to-the-rescue'),
array('4-winning-cleantech-innovations-outta-uc-berkeley-1', '4-winning-cleantech-innovations-outta-uc-berkeley'),
array('pimp-your-gas-guzzler-with-soy-seats-1', 'pimp-your-gas-guzzler-with-soy-seats'),
array('greenbox-flash-creators-tackle-energy-in-the-home-1', 'greenbox-flash-creators-tackle-energy-in-the-home'),
array('e2t-video-pge-ceo-paints-the-future-of-utilities-1', 'e2t-video-pge-ceo-paints-the-future-of-utilities'),
array('qualcomm-saves-millions-with-green-it-1', 'qualcomm-saves-millions-with-green-it'),
array('project-better-place-might-charge-up-sf-1', 'project-better-place-might-charge-up-sf'),
array('austin-cleantech-guru-to-be-kleiner-eir-1', 'austin-cleantech-guru-to-be-kleiner-eir'),
array('shai-agassi-on-how-to-electrify-americas-cars-1', 'shai-agassi-on-how-to-electrify-americas-cars'),
array('the-good-the-bad-the-ugly-of-7-gas-1', 'the-good-the-bad-the-ugly-of-7-gas'),
array('13-startups-working-on-solar-concentrating-pv-1', '13-startups-working-on-solar-concentrating-pv'),
array('bill-gates-trash-talks-bill-gates-1', 'bill-gates-trash-talks-bill-gates'),
array('google-and-ge-join-up-to-tackle-energy-policy-tech-1', 'google-and-ge-join-up-to-tackle-energy-policy-tech'),
array('how-internet-enabled-appliances-can-save-you-time-money-1', 'how-internet-enabled-appliances-can-save-you-time-money'),
array('ericsson-unveils-wind-powered-cell-tower-1', 'ericsson-unveils-wind-powered-cell-tower'),
array('google-ceo-to-stump-for-obama-boon-for-energy-action-1', 'google-ceo-to-stump-for-obama-boon-for-energy-action'),
array('10-green-options-for-black-friday-1', '10-green-options-for-black-friday'),
array('calling-for-submissions-for-greennet-startups-1', 'calling-for-submissions-for-greennet-startups'),
array('why-the-consumer-electronics-show-is-going-greener-in-2009-1', 'why-the-consumer-electronics-show-is-going-greener-in-2009'),
array('7-ways-to-cut-fuel-consumption-with-it-1', '7-ways-to-cut-fuel-consumption-with-it'),
array('greennet-keynote-bob-metcalfes-search-for-the-enternet-1', 'greennet-keynote-bob-metcalfes-search-for-the-enternet'),
array('sf-mayor-gavin-newsom-power-america-with-ocean-energy-1', 'sf-mayor-gavin-newsom-power-america-with-ocean-energy'),
array('ciscos-latest-consumer-play-the-smart-grid-1', 'ciscos-latest-consumer-play-the-smart-grid'),
array('how-digital-music-can-fight-climate-change-1', 'how-digital-music-can-fight-climate-change'),
array('earth2techs-top-15-smart-grid-influencers-1', 'earth2techs-top-15-smart-grid-influencers'),
array('google-releases-api-for-energy-tool-powermeter-1', 'google-releases-api-for-energy-tool-powermeter'),
array('the-reliance-chain-communities-wireless-networks-energy-1', 'the-reliance-chain-communities-wireless-networks-energy'),
array('join-vinod-khosla-jerry-brown-google-and-more-at-greennet-next-week-1', 'join-vinod-khosla-jerry-brown-google-and-more-at-greennet-next-week'),
array('the-new-office-space-1', 'the-new-office-space'),
array('the-new-office-space-goes-global-1', 'the-new-office-space-goes-global'),
array('broadband-in-the-boonies-1', 'broadband-in-the-boonies'),
array('gmail-mobile-1', 'gmail-mobile'),
array('webworkerdaily-refreshed-1', 'webworkerdaily-refreshed'),
array('how-to-screw-up-an-email-negotiation-1', 'how-to-screw-up-an-email-negotiation'),
array('seven-habits-of-successful-virtual-teams-1', 'seven-habits-of-successful-virtual-teams'),
array('how-to-manage-kids-in-the-home-office-1', 'how-to-manage-kids-in-the-home-office'),
array('5-ways-to-get-work-under-control-1', '5-ways-to-get-work-under-control'),
array('10-new-ways-to-make-money-online-1', '10-new-ways-to-make-money-online'),
array('wwd-gets-chronicled-1', 'wwd-gets-chronicled'),
array('the-dangerous-myth-of-the-dream-job-1', 'the-dangerous-myth-of-the-dream-job'),
array('how-to-build-your-personal-brand-online-1', 'how-to-build-your-personal-brand-online'),
array('dimdim-challenges-webex-microsoft-1', 'dimdim-challenges-webex-microsoft'),
array('8-steps-to-running-your-business-on-mostly-free-apps-1', '8-steps-to-running-your-business-on-mostly-free-apps'),
array('yahoo-looks-to-aggregate-your-mobile-content-with-oneplace-1', 'yahoo-looks-to-aggregate-your-mobile-content-with-oneplace'),
array('gigaom-acquires-jkontherun-1', 'gigaom-acquires-jkontherun'),
array('14-things-corporations-can-learn-from-seasoned-web-workers-1', '14-things-corporations-can-learn-from-seasoned-web-workers'),
array('happy-holidays-1', 'happy-holidays'),
array('were-all-web-workers-now-1', 'were-all-web-workers-now'),
array('sitepoint-book-sale-to-aid-bushfire-appeal-1', 'sitepoint-book-sale-to-aid-bushfire-appeal'),
array('true-knowledge-opens-api-1', 'true-knowledge-opens-api'),
array('cheap-ways-to-upgrade-your-laptop-1', 'cheap-ways-to-upgrade-your-laptop'),
array('take-our-survey-for-a-chance-to-win-a-50-gift-certificate-from-amazon-com-1', 'take-our-survey-for-a-chance-to-win-a-50-gift-certificate-from-amazon-com'),
array('take-our-short-work-survey-for-a-chance-to-win-50-to-amazon-com-1', 'take-our-short-work-survey-for-a-chance-to-win-50-to-amazon-com')
);
 
if ( current_user_can( 'manage_options' ) && isset( $_GET['go_slug_swap'] ) )
gigaom_script_slug_swap( $pairs );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.