Example #1
0
/**
 * Displays the JavaScript meta box.
 *
 * @since 0.8
 */
function cleaner_gallery_javascript_meta_box()
{
    $scripts = array('' => '', 'colorbox' => __('Colorbox', 'cleaner-gallery'), 'fancybox' => __('FancyBox', 'cleaner-gallery'), 'fancyzoom' => __('FancyZoom', 'cleaner-gallery'), 'floatbox' => __('Floatbox', 'cleaner-gallery'), 'greybox' => __('GreyBox', 'cleaner-gallery'), 'jquery_lightbox' => __('jQuery Lightbox', 'cleaner-gallery'), 'jquery_lightbox_plugin' => __('jQuery Lightbox Plugin', 'cleaner-gallery'), 'jquery_lightbox_balupton' => __('jQuery Lightbox (Balupton)', 'cleaner-gallery'), 'lightbox' => __('Lightbox', 'cleaner-gallery'), 'lightview' => __('Lightview', 'cleaner-gallery'), 'lightwindow' => __('LightWindow', 'cleaner-gallery'), 'lytebox' => __('Lytebox', 'cleaner-gallery'), 'shadowbox' => __('Shadowbox', 'cleaner-gallery'), 'shutter_reloaded' => __('Shutter Reloaded', 'cleaner-gallery'), 'slimbox' => __('Slimbox', 'cleaner-gallery'), 'thickbox' => __('Thickbox', 'cleaner-gallery'));
    ?>
	<table class="form-table">
		<tr>
			<th><?php 
    _e('About:', 'cleaner-gallery');
    ?>
</th>
			<td>
				<?php 
    _e('If you are using a Lightbox-type image script, this plugin will work along with it.  There are several supported scripts to choose from.', 'cleaner_gallery');
    ?>
			</td>
		</tr>
		<tr>
			<th><?php 
    _e('Image Script:', 'cleaner-gallery');
    ?>
</th>
			<td>
				<select name="image_script" id="image_script">
					<?php 
    foreach ($scripts as $option => $option_name) {
        ?>
						<option value="<?php 
        echo $option;
        ?>
" <?php 
        selected($option, cleaner_gallery_get_setting('image_script'));
        ?>
><?php 
        echo $option_name;
        ?>
</option>
					<?php 
    }
    ?>
				</select>
			</td>
		</tr>
		<tr>
			<th><?php 
    _e('Thickbox:', 'cleaner-gallery');
    ?>
</th>
			<td>
				<input id="thickbox_js" name="thickbox_js" type="checkbox" <?php 
    checked(cleaner_gallery_get_setting('thickbox_js'), true);
    ?>
 value="true" /> 
				<label for="thickbox_js"><?php 
    _e('Auto-load Thickbox JavaScript (included with WordPress)?', 'cleaner-gallery');
    ?>
</label>
				<br />
				<input id="thickbox_css" name="thickbox_css" type="checkbox" <?php 
    checked(cleaner_gallery_get_setting('thickbox_css'), true);
    ?>
 value="true" /> 
				<label for="thickbox_css"><?php 
    _e('Auto-load Thickbox CSS (included with WordPress)?', 'cleaner-gallery');
    ?>
</label>
			</td>
		</tr>
	</table><?php 
}
/**
 * Returns the link class and rel attributes based on what the user selected in the plugin
 * settings.  This is important for handling Lightbox-type image scripts.
 *
 * @since  0.7.0
 * @access public
 * @param  int    $id
 * @return string
 */
function cleaner_gallery_link_attributes($id = 0)
{
    $script = cleaner_gallery_get_setting('image_script');
    if (!array_key_exists($script, cleaner_gallery_get_supported_scripts())) {
        return '';
    }
    switch ($script) {
        case 'lightbox':
        case 'slimbox':
        case 'jquery_lightbox_plugin':
        case 'jquery_lightbox_balupton':
            $class = 'lightbox';
            $rel = "lightbox[cleaner-gallery-{$id}]";
            break;
        case 'colorbox':
            $class = "colorbox colorbox-{$id}";
            $rel = "colorbox-{$id}";
            break;
        case 'jquery_lightbox':
            $class = 'lightbox';
            $rel = "cleaner-gallery-{$id}";
            break;
        case 'lightwindow':
            $class = 'lightwindow';
            $rel = "lightwindow[cleaner-gallery-{$id}]";
            break;
        case 'floatbox':
            $class = 'floatbox';
            $rel = "floatbox.cleaner-gallery-{$id}";
            break;
        case 'shutter_reloaded':
            $class = "shutterset_cleaner-gallery-{$id}";
            $rel = "lightbox[cleaner-gallery-{$id}]";
            break;
        case 'fancybox':
            $class = 'fancybox';
            $rel = "fancybox-{$id}";
            break;
        case 'greybox':
            $class = 'greybox';
            $rel = "gb_imageset[cleaner-gallery-{$id}]";
            break;
        case 'lightview':
            $class = 'lightview';
            $rel = "gallery[cleaner-gallery-{$id}]";
            break;
        case 'lytebox':
            $class = 'lytebox';
            $rel = "lytebox[cleaner-gallery-{$id}]";
            break;
        case 'thickbox':
            $class = 'thickbox';
            $rel = "clean-gallery-{$id}";
            break;
        case 'shadowbox':
            $class = 'shadowbox';
            $rel = "shadowbox[cleaner-gallery-{$id}]";
            break;
        case 'pretty_photo':
            $class = 'prettyPhoto';
            $rel = "prettyPhoto[{$id}]";
            break;
        case 'fancyzoom':
        default:
            $class = '';
            $rel = '';
            break;
    }
    $class = apply_filters('cleaner_gallery_image_link_class', $class);
    $rel = apply_filters('cleaner_gallery_image_link_rel', $rel);
    $class = !empty($class) ? " class='{$class}'" : '';
    $rel = !empty($rel) ? " rel='{$rel}'" : '';
    return $class . $rel;
}
 /**
  * Enqueues scripts and styles on the front end.
  *
  * @since  1.0.0
  * @access public
  * @return void
  */
 public function enqueue_scripts()
 {
     if (cleaner_gallery_get_setting('thickbox_js')) {
         wp_enqueue_script('thickbox');
     }
     if (cleaner_gallery_get_setting('thickbox_css')) {
         wp_enqueue_style('thickbox');
     }
 }
