You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ if (!defined('TOTAL_SLIDER_REQUIRED_CAPABILITY')) { header('HTTP/1.1 403 Forbidden'); die('<h1>Forbidden</h1>'); } if (!function_exists('__')) { header('HTTP/1.1 403 Forbidden'); die('<h1>Forbidden</h1>'); } ?> <!--sortable slides--> <?php $group = new Total_Slide_Group($TS_Total_Slider->slug); $group->load(); $current_slides = $group->get_slides(); ?> <div id="slidesort-container"> <ul id="slidesort" style="width:<?php echo intval(count($current_slides) * 180); ?> px;"> <?php if (is_array($current_slides) && count($current_slides) > 0) { foreach ($current_slides as $slide) { $my_id = $TS_Total_Slider->id_filter($slide['id']); if (is_numeric($slide['background'])) { $background_url = wp_get_attachment_url((int) $slide['background']); } else {
} // v2.0: we can no longer have slide groups that have identical names, even if slugs don't clash $existing_terms = get_terms('total_slider_slide_group', array('hide_empty' => false)); if (!$collision && is_array($existing_terms) && count($existing_terms) > 0) { foreach ($existing_terms as $term) { if ($term->name == $_POST['group-name']) { $collision = true; break; } } } // if collision, throw an error: if ($collision) { $create_error = __('Unable to create this slide group, as there is already a group with this name.', 'total-slider'); } else { $new_group = new Total_Slide_Group($new_slug, $_POST['group-name']); // set the new template $desired_tpl_slug = Total_Slider_Template::sanitize_slug($_POST['template-slug']); $tpl_location = false; $tpl_slug = false; // determine which template location this template is from $t = new Total_Slider_Template_Iterator(); foreach (Total_Slider::$allowed_template_locations as $l) { if ($tpl_location || $tpl_slug) { break; } $choices = $t->discover_templates($l, false); // find the right template and set our provision template slug and location to it if (is_array($choices) && count($choices) > 0) { foreach ($choices as $c) { if ($desired_tpl_slug == $c['slug']) {
/** * An iterator for the purposes of Slider Template files. Loads the next slide in, preparing other methods to spit out this Slide's information. * * @return boolean * */ public function has_slides() { if (!$this->instance) { throw new Exception("The widget's instance data, containing information about which slide group to show, could not be loaded."); return false; } if (!is_array($this->slides) || count($this->slides) < 1) { $this->slides = $this->slide_group->get_slides(); } // on which slide should we work? does it exist? if (count($this->slides) < $this->slider_iteration + 1) { return false; // we are at the end of the slides } // otherwise, load in the data if (!empty($this->slides[$this->slider_iteration]['title'])) { $this->slide_title = $this->slides[$this->slider_iteration]['title']; } if (!empty($this->slides[$this->slider_iteration]['description'])) { $this->slide_description = $this->slides[$this->slider_iteration]['description']; } else { $this->slide_description = ''; } if (!empty($this->slides[$this->slider_iteration]['id'])) { $this->slide_identifier = $this->slides[$this->slider_iteration]['id']; } // the background may be blank! if (!empty($this->slides[$this->slider_iteration]['background'])) { $this->slide_background_url = $this->slides[$this->slider_iteration]['background']; } else { $this->slide_background_url = ''; } // the link may be blank! if (!empty($this->slides[$this->slider_iteration]['link'])) { $this->slide_link = $this->slides[$this->slider_iteration]['link']; } else { $this->slide_link = ''; } // get X and Y coords if (!empty($this->slides[$this->slider_iteration]['title_pos_x']) || 0 === $this->slides[$this->slider_iteration]['title_pos_x']) { $this->slide_x = $this->slides[$this->slider_iteration]['title_pos_x']; } if (!empty($this->slides[$this->slider_iteration]['title_pos_y']) || 0 === $this->slides[$this->slider_iteration]['title_pos_y']) { $this->slide_y = $this->slides[$this->slider_iteration]['title_pos_y']; } // the data is ready, bump the iterator and return true $this->slider_iteration++; return true; }
if (!function_exists('__')) { header('HTTP/1.1 403 Forbidden'); die('<h1>Forbidden</h1>'); } require_once ABSPATH . 'wp-admin/includes/user.php'; // get the slide group list $legacy_slide_groups = get_option('total_slider_slide_groups'); if (is_array($legacy_slide_groups) && count($legacy_slide_groups) > 0) { $legacy_slide_group_names = array(); // to detect and handle Slide Group name clashes, which are now a problem with the 2.0 data format foreach ($legacy_slide_groups as $key => $legacy_group) { if (is_a($legacy_group, 'Total_Slide_Group')) { // convert this group to the new format $new_slug = Total_Slider::sanitize_slide_group_slug($legacy_group->slug); $legacy_slides = get_option('total_slider_slides_' . $new_slug); $new_group = new Total_Slide_Group($new_slug, $legacy_group->name); $new_group->template = $legacy_group->template; $new_group->templateLocation = $legacy_group->templateLocation; // if this legacy group name collides with an existing legacy group name, we must rename and re-slug it // or WP will combine posts attached to the two terms, merging the Slide Groups! if (in_array($legacy_group->name, $legacy_slide_group_names)) { $new_group->name = $legacy_group->name . ' (duplicate name)'; $new_group->slug = Total_Slider::sanitize_slide_group_slug(substr($legacy_group->slug, 0, 12) . sanitize_title_with_dashes(uniqid('', true))); } $new_group->save(); $new_slide_ids = array(); if (is_array($legacy_slides) && count($legacy_slides) > 0) { foreach ($legacy_slides as $legacy_slide) { $title = $legacy_slide['title']; $description = $legacy_slide['description']; $background = $legacy_slide['background'];
/** * Print the HTML for the slide template metabox. * * @return void * */ public function print_slide_template_metabox() { global $TS_Total_Slider; if (!$this->slug) { if (!array_key_exists('group', $_GET)) { return false; } $this->slug = $this->sanitize_slide_group_slug($_GET['group']); } $slide_group = new Total_Slide_Group($this->slug); if (!$slide_group->load()) { return false; } ?> <div id="template-switch-controls"> <p> <?php $t = new Total_Slider_Template_Iterator(); ?> <select name="template-slug" id="template-slug-selector"> <?php $builtin = $t->discover_templates('builtin'); ?> <?php if (is_array($builtin) && count($builtin) > 0) { ?> <optgroup label="<?php _e('Built-in', 'total-slider'); ?> "> <?php foreach ($builtin as $tpl) { ?> <option value="<?php echo esc_attr($tpl['slug']); ?> " <?php if ('builtin' == $slide_group->templateLocation && $slide_group->template == $tpl['slug']) { ?> selected="selected" <?php } ?> ><?php echo esc_html($tpl['name']); ?> </option> <?php } ?> </optgroup> <?php } ?> <?php $theme = $t->discover_templates('theme'); ?> <?php if (is_array($theme) && count($theme) > 0) { ?> <optgroup label="<?php _e('Theme', 'total-slider'); ?> "> <?php foreach ($theme as $tpl) { ?> <option value="<?php echo esc_attr($tpl['slug']); ?> " <?php if ('theme' == $slide_group->templateLocation && $slide_group->template == $tpl['slug']) { ?> selected="selected" <?php } ?> ><?php echo esc_html($tpl['name']); ?> </option> <?php } ?> </optgroup> <?php } ?> <?php $legacy = $t->discover_templates('legacy', false); ?> <?php if (is_array($legacy) && count($legacy) > 0) { ?> <optgroup label="<?php _e('v1.0 Templates', 'total-slider'); ?> "> <?php foreach ($legacy as $tpl) { ?> <option value="<?php echo esc_attr($tpl['slug']); ?> " <?php if ('legacy' == $slide_group->templateLocation) { ?> selected="selected" <?php } ?> ><?php echo esc_html($tpl['name']); ?> </option> <?php } ?> </optgroup> <?php } ?> <?php //$downloaded = $t->discover_templates('downloaded'); ?> <?php $downloaded = false; ?> <?php if (is_array($downloaded) && count($downloaded) > 0) { ?> <!--<optgroup label="<?php _e('Downloaded', 'total-slider'); ?> "> <?php foreach ($downloaded as $tpl) { ?> <option value="<?php echo esc_attr($tpl['slug']); ?> " <?php if ('downloaded' == $slide_group->templateLocation && $slideGroup->template == $tpl['slug']) { ?> selected="selected" <?php } ?> ><?php echo esc_html($tpl['name']); ?> </option> <?php } ?> </optgroup> --> <?php } ?> </select> <input id="template-switch-button" type="submit" class="button-secondary action" style="margin-top:8px; max-width:180px;" value="<?php _e('Change Template', 'total-slider'); ?> " /> </p> </div><?php }
/** * Get the Slide Groups, so we can display them in the table. * * @return array * */ public function get_groups() { $args = array('hide_empty' => false); $groups = get_terms('total_slider_slide_group', $args); // load template information if (is_array($groups) && count($groups) > 0) { foreach ($groups as $group) { $group_object = new Total_Slide_Group($group->slug); $group_object->load(); $group->template = $group_object->template; $group->templateLocation = $group_object->templateLocation; } } return $groups; }
?> <h1><?php _e('This page is not accessible to your user.', 'total-slider'); ?> </h1><?php return; } $TS_Total_Slider->slug = $TS_Total_Slider->sanitize_slide_group_slug($_GET['group']); if (empty($TS_Total_Slider->slug)) { echo '<div class="wrap"><h1>'; _e('No Slide Group selected.', 'total-slider'); echo '</h1></div>'; return; } // get the name data for this slide group based on its slug $slide_group = new Total_Slide_Group($TS_Total_Slider->slug); if (!$slide_group->load()) { echo '<div class="wrap"><h1>'; _e('Could not load the selected Slide Group. Does it exist?', 'total-slider'); echo '</h1></div>'; return; } // determine and load template if (!$TS_Total_Slider->template || !is_a($TS_Total_Slider->template, 'Total_Slider_Template')) { $TS_Total_Slider->determine_template(); } if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && array_key_exists('action', $_GET) && 'changeTemplate' == $_GET['action']) { // change the template and redirect if (!wp_verify_nonce($_POST['total-slider-change-template-nonce'], 'total-slider-change-template')) { die(__('Unable to confirm the form’s security.', 'total-slider')); }
die; } // get the group that we are supposed to be acting on if (array_key_exists('group', $_GET)) { $slug = $_GET['group']; } else { $slug = ''; } if (empty($slug)) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: application/json'); echo json_encode(array('error' => __('You did not supply the slide group to which this action should be applied.', 'total-slider'))); die; } try { $g = new Total_Slide_Group($slug); if (!$g->load()) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: application/json'); echo json_encode(array('error' => __('Could not load the selected Slide Group. Does it exist?', 'total-slider'))); die; } } catch (Exception $e) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: application/json'); echo json_encode(array('error' => $e->getMessage())); die; } switch ($_GET['action']) { case 'createNewSlide': if (!current_user_can(TOTAL_SLIDER_REQUIRED_CAPABILITY)) {