/** * Check if swiftylib classes are needed and find newest version of lib before instantiating * * @param $class_name */ function swifty_autoload_function($class_name) { if ($class_name === 'LibSwiftyPlugin') { swifty_autoload_lib_helper_main('/php/lib_swifty_plugin.php'); if (is_null(LibSwiftyPlugin::get_instance())) { new LibSwiftyPlugin(); } } if ($class_name === 'LibSwiftyPluginView') { swifty_autoload_lib_helper_main('/php/lib_swifty_plugin_view.php'); if (is_null(LibSwiftyPluginView::get_instance())) { new LibSwiftyPluginView(); } } }
/** * @param integer $post_id * @param string $post_status */ protected function _update_post_status($post_id, $post_status) { if ($this->is_swifty && $post_status === 'publish') { // use autosave content when publishing, remove autosave (no newer autosave record) $autosave_content = LibSwiftyPluginView::get_instance()->get_autosave_version_if_newer($post_id); $post_data = array('ID' => $post_id, 'post_status' => $post_status); if ($autosave_content) { $post_data['post_content'] = $autosave_content; } wp_update_post($post_data); } else { // remember current autosave LibSwiftyPlugin::get_instance()->wp_update_post_keep_autosave($post_id, array('ID' => $post_id, 'post_status' => $post_status)); } }