/** * Modal window post edit shortcode output */ function cvm_post_edit_modal() { global $post, $CVM_POST_TYPE; if (!$post || $CVM_POST_TYPE->get_post_type() == $post->post_type) { return; } $options = cvm_get_player_settings(); ?> <div id="CVMVideo_Modal_Window" style="display:none;"> <div class="wrap"> <div id="cvm-playlist-items"> <div class="inside"> <h2><?php _e('Playlist settings', 'cvm_video'); ?> </h2> <div id="cvm-playlist-settings" class="cvm-player-settings-options"> <table> <tr> <th><label for="cvm_playlist_theme"><?php _e('Theme', 'cvm_video'); ?> :</label></th> <td> <?php $playlist_themes = cvm_playlist_themes(); cvm_select(array('name' => 'cvm_playlist_theme', 'id' => 'cvm_playlist_theme', 'options' => $playlist_themes)); ?> </td> </tr> <tr> <th><label for="cvm_aspect_ratio"><?php _e('Aspect', 'cvm_video'); ?> :</label></th> <td> <?php $args = array('options' => array('4x3' => '4x3', '16x9' => '16x9'), 'name' => 'aspect_ratio', 'id' => 'aspect_ratio', 'class' => 'cvm_aspect_ratio'); cvm_select($args); ?> </td> </tr> <tr> <th><label for="width"><?php _e('Width', 'cvm_video'); ?> :</label></th> <td> <input type="text" class="cvm_width" name="width" id="width" value="<?php echo $options['width']; ?> " size="2" />px | <?php _e('Height', 'cvm_video'); ?> : <span class="cvm_height" id="cvm_calc_height"><?php echo cvm_player_height($options['aspect_ratio'], $options['width']); ?> </span>px </td> </tr> <tr> <th><label for="volume"><?php _e('Volume', 'cvm_video'); ?> </label>:</th> <td> <input type="text" name="volume" id="volume" value="<?php echo $options['volume']; ?> " size="1" maxlength="3" /> <label for="volume"><span class="description"><?php _e('number between 0 (mute) and 100 (max)', 'cvm_video'); ?> </span></label> </td> </tr> </table> <input type="button" id="cvm-insert-playlist-shortcode" class="button primary" value="<?php _e('Insert playlist', 'cvm_video'); ?> " /> </div> <input type="hidden" name="cvm_selected_items" value="" /> <h2><?php _e('Videos in playlist', 'cvm_video'); ?> </h2> <div id="cvm-list-items"> <em><?php _e('No video selected', 'cvm_video'); ?> <br /><?php _e('To create a playlist check some videos from the list on the right.', 'cvm_video'); ?> </em> </div> </div> </div> <div id="cvm-display-videos"> <iframe src="edit.php?post_type=<?php echo $CVM_POST_TYPE->get_post_type(); ?> &page=cvm_videos" frameborder="0" width="100%" height="100%"></iframe> </div> </div> </div> <?php }
function cvm_output_playlist($videos = 'latest', $results = 5, $theme = 'default', $player_settings = array()) { global $CVM_POST_TYPE; $args = array('post_type' => $CVM_POST_TYPE->get_post_type(), 'posts_per_page' => absint($results), 'numberposts' => absint($results), 'post_status' => 'publish', 'supress_filters' => true); // if $videos is array, the function was called with an array of video ids if (is_array($videos)) { $ids = array(); foreach ($videos as $video_id) { $ids[] = absint($video_id); } $args['include'] = $ids; $args['posts_per_page'] = count($ids); $args['numberposts'] = count($ids); } elseif (is_string($videos)) { $found = false; switch ($videos) { case 'latest': $args['orderby'] = 'post_date'; $args['order'] = 'DESC'; $found = true; break; } if (!$found) { return; } } else { // if $videos is anything else other than array or string, bail out return; } // get video posts $posts = get_posts($args); if (!$posts) { return; } $videos = array(); foreach ($posts as $post_key => $post) { if (isset($ids)) { $key = array_search($post->ID, $ids); } else { $key = $post_key; } if (is_numeric($key)) { $videos[$key] = array('ID' => $post->ID, 'title' => $post->post_title, 'video_data' => get_post_meta($post->ID, '__cvm_video_data', true)); } } ksort($videos); ob_start(); // set custom player settings if any global $CVM_PLAYER_SETTINGS; if ($player_settings && is_array($player_settings)) { $defaults = cvm_get_player_settings(); foreach ($defaults as $setting => $value) { if (isset($player_settings[$setting]) && !empty($player_settings[$setting])) { $defaults[$setting] = $player_settings[$setting]; } } $CVM_PLAYER_SETTINGS = $defaults; } global $cvm_video; if (!array_key_exists($theme, cvm_playlist_themes())) { $theme = 'default'; } $file = CVM_PATH . 'themes/' . $theme . '/player.php'; if (!is_file($file)) { $theme = 'default'; } include CVM_PATH . 'themes/' . $theme . '/player.php'; $content = ob_get_contents(); ob_end_clean(); cvm_enqueue_player(); wp_enqueue_script('cvm-vim-player-' . $theme, CVM_URL . 'themes/' . $theme . '/assets/script.js', array('cvm-video-player'), '1.0'); wp_enqueue_style('cvm-vim-player-' . $theme, CVM_URL . 'themes/' . $theme . '/assets/stylesheet.css', false, '1.0'); // remove custom player settings $CVM_PLAYER_SETTINGS = false; return $content; }