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'); }
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); } } }
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 }