Skip to content

Instantly share code, notes, and snippets.

View szbl's full-sized avatar

Sizeable, Inc. szbl

View GitHub Profile
@szbl
szbl / ryan.php
Last active August 29, 2015 14:06
<?php
$obj = new stdClass();
echo 'Object in var: ';
var_dump( $obj == true );
echo '<hr>';
echo 'Non-existent var: ';
@var_dump( $nonexistent_obj == true );
--
-- Basic update for site URL, does not update hard-coded content URLs but
-- should update properly generated permalinks and the basic site settings.
--
UPDATE wp_options
SET option_value = REPLACE( option_value, 'http://www.oldhostname.com', 'http://www.newhostname.com' )
WHERE option_value LIKE 'http://%';
<div class="col-sm-6 col-md-4"><div class="thumbnail" style="
background: red;
border: 0;
"><div class="caption" style="
background: #fff;
padding: 0;
min-height: 318px;
margin: 0 3px;
"><h3 style="
color: #fff;
-- Update options (site url, home)
--
UPDATE wp_options
SET option_value = REPLACE( option_value, 'http://url1', 'http://url2' )
WHERE option_value LIKE 'http://%';
-- Update post content
--
UPDATE wp_posts
SET post_content = REPLACE( post_content, 'http://url1', 'http://url2' );
# Download, extract, move and delete WordPress source.
cd /path/to/project/docroot/
wget http://wordpress.org/latest.tar.gz
tar zxvf latest.tar.gz
mv wordpress/* ./
rm -rf latest.tar.gz wordpress
# now hit the URL in your browser and install ;]
# assume: /path/to/sql/file/mydb.sql
cd /path/to/sql/file/
mysql -u root -p
# passord
> use mydb;
> \. mydb.sql
<?php
add_filter( 'gform_pre_render_1', 'szbl_gform_render_test' );
function szbl_gform_render_test( $form )
{
foreach ( $form['fields'] as $key => $field )
{
if ( 'select' == $field->type )
{
if ( 5 == $field->id )
<?php
// single directory
foreach ( glob( dirname( __FILE__ ) . '/lib/*.php' ) as $file ) include $file;
// Or if you're doing 1 directory deep:
foreach ( glob( dirname( __FILE__ ) . '/lib/*.php' ) as $file ) include $file;
foreach ( glob( dirname( __FILE__ ) . '/lib/*/*.php' ) as $file ) include $file;
<?php
add_action( 'admin_init', 'szbl_redirect_subscribers' );
function szbl_redirect_subscribers()
{
$redirect_url = site_url( '/where-to-go/' );
if ( is_user_logged_in() )
{
if ( !current_user_can( 'edit_posts' ) )
{
<?php
/*
Reference: https://codex.wordpress.org/Function_Reference/register_post_type
*/
// hook into the "init" action
add_action( 'init', 'sam_register_post_types' );
function sam_register_post_types()
{