Exemple #1
0
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
/**
 * Defining Variables
 */
ini_set('default_socket_timeout', 10);
$videogall_url = plugin_dir_url(__FILE__);
$videogall_path = plugin_dir_path(__FILE__);
$videogall_db_version = "3.1";
/**
 * Calling required functions & pages
 */
require $videogall_path . 'inc/videogall-functions.php';
require $videogall_path . 'admin/plugin-options.php';
$videogall_options = videogall_get_options();
/**
 * Embedding necessary javascripts & stylesheets
 */
function videogall_enqueue_scripts()
{
    global $videogall_url;
    wp_enqueue_script('jquery');
    wp_enqueue_script('videogall-js', $videogall_url . 'js/videogall.js', 'jquery');
    /* No se utilizaran, el theme ya los contienen
        wp_enqueue_script('videogall-fancybox-js', $videogall_url.'inc/fancybox/jquery.fancybox.pack.js', 'jquery');
        wp_enqueue_script('videogall-fancybox-js', $videogall_url.'inc/fancybox/jquery.easing-1.3.pack.js', 'jquery');
        wp_enqueue_script('videogall-fancybox-js', $videogall_url.'inc/fancybox/jquery.mousewheel-3.0.4.pack.js', 'jquery');
        wp_enqueue_style('videogall-fancybox-css', $videogall_url.'inc/fancybox/jquery.fancybox-1.3.4.css', false, false, 'all');
    	*/
    wp_enqueue_style('videogall-css', $videogall_url . 'css/videogall.css', false, false, 'all');
/**
 * Display the options page
 */
function videogall_options_page()
{
    global $videogall_url;
    if (isset($_POST['settings-reset'])) {
        delete_option('videogall_options');
        add_settings_error('videogall_options', 'reset', __('Default settings restored', 'videogall'), 'updated');
    }
    ?>
    <div id="settings-wrap">
        <h1 class="settings-title"><img src="<?php 
    echo $videogall_url;
    ?>
admin/images/options.png"/><?php 
    _e('Videogall Settings', 'videogall');
    ?>
</h1>
        <form method="post" id="settings-form" action="options.php">
            <?php 
    settings_fields('videogall_options');
    $videogall_options = videogall_get_options();
    $videogall_default_options = videogall_get_default_options();
    ?>
            <div class="settings-fields-wrap">
                <div class="settings-nav">
                    <?php 
    $first = true;
    foreach (videogall_options_tabs() as $entry) {
        if ($first) {
            $current_class = " current-tab";
        } else {
            $current_class = "";
        }
        echo '<a class="tab' . $current_class . '" id="tab-' . $entry['value'] . '" href="javascript:void(0)"><img src="' . $videogall_url . 'admin/images/tab_' . $entry['value'] . '.png"/>' . $entry['label'] . '</a>';
        $first = false;
    }
    ?>
                </div>
                <div class="settings-fields">
                    <?php 
    settings_errors();
    ?>
                    <div class="section current-section" id="section-1">
                        <p>
                            <?php 
    $videos = videogall_get_results("videogall_videos");
    foreach ($videos as $entry) {
        ?>
			    <div class="edit-video">
				<img class="edit-video-item" id="edit-video-item-<?php 
        echo $entry['id'];
        ?>
" height="150" src="<?php 
        echo $entry['thumbnail'];
        ?>
"/>
				<div class="edit-links">
				    <a class="edit" id="edit-<?php 
        echo $entry['id'];
        ?>
" href="javascript:void(0)"><?php 
        _e('Edit', 'videogall');
        ?>
</a>
				    <input class="delete" type="submit" name="delete-<?php 
        echo $entry['id'];
        ?>
" id="delete-<?php 
        echo $entry['id'];
        ?>
" value="<?php 
        _e('Delete', 'videogall');
        ?>
"/>
				</div>
			    </div>
			    <div class="edit-video-form" id="edit-video-form-<?php 
        echo $entry['id'];
        ?>
">
				<div class="edit-video-form-wrap">
				    <p>
					<strong><?php 
        _e('Video url *', 'videogall');
        ?>
</strong>&nbsp;&nbsp;&nbsp;
					<input type="text" name="edit-video-url-<?php 
        echo $entry['id'];
        ?>
" id="edit-video-url-<?php 
        echo $entry['id'];
        ?>
" value="<?php 
        echo $entry['url'];
        ?>
"/>
				    </p>
				    <p>
					<strong><?php 
        _e('Video thumbnail', 'videogall');
        ?>
</strong>&nbsp;&nbsp;&nbsp;
					<input type="text" name="edit-video-thumb-<?php 
        echo $entry['id'];
        ?>
" id="edit-video-thumb-<?php 
        echo $entry['id'];
        ?>
" value="<?php 
        echo $entry['thumbnail'];
        ?>
"/>
					<input id="edit-video-thumb-<?php 
        echo $entry['id'];
        ?>
_upload" type="button" class="button-secondary image_upload" value="<?php 
        _e('Upload thumbnail', 'videogall');
        ?>
" />
				    </p>
				    <p>
					<strong><?php 
        _e('Video category', 'videogall');
        ?>
</strong>&nbsp;&nbsp;&nbsp;
					<select name="edit-video-category-<?php 
        echo $entry['id'];
        ?>
" id="edit-video-category-<?php 
        echo $entry['id'];
        ?>
">
					    <option value="0"><?php 
        _e('Uncategorized', 'videogall');
        ?>
</option>
					    <?php 
        $categories = videogall_get_results("videogall_categories");
        foreach ($categories as $cat) {
            if ($cat['id'] == $entry['category']) {
                $selected = "selected";
            } else {
                $selected = "";
            }
            ?>
					    <option value="<?php 
            echo $cat['id'];
            ?>
"<?php 
            echo $selected;
            ?>
><?php 
            echo ucwords($cat['name']);
            ?>
</option>
					    <?php 
        }
        ?>
					</select>
				    </p>
				    <p>
					<strong><?php 
        _e('Video caption', 'videogall');
        ?>
</strong>&nbsp;&nbsp;&nbsp;
					<input type="text" name="edit-video-caption-<?php 
        echo $entry['id'];
        ?>
" id="edit-video-caption-<?php 
        echo $entry['id'];
        ?>
" value="<?php 
        echo $entry['caption'];
        ?>
"/>
				    </p>
				    <p>
					<strong><?php 
        _e('Video description', 'videogall');
        ?>
</strong>&nbsp;&nbsp;&nbsp;
					<textarea rows="3" cols="60" style="vertical-align:middle;" name="edit-video-description-<?php 
        echo $entry['id'];
        ?>
" id="edit-video-description-<?php 
        echo $entry['id'];
        ?>
"><?php 
        echo $entry['description'];
        ?>
</textarea>
				    </p>
				    <?php 
        submit_button(__('Save Video Changes', 'videogall'), 'primary edit-video-submit edit-video-submit-' . $entry['id'], 'edit-video-submit');
        ?>
				    <img class="edit-close" src="<?php 
        echo $videogall_url;
        ?>
admin/images/close_btn.png"/>
				</div>
			    </div>
			    <?php 
    }
    ?>
			    <input type="hidden" name="edit-id" id="edit-id" value=""/>
			    <input type="hidden" name="delete-id" id="delete-id" value=""/>
                        </p>
                    </div>
		    <div class="section" id="section-2">
                        <p>
                            <label><?php 
    _e('Add video url *', 'videogall');
    ?>
</label>
			    <input type="text" name="add-video-url" id="add-video-url" value=""/>
                        </p>
			<p>
                            <label><?php 
    _e('Select video category', 'videogall');
    ?>
</label>
			    <select name="add-video-category" id="add-video-category">
				<option value="0"><?php 
    _e('Uncategorized', 'videogall');
    ?>
</option>
				<?php 
    $categories = videogall_get_results("videogall_categories");
    foreach ($categories as $entry) {
        ?>
				<option value="<?php 
        echo $entry['id'];
        ?>
"><?php 
        echo ucwords($entry['name']);
        ?>
</option>
				<?php 
    }
    ?>
			    </select>
                        </p>
			<p>
			    <label><?php 
    _e('Add video thumbnail', 'videogall');
    ?>
</label>
			    <input type="text" name="add-video-thumb" id="add-video-thumb" value=""/>
			    <input id="add-video-thumb_upload" type="button" class="button-secondary image_upload" value="<?php 
    _e('Upload thumbnail', 'videogall');
    ?>
" />
			</p>
			<p>
			    <label><?php 
    _e('Add video caption', 'videogall');
    ?>
</label>
			    <input type="text" name="add-video-caption" id="add-video-caption" value=""/>
			</p>
			<p>
			    <label><?php 
    _e('Add video description', 'videogall');
    ?>
</label>
			    <textarea rows="3" cols="60" name="add-video-description" id="add-video-description"></textarea>
			</p>
			<p><?php 
    submit_button(__('Add new video', 'videogall'), 'primary', 'add-video-submit');
    ?>
</p>
                    </div>
		    <div class="section" id="section-3">
                        <p>
			    <label><?php 
    _e('Add category name *', 'videogall');
    ?>
</label>
			    <input type="text" name="add-category-name" id="add-category-name" value=""/>
			    <?php 
    submit_button(__('Add new category', 'videogall'), 'primary', 'add-category-submit');
    ?>
			</p>
			<p>
			    <label><?php 
    _e('Update or Delete category', 'videogall');
    ?>
</label>
			    <select name="update-video-category" id="update-video-category">
				<option value="0"><?php 
    _e('Select category', 'videogall');
    ?>
</option>
			    <?php 
    $categories = videogall_get_results("videogall_categories");
    foreach ($categories as $entry) {
        ?>
				<option value="<?php 
        echo $entry['id'];
        ?>
"><?php 
        echo $entry['name'];
        ?>
</option>
			    <?php 
    }
    ?>
			    </select>
			    <span id="update-cat-section"><input type="text" name="update-category-name" id="update-category-name" value=""/><input type="submit" name="update-category-submit" id="update-category-submit" class="button-primary" value="<?php 
    _e('Rename category', 'videogall');
    ?>
"/></span>
			    <?php 
    submit_button(__('Delete category', 'videogall'), 'primary', 'delete-category-submit');
    ?>
			</p>
                    </div>
		    <div class="section" id="section-4">
                        <p>
			    <label><?php 
    _e('Number of columns', 'videogall');
    ?>
</label>
			    <select name="videogall_options[number_of_columns]">
				<?php 
    foreach (videogall_column_list() as $entry) {
        ?>
				    <option value="<?php 
        echo $entry['value'];
        ?>
" <?php 
        selected($videogall_options['number_of_columns'], $entry['value']);
        ?>
><?php 
        echo $entry['label'];
        ?>
</option>
				<?php 
    }
    ?>
			    </select>
			</p>
			<p>
			    <label><?php 
    _e('Video Size', 'videogall');
    ?>
</label>
			    <select name="videogall_options[video_size]">
				<?php 
    foreach (videogall_video_size_list() as $entry) {
        ?>
				    <option value="<?php 
        echo $entry['value'];
        ?>
" <?php 
        selected($videogall_options['video_size'], $entry['value']);
        ?>
><?php 
        echo $entry['label'];
        ?>
</option>
				<?php 
    }
    ?>
			    </select>
			</p>
			<p>
			    <label><?php 
    _e('Enable Pagination ?', 'videogall');
    ?>
</label>
			    <input type="checkbox" name="videogall_options[enable_pagination]" value="false" <?php 
    checked(true, $videogall_options['enable_pagination']);
    ?>
 />
			</p>
			<p>
			    <label><?php 
    _e('Videos Per Page', 'videogall');
    ?>
</label>
			    <input type="text" name="videogall_options[videos_per_page]" value="<?php 
    echo esc_attr($videogall_options['videos_per_page']);
    ?>
"/>
			</p>
			<p>
			    <label><?php 
    _e('Show categories', 'videogall');
    ?>
</label>
			    <input type="checkbox" name="videogall_options[show_categories]" value="false" <?php 
    checked(true, $videogall_options['show_categories']);
    ?>
 />
			</p>
			<p>
			    <label><?php 
    _e('Sort videos by category', 'videogall');
    ?>
</label>
			    <input type="checkbox" name="videogall_options[sort_by_category]" value="false" <?php 
    checked(true, $videogall_options['sort_by_category']);
    ?>
 />
			</p>
			<p>
			    <label><?php 
    _e('Video Order', 'videogall');
    ?>
</label>
			    <select name="videogall_options[video_order]">
				<?php 
    foreach (videogall_video_order_list() as $entry) {
        ?>
				    <option value="<?php 
        echo $entry['value'];
        ?>
" <?php 
        selected($videogall_options['video_order'], $entry['value']);
        ?>
><?php 
        echo $entry['label'];
        ?>
</option>
				<?php 
    }
    ?>
			    </select>
			</p>
			<p>
			    <label><?php 
    _e('Show border around thumbnail', 'videogall');
    ?>
</label>
			    <input type="checkbox" name="videogall_options[enable_border]" value="false" <?php 
    checked(true, $videogall_options['enable_border']);
    ?>
 />
			</p>
			<p>
			    <label><?php 
    _e('Border Color', 'videogall');
    ?>
</label>
			    <input type="text" class="color" name="videogall_options[border_color]" value="<?php 
    echo esc_attr($videogall_options['border_color']);
    ?>
"/>
			</p>
			<p>
			    <label><?php 
    _e('Use shadowbox for images', 'videogall');
    ?>
</label>
			    <input type="checkbox" name="videogall_options[shadowbox_images]" value="false" <?php 
    checked(true, $videogall_options['shadowbox_images']);
    ?>
 />
			</p>
			<p>
			    <label><?php 
    _e('Autoplay videos on launch ?', 'videogall');
    ?>
</label>
			    <input type="checkbox" name="videogall_options[autoplay]" value="false" <?php 
    checked(true, $videogall_options['autoplay']);
    ?>
 />
			</p>
			<?php 
    submit_button();
    ?>
                    </div>
                </div>
            </div>
        </form>
        <div class="settings-bottom-bar">
	    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" id="paypal-form">
		    <input type="hidden" name="cmd" value="_s-xclick">
		    <input type="hidden" name="hosted_button_id" value="NR5ENJ5DRLHJN">
		    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="<?php 
    _e('PayPal - The safer, easier way to pay online!', 'videogall');
    ?>
">
		    <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
	    </form>
            <form method="post" id="settings-reset-form">
                <input type="submit" class="button-secondary" name="settings-reset" id="settings-reset" value="<?php 
    _e('Reset Settings', 'videogall');
    ?>
" />
            </form>
        </div>
    </div>
    <?php 
}