Example #4
0
/**
 * Displays the settings page for the plugin.
 *
 * @since  0.9.0
 * @access public
 * @return void
 */
function cleaner_gallery_settings_page()
{
    /* Set up some default empty variables. */
    $size_field = '';
    $image_link_field = '';
    $orderby_field = '';
    $order_field = '';
    /* Get the available image sizes. */
    foreach (get_intermediate_image_sizes() as $size) {
        $image_sizes[$size] = $size;
    }
    $image_sizes = array_merge($image_sizes, array('thumbnail' => __('Thumbnail', 'cleaner-gallery'), 'medium' => __('Medium', 'cleaner-gallery'), 'large' => __('Large', 'cleaner-gallery'), 'full' => __('Full', 'cleaner-gallery')));
    /* WP filter. */
    $image_sizes = apply_filters('image_size_names_choose', $image_sizes);
    /* Set up an array items that gallery items can link to. */
    $image_link = array_merge(array('none' => __('No image or page', 'cleaner-gallery'), '' => __('Attachment Page', 'cleaner-gallery')), $image_sizes);
    /* Set up an array of orderby options. */
    $orderby_options = array('comment_count' => __('Comment Count', 'cleaner-gallery'), 'date' => __('Date', 'cleaner-gallery'), 'ID' => __('ID', 'cleaner-gallery'), 'menu_order ID' => __('Menu Order', 'cleaner-gallery'), 'none' => __('None', 'cleaner-gallery'), 'rand' => __('Random', 'cleaner-gallery'), 'title' => __('Title', 'cleaner-gallery'));
    /* Set up an array of ordering options. */
    $order_options = array('ASC' => __('Ascending', 'cleaner-gallery'), 'DESC' => __('Descending', 'cleaner_gallery'));
    /* Set up an array of supported Lightbox-type scripts the plugin supports. */
    $scripts = cleaner_gallery_get_supported_scripts();
    /* === Set up form fields for use inline with text. === */
    /* Set up the image size select element. */
    foreach ($image_sizes as $size => $label) {
        $size_field .= '<option value="' . esc_attr($size) . '" ' . selected($size, cleaner_gallery_get_setting('size'), false) . '>' . esc_html($label) . '</option>';
    }
    $size_field = '<select name="cleaner_gallery_settings[size]" id="size">' . $size_field . '</select>';
    /* Set up the image link select element. */
    foreach ($image_link as $option => $option_name) {
        $image_link_field .= '<option value="' . esc_attr($option) . '" ' . selected($option, cleaner_gallery_get_setting('image_link'), false) . '>' . esc_html($option_name) . '</option>';
    }
    $image_link_field = '<select id="image_link" name="cleaner_gallery_settings[image_link]">' . $image_link_field . '</select>';
    /* Set up the orderby select element. */
    foreach ($orderby_options as $option => $option_name) {
        $orderby_field .= '<option value="' . esc_attr($option) . '" ' . selected($option, cleaner_gallery_get_setting('orderby'), false) . '>' . esc_html($option_name) . '</option>';
    }
    $orderby_field = '<select name="cleaner_gallery_settings[orderby]" id="orderby">' . $orderby_field . '</select>';
    /* Set up the order select element. */
    foreach ($order_options as $option => $option_name) {
        $order_field .= '<option value="' . esc_attr($option) . '" ' . selected($option, cleaner_gallery_get_setting('order'), false) . '>' . esc_html($option_name) . '</option>';
    }
    $order_field = '<select name="cleaner_gallery_settings[order]" id="order">' . $order_field . '</select>';
    ?>

	<div class="wrap">

		<?php 
    screen_icon();
    ?>

		<h2><?php 
    _e('Cleaner Gallery Settings', 'cleaner-gallery');
    ?>
</h2>

		<?php 
    if (isset($_GET['updated']) && 'true' == esc_attr($_GET['updated'])) {
        echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>' . __('Settings saved.', 'cleaner-gallery') . '</strong></p></div>';
    }
    ?>

		<form action="<?php 
    echo admin_url('options.php');
    ?>
" method="post">

			<?php 
    settings_fields('cleaner_gallery_settings');
    ?>

			<table class="form-table">

				<tr>
					<th><?php 
    _e('Default gallery settings', 'cleaner-gallery');
    ?>
</th>
					<td>
						<?php 
    printf(__('Display %s size images by default.', 'cleaner-gallery'), $size_field);
    ?>
						<br />
						<?php 
    printf(__('Images should link to %s by default.', 'cleaner-gallery'), $image_link_field);
    ?>
						<br />
						<?php 
    printf(__('Galleries should be ordered by %s by default.', 'cleaner-gallery'), $orderby_field);
    ?>
						<br />
						<?php 
    printf(__('Display gallery images in %s order by default.', 'cleaner-gallery'), $order_field);
    ?>
						<br />
						<p class="description">
							<?php 
    _e('(These settings may be overriden for individual galleries.)', 'cleaner-gallery');
    ?>
						</p>
					</td>
				</tr>

				<tr>
					<th><?php 
    _e('Image caption settings', 'cleaner-gallery');
    ?>
</th>
					<td>
						<input id="caption_remove" name="cleaner_gallery_settings[caption_remove]" type="checkbox" <?php 
    checked(cleaner_gallery_get_setting('caption_remove') ? true : false, true);
    ?>
 value="true" /> 
						<label for="caption_remove"><?php 
    _e('Completely remove image captions (overrules other caption settings).', 'cleaner-gallery');
    ?>
</label>
						<br />
						<input id="caption_title" name="cleaner_gallery_settings[caption_title]" type="checkbox" <?php 
    checked(cleaner_gallery_get_setting('caption_title') ? true : false, true);
    ?>
 value="true" /> 
						<label for="caption_title"><?php 
    _e('Use the image title as a caption if there is no caption available.', 'cleaner-gallery');
    ?>
</label>
					</td>
				</tr>

				<tr>
					<th><?php 
    _e('Script and style settings', 'cleaner-gallery');
    ?>
</th>
					<td>
						<input id="thickbox_js" name="cleaner_gallery_settings[thickbox_js]" type="checkbox" <?php 
    checked(cleaner_gallery_get_setting('thickbox_js') ? true : false, true);
    ?>
 value="true" /> 
						<label for="thickbox_js"><?php 
    _e('Load the Thickbox JavaScript (included with WordPress).', 'cleaner-gallery');
    ?>
</label>
						<br />
						<input id="thickbox_css" name="cleaner_gallery_settings[thickbox_css]" type="checkbox" <?php 
    checked(cleaner_gallery_get_setting('thickbox_css') ? true : false, true);
    ?>
 value="true" /> 
						<label for="thickbox_css"><?php 
    _e('Load the Thickbox stylesheet (included with WordPress).', 'cleaner-gallery');
    ?>
</label>
					</td>
				</tr>

				<tr>
					<th><?php 
    _e('External image script', 'cleaner-gallery');
    ?>
</th>
					<td>
						<select name="cleaner_gallery_settings[image_script]" id="image_script">
							<option value=""></option>
							<?php 
    foreach ($scripts as $option => $option_name) {
        ?>
								<option value="<?php 
        echo $option;
        ?>
" <?php 
        selected($option, cleaner_gallery_get_setting('image_script'));
        ?>
><?php 
        echo $option_name;
        ?>
</option>
							<?php 
    }
    ?>
						</select>
						<br />
						<p class="description">
							<?php 
    _e('The use, installation, and configuration of third-party image scripts are not supported by the Cleaner Gallery plugin developer. Please contact the image script developer for help using your preferred script.', 'cleaner-gallery');
    ?>
						</p>
					</td>
				</tr>

				<tr>
					<th><?php 
    _e('Like this plugin?', 'cleaner-gallery');
    ?>
</th>
					<td>
						<p><?php 
    _e("Here's how you can give back:", 'cleaner-gallery');
    ?>
</p>
						<ul>
							<li><a href="http://wordpress.org/support/view/plugin-reviews/cleaner-gallery#postform"><?php 
    _e('Give the plugin a good rating.', 'cleaner-gallery');
    ?>
</a></li>
							<li><a href="http://themehybrid.com/donate"><?php 
    _e('Donate to the project.', 'cleaner-gallery');
    ?>
</a></li>
						</ul>
					</td>
				</tr>
			</table>

			<?php 
    submit_button(esc_attr__('Update Settings', 'cleaner-gallery'), 'button-primary', 'submit');
    ?>

		</form>
	</div>
<?php 
}
/**
 * Load the Thickbox JavaScript if needed.
 *
 * @since 0.8.0
 */
function cleaner_gallery_enqueue_script()
{
    if (cleaner_gallery_get_setting('thickbox_js')) {
        wp_enqueue_script('thickbox');
    }
}