Skip to content

Instantly share code, notes, and snippets.

View szbl's full-sized avatar

Sizeable, Inc. szbl

View GitHub Profile
@szbl
szbl / szbl-seo-converter.php
Created March 10, 2017 18:15
Convert from HeadSpace2 to Yoast SEO quick.
<?php
/*
Adds Yoast SEO post meta for quick conversion for title/meta description
from HeadSpace2.
*/
add_action( 'init', 'szbl_convert' );
function szbl_convert()
{
--
-- Update site options (URL redirect/permalinks)
--
UPDATE wp_options
SET option_value = REPLACE( option_value, 'http://www.apexcovantage.com', 'http://www.apexengineering.com' )
WHERE option_value LIKE 'http://%';
--
-- Update page/post content
--
$( 'select.multiline' ).each(function($){
var ajax_url = false, minInputLength = 3;
if ( $( this ).data( 'min-input' ) )
{
minInputLength = $( this ).data( 'min-input' );
}
ajax_url = $( this ).data( 'source' ); ?>
{
"total_count": 3,
"incomplete_results" : false,
"items" : [
{
"value" : 123,
"label" : "<strong>Person Name</strong><br>Phone: 410.444.1234<br>Fax: 410.555.1234<br>Email: andy@szbl.in"
},
{
"value" : 456,
<?php
function szbl_ssl_srcset_fix( $src_list )
{
foreach ( $src_list as $k => $src ) {
$src_list[ $k ]['url'] = set_url_scheme( $src['url'], 'https' );
}
return $src_list;
}
add_filter( 'wp_calculate_image_srcset', 'szbl_ssl_srcset_fix' );
-- Run this on the cloned staging database (to become production)
UPDATE wp_options
SET option_value = REPLACE( option_value, 'http://stage.stuncreative.com', 'http://www.stuncreative.com' )
WHERE option_value LIKE 'http://%';
UPDATE wp_posts
SET post_content = REPLACE( post_content, 'http://stage.stuncreative.com', 'http://www.stuncreative.com' );
UPDATE wp_postmeta
@szbl
szbl / tca.sql
Last active December 12, 2015 01:21
INSERT INTO
wp_usermeta ( user_id, meta_key, meta_value )
SELECT
u.ID as user_id, 'szbl_favorites' as meta_key, pm.post_id as meta_value
FROM wp_users u, wp_postmeta pm
WHERE CONCAT( '_stcr@_', u.user_email ) = pm.meta_key
ORDER BY user_email
INSERT INTO wp_usermeta
( user_id, meta_key, meta_value )
SELECT
u.ID as user_id,
'szbl_favorites' as meta_key,
pm.post_id as meta_value
FROM
wp_postmeta pm, wp_users u
WHERE
pm.meta_key = 'start_email'
<?php
// replace the foreach loop on line 132 with this version:
foreach ( $this->get_children() as $child_id ) {
if ( ! is_int( $child_id ) ) {
continue;
}
$sale_price = get_post_meta( $child_id, '_sale_price', true );
if ( $sale_price !== "" && $sale_price >= 0 ) {
<?php get_header(); ?>
<article id="post-<?php echo get_the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>