Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created August 12, 2012 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/3334021 to your computer and use it in GitHub Desktop.
Save wpsmith/3334021 to your computer and use it in GitHub Desktop.
Genesis 1.8.x Post Class Patch for functions.php. This patch will be safe for Genesis 1.9.x re-write of this function.
<?php
add_action( 'save_post', 'wps_inpost_layout_check', 1 );
/**
* Checks the version of Genesis and executes accordingly.
*
* Executes for Genesis versions less than 1.9.x.
*
* @category Genesis
* @package Admin
* @subpackage Inpost-Metaboxes
*/
function wps_inpost_layout_check() {
if ( version_compare( wp_get_theme()->parent()->Version, '1.9.0' ) < 0 ) {
add_action( 'save_post', 'genesis_inpost_layout_save_patch', 2, 2 );
}
}
/**
* Saves the post class when we save a post / page.
*
* It does so by grabbing the array passed in $_POST.
*
* @category Genesis
* @package Admin
* @subpackage Inpost-Metaboxes
*
*
* @param integer $post_id Post ID
* @param stdClass $post Post object
* @return integer|null Returns post ID if the nonce was not correct or user was not
* allowed to edit content. Returns null if doing autosave, ajax or cron
*/
function genesis_inpost_layout_save_patch( $post_id, $post ) {
/** Don't try to save the data under autosave, ajax, or future post. */
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
return;
if ( defined( 'DOING_CRON' ) && DOING_CRON )
return;
$genesis_custom_post_class = $_POST['_genesis_custom_post_class'];
/** Save custom post class value, or delete if the value is empty */
if ( $genesis_custom_post_class )
update_post_meta( $post_id, '_genesis_custom_post_class', $genesis_custom_post_class );
else
delete_post_meta( $post_id, '_genesis_custom_post_class' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment