Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Custom XML file to be read by Flash SWF
- * Install : wp-content/gallery.xml.php
- * Description : Grabs two custom fields from post 101 and generates a configuration XML file
- * Dependencies : must adjust wp-load.php path in case this file is not inside wp-content/
- * Usage : within Flash, call this XML generator and assign the correct POST_ID: "http://yourdomain.com/wp-content/gallery.xml.php?id=POST_ID"
- * Observations: pay attention to the use of single and double quotes within the $xml variable
- */
- require_once "../wp-load.php";
- $id = intval($_GET['id']);
- function GetGallery($idi){
- $idi = intval($idi);
- $img = array();
- $results = get_children( array(
- 'post_parent' => $idi,
- 'post_status' => 'inherit',
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'order' => 'ASC',
- 'orderby' => 'menu_order') );
- foreach ( $results as $imagem )
- {
- $pic=wp_get_attachment_image_src( $imagem->ID, 'medium' );
- $title = $imagem->post_title;
- $txt = $imagem->post_content;
- $img[] = array('href' => $pic[0], 'title' => $title, 'txt' => $txt);
- }
- return $img;
- }
- $GAL = GetGallery($id);
- $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
- $xml .= '<gallery>' . "\n\n";
- $xml .= '<options>' . "\n\n";
- $xml .= ' <name>ONE OF MANY</name>' . "\n\n";
- $xml .= '</options>' . "\n\n";
- $xml .= '<pictures>' . "\n\n";
- foreach($GAL as $jpg) {
- $xml .= ' <pic>' . "\n";
- $xml .= ' <bigimage>' . $jpg['href'] . '</bigimage>' ."\n";
- $xml .= ' <info title="'. $jpg['title'] .'" desc="'. $jpg['txt'] .'" />' . "\n";
- $xml .= ' </pic>' . "\n\n";
- }
- $xml .= '</pictures>' . "\n\n";
- $xml .= '</gallery>';
- echo $xml;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement