Created
August 12, 2012 19:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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