Ejemplo n.º 1
0
 public static function admin_enqueue_scripts()
 {
     self::wp_enqueue_scripts();
     // Enqueue all transition scripts for live preview.
     foreach (TpsOptions::getTransitionEffects() as $key => $value) {
         self::enqueueTransition($key);
     }
     // CSS, even if there is no theme, so we can change the path via JS.
     if (TpsOptions::get('theme') == 'none') {
         wp_register_style('theiaPostSlider', TPS_PLUGINS_URL . 'css/' . TpsOptions::get('theme'), TPS_VERSION);
         wp_enqueue_style('theiaPostSlider');
     }
     // Admin CSS
     wp_register_style('theiaPostSlider-admin', TPS_PLUGINS_URL . 'css/admin.css', TPS_VERSION);
     wp_enqueue_style('theiaPostSlider-admin');
 }
Ejemplo n.º 2
0
 public static function initOptions()
 {
     $defaults = array('tps_general' => array('transition_effect' => 'slide', 'transition_speed' => 400, 'theme' => 'buttons-orange.css'), 'tps_nav' => array('navigation_text' => '%{currentSlide} of %{totalSlides}', 'helper_text' => 'Use your ← → (arrow) keys to browse', 'prev_text' => 'Prev', 'next_text' => 'Next', 'button_width' => 0, 'prev_text_post' => 'Prev post', 'next_text_post' => 'Next post', 'button_width_post' => 0, 'post_navigation' => false, 'post_navigation_same_category' => false, 'refresh_page_on_slide' => false, 'nav_horizontal_position' => 'right', 'nav_vertical_position' => 'top_and_bottom', 'enable_on_pages' => false));
     foreach ($defaults as $groupId => $groupValues) {
         $options = get_option($groupId);
         $changed = false;
         // Add missing options
         foreach ($groupValues as $key => $value) {
             if (isset($options[$key]) == false) {
                 $changed = true;
                 $options[$key] = $value;
             }
         }
         // Validate options
         if ($groupId == 'tps_general') {
             if (array_key_exists($options['transition_effect'], TpsOptions::getTransitionEffects()) == false) {
                 $options['transition_effect'] = $groupValues['transition_effect'];
                 $changed = true;
             }
             if ($options['transition_speed'] < 0) {
                 $options['transition_speed'] = $groupValues['transition_speed'];
                 $changed = true;
             }
         }
         if ($groupId == 'tps_nav') {
             if ($options['button_width'] < 0) {
                 $options['button_width'] = $groupValues['button_width'];
                 $changed = true;
             }
         }
         // Save options
         if ($changed) {
             update_option($groupId, $options);
         }
     }
 }
