Last active
March 2, 2016 09:04
-
-
Save slimndap/50db2b3206f4fdbab1ac to your computer and use it in GitHub Desktop.
Imports the 'LongText' for a newly created production from ActiveTickets. For use with the ActiveTickets for WordPress plugin http://theater.slimndap.com/downloads/activetickets-for-wordpress/.
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 | |
/** | |
* Imports the 'LongText' for a newly created production from ActiveTickets. | |
* | |
* By default, ActiveTicket for WordPress only imports the 'ShortText'. | |
* Importing the 'LongText' requires an extra API call for every production during the import, | |
* which may cause a higher load on the server. | |
* | |
* @param WPT_Production $production The production. | |
* @param object $activetickets_program The production data from ActiveTickets. | |
* @return void | |
*/ | |
function import_activetickets_longtext($production, $activetickets_program) { | |
global $wp_theatre; | |
$method = 'GetProgramDetail'; | |
$resultvar = $method.'Result'; | |
$args = array( | |
"Clientname" => $wp_theatre->activetickets->options['clientname'], | |
"LanguageCode" => 'nl', | |
"ProgramId" => intval($activetickets_program->ProgramId), | |
); | |
$xml = $wp_theatre->activetickets->api($method,$resultvar,$args); | |
if (!empty($xml->Program->Program->LongText)) { | |
$post = array( | |
'ID' => $production->ID, | |
'post_content' => strval( $xml->Program->Program->LongText ), | |
); | |
wp_update_post( $post ); | |
} | |
} | |
add_action('wpt_activetickets_import/create_production', 'import_activetickets_longtext', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment