/**
  * Creates or returns an instance of this class.
  *
  * @since 1.1.0
  *
  * @return Theme_Blvd_Frontend_Init A single instance of this class.
  */
 public static function get_instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Edit a slider
  *
  * @since 1.0.0
  */
 public function edit_slider()
 {
     $slider_id = $_POST['data'];
     $api = Theme_Blvd_Sliders_API::get_instance();
     $types = $api->get_sliders();
     echo $slider_id . '[(=>)]';
     $this->admin_page->edit_slider($_POST['data']);
     die;
 }
Exemplo n.º 3
0
 /**
  * Remove slider type.
  *
  * @since 2.3.0
  *
  * @param string $slider_id ID for new slider type
  */
 function themeblvd_remove_slider($slider_id)
 {
     // Get out if Sliders API doesn't exist.
     if (!class_exists('Theme_Blvd_Sliders_API')) {
         return;
     }
     $api = Theme_Blvd_Sliders_API::get_instance();
     $api->remove($slider_id);
 }
Exemplo n.º 4
0
/**
 * Setup Sliders API and filter in registered "Sliders"
 * and "Post Slider" elements for Theme Blvd Layout
 * Builder plugin.
 *
 * @since 1.1.0
 */
function themeblvd_sliders_api_init()
{
    // Add filter for Layout Builder's API to register
    // "Sliders" and "Post Slider" elements
    add_filter('themeblvd_registered_elements', 'themeblvd_sliders_registered_elements');
    // Include Theme_Blvd_Sliders_API class.
    include_once TB_SLIDERS_PLUGIN_DIR . '/includes/api/class-tb-sliders-api.php';
    // Instantiate single object for Sliders API.
    // Helper functions are located within theme
    // framework. i.e. themeblvd_add_slider()
    Theme_Blvd_Sliders_API::get_instance();
}
    /**
     * Generates the the interface to edit slider.
     *
     * @since 1.0.0
     *
     * @param $id string ID of slider to edit
     */
    public function edit_slider($id)
    {
        $api = Theme_Blvd_Sliders_API::get_instance();
        // Get slider custom post
        $slider = get_post($id);
        // Check for no post object returned from ID.
        if (!$slider) {
            echo '<div class="error"><p>' . __('The slider could not be found.', 'themeblvd_sliders') . '</p></div>';
            return;
        }
        // Post ID
        $post_id = $slider->ID;
        // Meta data for slider post
        $current_slides = get_post_meta($post_id, 'slides', true);
        $type = get_post_meta($post_id, 'type', true);
        $settings = get_post_meta($post_id, 'settings', true);
        // Check if slider type is valid.
        if (!$api->is_slider($type)) {
            echo '<div class="error"><p>' . sprintf(__('The slider type "%s" is not valid.', 'themeblvd_sliders'), $type) . '</p></div>';
            return;
        }
        $type_info = $types = $api->get_sliders($type);
        $options = $type_info['options'];
        ?>
		<input type="hidden" name="slider_id" value="<?php 
        echo $post_id;
        ?>
" />
		<div id="poststuff" class="metabox-holder full-width has-right-sidebar">
			<div class="inner-sidebar">
				<div id="slider-publish" class="postbox postbox-publish">
					<h3 class="hndle" title="<?php 
        echo __('Click to toggle', 'themeblvd_sliders');
        ?>
"><?php 
        _e('Publish', 'themeblvd_sliders');
        ?>
 <?php 
        echo stripslashes($slider->post_title);
        ?>
</h3>
					<div class="tb-widget-content submitbox">
						<div id="major-publishing-actions">
							<div id="delete-action">
								<a class="submitdelete delete_slider" href="#<?php 
        echo $post_id;
        ?>
"><?php 
        _e('Delete', 'themeblvd_sliders');
        ?>
</a>
							</div>
							<div id="publishing-action">
								<input class="button-primary" value="<?php 
        _e('Update Slider', 'themeblvd_sliders');
        ?>
" type="submit" />
								<img src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" class="ajax-loading" />
							</div>
							<div class="clear"></div>
						</div>
					</div><!-- .tb-widget-content (end) -->
				</div><!-- .post-box (end) -->
				<div id="slider-info" class="postbox postbox-slider-info closed">
					<div class="handlediv" title="<?php 
        echo __('Click to toggle', 'themeblvd_sliders');
        ?>
"><br></div>
					<h3 class="hndle"><?php 
        _e('Slider Information', 'themeblvd_sliders');
        ?>
</h3>
					<div class="tb-widget-content hide">
						<?php 
        // Current settings
        $info_settings = array('post_title' => $slider->post_title, 'post_name' => $slider->post_name);
        // Setup attribute options
        $info_options = array(array('name' => __('Slider Name', 'themeblvd_sliders'), 'id' => 'post_title', 'desc' => __('This title is just for you. It\'ll never be used outside of your WordPress admin panel.', 'themeblvd_sliders'), 'type' => 'text'), array('name' => __('Slider ID', 'themeblvd_sliders'), 'id' => 'post_name', 'desc' => __('Sliders are assigned based on this ID. So if you change this at any point, make sure to also update any builder elements, pages, or other options in which you\'ve assigned this specific slider.', 'themeblvd_sliders'), 'type' => 'text'));
        // Display form element
        $form = themeblvd_option_fields('info', $info_options, $info_settings, false);
        echo $form[0];
        ?>
					</div><!-- .tb-widget-content (end) -->
				</div><!-- .post-box (end) -->
				<?php 
        if ($options) {
            ?>
					<div id="slider-options" class="postbox postbox-options closed">
						<div class="handlediv" title="<?php 
            echo __('Click to toggle', 'themeblvd_sliders');
            ?>
"><br></div>
						<h3 class="hndle"><?php 
            echo $type_info['name'] . ' ' . __('Options', 'themeblvd_sliders');
            ?>
</h3>
						<div class="tb-widget-content hide">
							<?php 
            // Slider Options
            $form = themeblvd_option_fields('options', $options, $settings, false);
            echo $form[0];
            ?>
						</div><!-- .tb-widget-content (end) -->
					</div><!-- .post-box (end) -->
				<?php 
        }
        ?>
			</div><!-- .inner-sidebar (end) -->
			<div id="post-body">
				<div id="post-body-content">
					<div id="titlediv">
						<div class="ajax-overlay"></div>
						<h2><?php 
        printf(__('Manage %s Slides', 'themeblvd_sliders'), ucfirst($type));
        ?>
</h2>
						<a href="#<?php 
        echo $post_id;
        ?>
=><?php 
        echo $type;
        ?>
" id="add_new_slide" class="button-secondary"><?php 
        _e('Add New Slide', 'themeblvd_sliders');
        ?>
</a>
						<img src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" class="ajax-loading" id="ajax-loading">
						<div class="clear"></div>
					</div><!-- #titlediv (end) -->
					<div id="sortable">
						<?php 
        if (!empty($current_slides)) {
            foreach ($current_slides as $slide_id => $slide) {
                $this->edit_slide($post_id, $type, $slide_id, $slide);
            }
        } else {
            echo '<p class="warning no-item-yet">' . __('You haven\'t added any slides yet. Get started by clicking "Add New Slide" above.', 'themeblvd_sliders') . '</p>';
        }
        ?>
					</div><!-- .sortable-slides (end) -->
				</div><!-- #post-body-content (end) -->
			</div><!-- #post-body (end) -->
		</div><!-- .metabox-holder (end) -->
		<?php 
    }