Ejemplo n.º 3
0
    public function echoPage()
    {
        ?>
		<form method="post" action="options.php">
			<?php 
        settings_fields('tps_options_nav');
        ?>
			<?php 
        $options = get_option('tps_nav');
        ?>
			<h3><?php 
        _e("Navigation Bar Settings", 'theia-post-slider');
        ?>
</h3>
			<table class="form-table">
				<tr valign="top">
					<th scope="row">
						<label for="tps_navigation_text"><?php 
        _e("Navigation text:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_navigation_text" name="tps_nav[navigation_text]" value="<?php 
        echo $options['navigation_text'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
						<p class="description">Variables: <b>%{currentSlide}</b> and <b>%{totalSlides}</b></p>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_helper_text"><?php 
        _e("Helper text:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_helper_text" name="tps_nav[helper_text]" value="<?php 
        echo $options['helper_text'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_prev_button_text"><?php 
        _e("Previous button text:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_prev_button_text" name="tps_nav[prev_text]" value="<?php 
        echo $options['prev_text'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_next_button_text"><?php 
        _e("Next button text:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_next_button_text" name="tps_nav[next_text]" value="<?php 
        echo $options['next_text'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_button_width"><?php 
        _e("Button width (px):", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_button_width" name="tps_nav[button_width]" value="<?php 
        echo $options['button_width'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
						<p class="description">Use this if you want both buttons to have the same width. Insert "0" for no fixed width.</p>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_nav_horizontal_position"><?php 
        _e("Horizontal position:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<select id="tps_nav_horizontal_position" name="tps_nav[nav_horizontal_position]" onchange="updateSlider()">
							<?php 
        foreach (TpsOptions::getButtonHorizontalPositions() as $key => $value) {
            $output = '<option value="' . $key . '"' . ($key == $options['nav_horizontal_position'] ? ' selected' : '') . '>' . $value . '</option>' . "\n";
            echo $output;
        }
        ?>
						</select>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_nav_vertical_position"><?php 
        _e("Vertical position:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<select id="tps_nav_vertical_position" name="tps_nav[nav_vertical_position]" onchange="updateSlider()">
							<?php 
        foreach (TpsOptions::getButtonVerticalPositions() as $key => $value) {
            $output = '<option value="' . $key . '"' . ($key == $options['nav_vertical_position'] ? ' selected' : '') . '>' . $value . '</option>' . "\n";
            echo $output;
        }
        ?>
						</select>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label><?php 
        _e("Button behavior:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<label>
							<input type="checkbox" name="tps_nav[refresh_page_on_slide]" value="true"<?php 
        echo $options['refresh_page_on_slide'] ? ' checked' : '';
        ?>
> Refresh page on each slide
						</label>
						<p class="description">The page will refresh on each displayed slide. This is useful, for example, if you want your ads to reload on each slide. Transition effects cannot be used with this option.</p>

						<label>
							<input type="checkbox" name="tps_nav[enable_on_pages]" value="true"<?php 
        echo $options['enable_on_pages'] ? ' checked' : '';
        ?>
> Enable slider on pages
						</label>
						<p class="description">By default, the slider is enabled only on <b>posts</b>. This will enable it also on <b>pages</b>. Note that some themes may be incompatible with this option.</p>
					</td>
				</tr>
			</table>

			<h3><?php 
        _e("Post Navigation", 'theia-post-slider');
        ?>
</h3>
			<table class="form-table">
				<tr valign="top">
					<th scope="row">
						<label><?php 
        _e("Button behavior:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<label>
							<input id="tps_post_navigation" onchange="updatePostNavigation()" type="checkbox" name="tps_nav[post_navigation]" value="true"<?php 
        echo $options['post_navigation'] ? ' checked' : '';
        ?>
> Enable additional post navigation
						</label>
						<p class="description">Clicking the "previous" button on the <b>first</b> slide will open the previous post, and clicking the "next" button on the <b>last</b> slide will open the next post.</p>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
					</th>
					<td>
						<label>
							<input id="tps_post_navigation_same_category" type="checkbox" name="tps_nav[post_navigation_same_category]" value="true"<?php 
        echo $options['post_navigation_same_category'] ? ' checked' : '';
        ?>
> Only for posts from the same category
						</label>
						<p class="description">The "previous" and "next" buttons will only navigate through posts of the same category.</p>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_prev_post_button_text"><?php 
        _e("Previous button text:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_prev_post_button_text" name="tps_nav[prev_text_post]" value="<?php 
        echo $options['prev_text_post'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_next_post_button_text"><?php 
        _e("Next button text:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_next_post_button_text" name="tps_nav[next_text_post]" value="<?php 
        echo $options['next_text_post'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_post_button_width"><?php 
        _e("Button width (px):", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_post_button_width" name="tps_nav[button_width_post]" value="<?php 
        echo $options['button_width_post'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
						<p class="description">Use this if you want both buttons to have the same width. Insert "0" for no fixed width.</p>
					</td>
				</tr>
			</table>
			<p class="submit">
				<input type="submit" class="button-primary" value="<?php 
        _e('Save All Changes', 'theia-post-slider');
        ?>
" />
			</p>
		</form>
		<script type="text/javascript">
			function updateSlider() {
				var $ = jQuery;

				// Update navigation text
				slider.setNavText($('#tps_navigation_text').val());

				// Update title text
				slider.setTitleText($('#tps_helper_text').val());

				// Update button text
				$('.theiaPostSlider_nav ._prev ._2').html($('#tps_prev_button_text').val());
				$('.theiaPostSlider_nav ._next ._2').html($('#tps_next_button_text').val());

				// Update button width
				var width = parseInt($('#tps_button_width').val());
				$('.theiaPostSlider_nav ._2').css('width', width > 0 ? width : '');

				// Update horizontal position
				$('#tps_nav_upper, #tps_nav_lower')
					.removeClass('_left _center _right')
					.addClass('_' + $('#tps_nav_horizontal_position').val());

				// Update vertical position
				$('#tps_nav_upper').toggle(['top_and_bottom', 'top'].indexOf($('#tps_nav_vertical_position').val()) != -1);
				$('#tps_nav_lower').toggle(['top_and_bottom', 'bottom'].indexOf($('#tps_nav_vertical_position').val()) != -1);
			}

			function updatePostNavigation() {
				var $ = jQuery,
					enabled = $('#tps_post_navigation').attr('checked') == 'checked';
				$('#tps_prev_post_button_text, #tps_next_post_button_text, #tps_post_button_width').attr('readonly', !enabled);
				$('#tps_post_navigation_same_category').attr('disabled', !enabled);
			}
			updatePostNavigation();
		</script>
		<?php 
    }
Ejemplo n.º 4
0
 * Decide whether to use these files as a standalone plugin or not (i.e. integrate them in a theme).
 */
if (!defined('TPS_USE_AS_STANDALONE')) {
    define('TPS_USE_AS_STANDALONE', true);
}
/*
 * Define the plugin URL.
 */
if (!defined('TPS_PLUGINS_URL')) {
    define('TPS_PLUGINS_URL', plugins_url('', __FILE__) . '/');
}
// Include other files.
include dirname(__FILE__) . '/TpsMisc.php';
include dirname(__FILE__) . '/TpsEnqueues.php';
include dirname(__FILE__) . '/TpsShortCodes.php';
include dirname(__FILE__) . '/TpsOptions.php';
include dirname(__FILE__) . '/admin-menu.php';
// Initialize plugin options.
TpsOptions::initOptions();
// Add hooks.
add_action('the_post', 'TpsMisc::the_post', 999999);
add_action('the_content', 'TpsMisc::the_content', 999999);
add_action('wp_enqueue_scripts', 'TpsEnqueues::wp_enqueue_scripts');
add_action('admin_enqueue_scripts', 'TpsEnqueues::admin_enqueue_scripts');
add_filter('mce_buttons', 'TpsMisc::wysiwyg_editor');
add_filter('wp_head', 'TpsMisc::wp_head');
add_action('init', 'TpsShortCodes::add_button');
// Add shortcodes.
add_shortcode("tps_header", "TpsShortCodes::tps_header");
add_shortcode("tps_footer", "TpsShortCodes::tps_footer");
add_shortcode("tps_title", "TpsShortCodes::tps_title");
Ejemplo n.º 5
0
    public function echoPage()
    {
        ?>
		<form method="post" action="options.php">
			<?php 
        settings_fields('tps_options_general');
        ?>
			<?php 
        $options = get_option('tps_general');
        ?>
			<h3><?php 
        _e("General Settings", 'theia-post-slider');
        ?>
</h3>
			<table class="form-table">
				<tr valign="top">
					<th scope="row">
						<label for="tps_theme"><?php 
        _e("Theme:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<select id="tps_theme" name="tps_general[theme]" onchange="updateSlider()">
							<?php 
        foreach (TpsOptions::getThemes() as $key => $value) {
            $output = '<option value="' . $key . '"' . ($key == $options['theme'] ? ' selected' : '') . '>' . $value . '</option>' . "\n";
            echo $output;
        }
        ?>
						</select>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_transition_effect"><?php 
        _e("Transition effect:", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<select id="tps_transition_effect" name="tps_general[transition_effect]" onchange="updateSlider()">
							<?php 
        foreach (TpsOptions::getTransitionEffects() as $key => $value) {
            $output = '<option value="' . $key . '"' . ($key == $options['transition_effect'] ? ' selected' : '') . '>' . $value . '</option>' . "\n";
            echo $output;
        }
        ?>
						</select>
					</td>
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="tps_transition_speed"><?php 
        _e("Transition duration (ms):", 'theia-post-slider');
        ?>
</label>
					</th>
					<td>
						<input type="text" id="tps_transition_speed" name="tps_general[transition_speed]" value="<?php 
        echo $options['transition_speed'];
        ?>
" class="regular-text" onchange="updateSlider()"/>
					</td>
				</tr>
			</table>
			<p class="submit">
				<input type="submit" class="button-primary" value="<?php 
        _e('Save All Changes', 'theia-post-slider');
        ?>
" />
			</p>
		</form>
		<script type="text/javascript">
			function updateSlider() {
				var $ = jQuery;

				// Update transition
				slider.setTransition({
					'effect': $('#tps_transition_effect').val(),
					'speed': parseInt($('#tps_transition_speed').val())
				});

				// Update theme
				var css = $('#theiaPostSlider-css');
				var href = '<?php 
        echo TPS_PLUGINS_URL . 'css/';
        ?>
' + $('#tps_theme').val() + '?ver=<?php 
        echo TPS_VERSION;
        ?>
';
				if (css.attr('href') != href) {
					css.attr('href', href);
				}
			}
		</script>
		<?php 
    }
Ejemplo n.º 6
0
    public static function do_page()
    {
        $tabs = array('general' => array('title' => __("General", 'theia-post-slider'), 'class' => 'General'), 'navigationBar' => array('title' => __("Navigation Bar", 'theia-post-slider'), 'class' => 'NavigationBar'));
        if (array_key_exists('tab', $_GET) && array_key_exists($_GET['tab'], $tabs)) {
            $currentTab = $_GET['tab'];
        } else {
            $currentTab = 'general';
        }
        ?>

		<div class="wrap" xmlns="http://www.w3.org/1999/html">
			<div id="icon-options-general" class="icon32"><br></div>
			<h2>Theia Post Slider</h2>
			<?php 
        settings_errors();
        ?>
			<h2 class="nav-tab-wrapper">
				<?php 
        foreach ($tabs as $id => $tab) {
            $class = 'nav-tab';
            if ($id == $currentTab) {
                $class .= ' nav-tab-active';
            }
            ?>
				    <a href="?page=tps&tab=<?php 
            echo $id;
            ?>
" class="<?php 
            echo $class;
            ?>
"><?php 
            echo $tab['title'];
            ?>
</a>
				    <?php 
        }
        ?>
			</h2>
			<?php 
        $class = 'TpsAdmin_' . $tabs[$currentTab]['class'];
        require $class . '.php';
        $page = new $class();
        $page->echoPage();
        ?>

			<h3><?php 
        _e("Live Preview", 'theia-post-slider');
        ?>
</h3>
			<div class="theiaPostSlider_adminPreview">
				<?php 
        echo TpsMisc::getNavigationBar(array('currentSlide' => 1, 'totalSlides' => 3, 'id' => 'tps_nav_upper', 'class' => '_upper', 'style' => in_array(TpsOptions::get('nav_vertical_position'), array('top_and_bottom', 'top')) ? '' : 'display: none'));
        ?>
				<div id="tps_dest" class="theiaPostSlider_slides"></div>
				<div id="tps_src" class="theiaPostSlider_slides">
					<?php 
        include dirname(__FILE__) . '/preview-slider.php';
        ?>
				</div>
				<?php 
        echo TpsMisc::getNavigationBar(array('currentSlide' => 1, 'totalSlides' => 3, 'id' => 'tps_nav_lower', 'class' => '_lower', 'style' => in_array(TpsOptions::get('nav_vertical_position'), array('top_and_bottom', 'bottom')) ? '' : 'display: none'));
        $sliderOptions = array('src' => '#tps_src > div', 'dest' => '#tps_dest', 'nav' => array('#tps_nav_upper', '#tps_nav_lower'), 'navText' => TpsOptions::get('navigation_text'), 'helperText' => TpsOptions::get('helper_text'), 'transitionEffect' => TpsOptions::get('transition_effect'), 'transitionSpeed' => TpsOptions::get('transition_speed'), 'keyboardShortcuts' => true, 'prevText' => TpsOptions::get('prev_text'), 'nextText' => TpsOptions::get('next_text'), 'buttonWidth' => TpsOptions::get('button_width'));
        ?>
				<script type='text/javascript'>
					var slider, theme;
					jQuery(document).ready(function() {
						slider = new tps.createSlideshow(<?php 
        echo json_encode($sliderOptions);
        ?>
);
					});
				</script>
			</div>
		</div>
		<?php 
    }
Ejemplo n.º 7
0
 public static function getPrevNextPost($previous)
 {
     if (!TpsOptions::get('post_navigation')) {
         return null;
     }
     $post = get_adjacent_post(TpsOptions::get('post_navigation_same_category'), '', $previous);
     if (!$post) {
         return null;
     }
     return $post->ID;
 }