/home/arranoyd/magicraft/wp-content/plugins/the-loading-bar/class-loading-bar.php
<?php
/**
 * The Loading Bar class file.
 * @package The Loading Bar
 */

if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly.
}
require_once( 'titan-framework-checker.php' );

if ( ! class_exists( 'GambitLoadingBar' ) ) {

	/**
	 * This class houses all the plugin's functions.
	 */
	class GambitLoadingBar {

		/**
		 * Indicates the plugin being loaded for the first time.
		 * @var $firstLoad
		 */
	    private static $firstLoad = 0;

		/**
		 * Hook into WordPress.
		 *
		 * @return	void
		 * @since	1.0
		 */
		function __construct() {

			add_action( 'tf_create_options', array( $this, 'create_options' ) );
			add_action( 'wp_head', array( $this, 'hide_the_page' ) );
			add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_loading_bar' ) );
			add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );

		}


		/**
		 * Pulls a list of post types and their slugs.
		 * CURRENTLY DOES NOT WORK DUE TO get_post_types ALWAYS RETURNING BLANKS WHEN $args IS SPECIFIED!!!!!!!
		 *
		 * @param string $type - defines whether a simple array or multidimensional array will be returned as a list.
		 * @return $posttypes
		 * @since 1.5
		 */
		public function get_all_post_types( $type = 'list' ) {
			$posttypes = null;
			$args = array(
			   'public' => true,
			   'publicly_queryable' => true,
			   '_builtin' => false,
			);
			$post_types = get_post_types( array(), 'objects', 'and' );

			foreach ( $post_types as $post_type ) {
				if ( 'list' == $type ) {
					$posttypes[ $post_type->labels->name ] = $post_type->query_var;
				} else {

					$posttypes['slug'][] = $post_type->query_var;
					$posttypes['name'][ $post_type->query_var ] = $post_type->labels->name;
				}
			}
			return $posttypes;
		}


		/**
		 * Create the admin panel with the custom post types.
		 * CURRENTLY DOES NOT WORK DUE TO get_post_types ALWAYS RETURNING BLANKS WHEN $args IS SPECIFIED!!!!!!!
		 *
		 * @param string $out - Determines output. Values can be string, or an array.
		 * @return array or string, depending on the parameter above.
		 * @since	1.0
		 */
		public function gambit_tlb_cpt( $out = 'array' ) {

			$output = null;

			// First, pull all post types.
			$postTypes = $this->get_all_post_types( 'array' );

			// Now traverse each post type and make sure they're not empty. Do not process if no posts appear.
			if ( count( $postTypes['slug'] ) > 0 ) {
				foreach ( $postTypes['slug'] as $eachCPT ) {

					$found_posts = null;

					// Prepare arguments for post lookup.
					$my_query = null;
					$args = array(
					  'post_type' => $eachCPT,
					  'post_status' => 'publish',
					  'posts_per_page' => -1,
				  	);

					// Make a query that sees if there are posts.
					$my_query = new WP_Query( $args );

					// There's at least one post? Process it.
					if ( $my_query->have_posts() ) {
						while ( $my_query->have_posts() ) : $my_query->the_post();
							$found_posts[ get_the_ID() ] = get_the_title();
				  		endwhile;
					}

					// Resets WordPress query.
					wp_reset_query();

					// Enter the populated post type into the output array. Empty posttypes will not be parsed.
					if ( count( $found_posts ) > 0 ) {

						// If the output is 'array', throw this output. This is the default behavior.
						if ( 'array' == $out ) {
							$thename = __( '%n with a Loading Bar', GAMBIT_LOADING_BAR );
							$thename = str_replace( '%n', $postTypes['slug'][ $eachCPT ], $thename );
							$output[] = array(
							    'name' => $thename,
							    'id' => 'where_' . $eachCPT,
							    'type' => 'multicheck',
							    'desc' => __( 'Choose specific posts from this post type that will show the loading bar. If you do not see your posts here, that post type is empty and should be populated.', GAMBIT_LOADING_BAR ),
								'options' => $found_posts,
								'depends' => array(
									'where' => 'select',
								),
							);
						} // If the value is something like 'string' or 'csv', throw this output instead. Default behavior.
						else {
							$output[] = $eachCPT;
						}
					}
				}
			}
			// Throw the output, whether null or what.
			return $output;

		}


		/**
		 * Create the admin panel.
		 *
		 * @return	void
		 * @since	1.0
		 */
		public function create_options() {
			$titan = TitanFramework::getInstance( GAMBIT_LOADING_BAR );
			$titan->set( 'css', false );

			$panel = $titan->createAdminPanel( array(
			    'name' => __( 'The Loading Bar', GAMBIT_LOADING_BAR ),
				'parent' => 'options-general.php',
				'desc' => __( 'These are the settings for your website loading screen. Note that the loading screen will only show up if your page has images (because if you don&apos;t have any images then your page will load fast).', GAMBIT_LOADING_BAR ),
			) );

			$panel->createOption( array(
			    'name' => __( 'General Settings', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Enable Loading Bar', GAMBIT_LOADING_BAR ),
			    'id' => 'enable',
			    'type' => 'enable',
			    'desc' => __( 'Enable the loading bar. The images hosted from your site are observed for their loading times. Your site will appear after those images finish loading.<br><strong>If no self hosted images are detected in your page, the loading bar won&apos;t appear.</strong>', GAMBIT_LOADING_BAR ),
			    'default' => true,
			) );

			$panel->createOption( array(
			    'name' => __( 'Disable Loading Bar in mobile devices', GAMBIT_LOADING_BAR ),
			    'id' => 'disable_mobile',
			    'type' => 'enable',
			    'desc' => __( 'If set, the Loading Bar will not operate on devices detected to be mobile, such as tablets or smartphones.', GAMBIT_LOADING_BAR ),
			    'default' => false,
			) );

			$panel->createOption( array(
			    'name' => __( 'Image Domains', GAMBIT_LOADING_BAR ),
			    'id' => 'domains',
			    'type' => 'text',
			    'desc' => __( 'By default, we observe the loading times of images from <strong>your own domain only</strong>. If you&apos;re hosting images from a CDN, enter the domains here (comma separated) so that we can observe those loading times too.<br><strong>Important Note: Some CDNs may not allow this, and you may see a <code>Access-Control-Allow-Origin</code> error if that is the case</strong>', GAMBIT_LOADING_BAR ),
			    'default' => '',
			) );

			$panel->createOption( array(
			    'name' => __( 'Load Once', GAMBIT_LOADING_BAR ),
			    'id' => 'load_once',
			    'type' => 'enable',
			    'desc' => __( 'When enabled, when your webpage gets fully loaded once, the loading bar will not show up anymore for that webpage and we&apos;ll assume that your webpage has been cached by the browser. This is helpful so that your visitors who have previously visited a loaded page won&apos;t be shown the loading progress anymore.<br><strong>Only enable this when you are done testing the looks of your loading bar.</strong>', GAMBIT_LOADING_BAR ),
			    'default' => false,
			) );

			$panel->createOption( array(
			    'name' => '<div class="dashicons dashicons-admin-tools"></div> ' . __( 'Testing Mode', GAMBIT_LOADING_BAR ),
			    'id' => 'testing_mode',
			    'type' => 'enable',
			    'desc' => __( 'In testing mode, the speed (per tick) of the loading bar will be slower so that you can have a better view of your selected settings.', GAMBIT_LOADING_BAR ),
			    'default' => false,
				'enabled' => 'Testing Mode',
				'disabled' => 'Live Mode',
			) );

			$panel->createOption( array(
			    'name' => '<div class="dashicons dashicons-admin-tools"></div> ' . __( 'Don&apos;t show page', GAMBIT_LOADING_BAR ),
			    'id' => 'testing_mode_halt',
			    'type' => 'checkbox',
			    'desc' => __( 'Keep showing the loading bar, don&apos;t continue to the page when we reach 100%. This is helpful when testing out your settings.', GAMBIT_LOADING_BAR ),
			    'default' => false,
				'depends' => array(
					'testing_mode' => true,
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Force overflow upon exit', GAMBIT_LOADING_BAR ),
			    'id' => 'force_overflow',
			    'type' => 'checkbox',
			    'desc' => __( 'Some themes may mess with the overflow attribute of the HTML body. Check this if you are getting that problem.', GAMBIT_LOADING_BAR ),
			    'default' => false,
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Background', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Background Color', GAMBIT_LOADING_BAR ),
			    'id' => 'background_color',
			    'type' => 'color',
			    'desc' => __( 'The background color of the loading screen', GAMBIT_LOADING_BAR ),
			    'default' => '#ffffff',
				'css' => '#loading-bar-container { background-color: value }',
			) );

			$panel->createOption( array(
			    'name' => __( 'Background Image', GAMBIT_LOADING_BAR ),
			    'id' => 'background_image',
			    'type' => 'upload',
			    'desc' => __( 'Be careful of adding a background image to your loader. The loader should be fast and if you&apos;re going to add an image, make sure that it has a very small file size.', GAMBIT_LOADING_BAR ),
				'css' => '#loading-bar-container { background-image: value; background-size: cover }',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Percentage Label', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Percentage Label', GAMBIT_LOADING_BAR ),
			    'id' => 'use_label',
			    'type' => 'enable',
			    'default' => false,
				'enabled' => __( 'Show Label', GAMBIT_LOADING_BAR ),
				'disabled' => __( 'Hide Label', GAMBIT_LOADING_BAR ),
			) );

			$panel->createOption( array(
			    'name' => __( 'Percentage Label Font', GAMBIT_LOADING_BAR ),
			    'id' => 'label_font',
			    'type' => 'font',
			    'desc' => __( 'Select the font to use for the percentage label. We recommend choosing a <strong>web safe font</strong> so that the loading screen will load faster. Using a Google WebFont will delay the appearance of the loading bar since the font file would have to be loaded also.', GAMBIT_LOADING_BAR ),
				'preview_text' => '0% 10% 20% 30% 40% 50% 61% 72% 83% 94% 100% 5% 16% 27% 38% 49% 51% 62% 25% 75% 99% 8% 11% 22% 33% 44% 55% 66% 77% 88%',
				'default' => array(
			        'font-family' => '"Trebuchet MS", Helvetica, sans-serif',
			        'color' => '#333333',
			        'font-size' => '40px',
			        'line-height' => '1em',
			    ),
				'css' => '#loading-bar-container { value }',
				'depends' => array(
					'use_label' => true,
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Label Placement', GAMBIT_LOADING_BAR ),
			    'id' => 'label_location',
			    'type' => 'select',
			    'desc' => __( 'The alignment of the percentage label within the screen. You can use the margin settings below to fine tune the location of the label.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'top-left' => __( 'Top Left', GAMBIT_LOADING_BAR ),
			        'top-center' => __( 'Top Center', GAMBIT_LOADING_BAR ),
			        'top-right' => __( 'Top Right', GAMBIT_LOADING_BAR ),
			        'middle-left' => __( 'Middle Left', GAMBIT_LOADING_BAR ),
					'middle-center' => __( 'Centered', GAMBIT_LOADING_BAR ),
					'middle-right' => __( 'Middle Right', GAMBIT_LOADING_BAR ),
					'bottom-left' => __( 'Bottom Left', GAMBIT_LOADING_BAR ),
					'bottom-center' => __( 'Bottom Center', GAMBIT_LOADING_BAR ),
					'bottom-right' => __( 'Bottom Right', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'middle-center',
				'depends' => array(
					'use_label' => true,
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Margin Left & Right', GAMBIT_LOADING_BAR ),
			    'id' => 'label_margin_horizontal',
			    'type' => 'number',
			    'desc' => __( 'The left & right paddings of the percentage label. You can use this setting to push or pull your percentage label left or right.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
				'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'use_label' => true,
				),
				'css' => '#loading-bar-label { margin-left: valuepx; margin-right: valuepx; }',
			) );

			$panel->createOption( array(
			    'name' => __( 'Margin Top & Bottom', GAMBIT_LOADING_BAR ),
			    'id' => 'label_margin_vertical',
			    'type' => 'number',
			    'desc' => __( 'The top & bottom paddings of the percentage label. You can use this setting to push or pull your percentage label up or down.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
				'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'use_label' => true,
				),
				'css' => '#loading-bar-label { margin-top: valuepx; margin-bottom: valuepx; }',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Text', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Text', GAMBIT_LOADING_BAR ),
			    'id' => 'use_loadingbar_text',
			    'type' => 'enable',
			    'desc' => __( 'Check this to use a text to display during loading.', GAMBIT_LOADING_BAR ),
			    'default' => false,
				'enabled' => __( 'Show Text', GAMBIT_LOADING_BAR ),
				'disabled' => __( 'Hide Text', GAMBIT_LOADING_BAR ),
			) );

			$panel->createOption( array(
				'name' => __( 'Loading Bar Text Caption', GAMBIT_LOADING_BAR ),
				'id' => 'loadingbar_text_caption',
				'type' => 'textarea',
				'placeholder' => 'Now Loading, Please Wait.',
				'desc' => 'Add text to be displayed during loading.',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Text Font', GAMBIT_LOADING_BAR ),
			    'id' => 'loadingbar_text_font',
			    'type' => 'font',
			    'desc' => __( 'Select the font to use for the text. We recommend choosing a <strong>web safe font</strong> so that the loading screen will load faster. Using a Google WebFont will delay the appearance of the loading bar since the font file would have to be loaded also.', GAMBIT_LOADING_BAR ),
				'default' => array(
			        'font-family' => '"Trebuchet MS", Helvetica, sans-serif',
			        'color' => '#333333',
			        'font-size' => '40px',
			        'line-height' => '1em',
			    ),
				'css' => '#loading-bar-text { value }',
				'depends' => array(
					'use_loadingbar_text' => true,
				),
			) );
			$panel->createOption( array(
			    'name' => __( 'Loading Bar Text Placement', GAMBIT_LOADING_BAR ),
			    'id' => 'loadingbar_text_location',
			    'type' => 'select',
			    'desc' => __( 'The alignment of the text within the screen. You can use the margin settings below to fine tune the location of the text.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'top-left' => __( 'Top Left', GAMBIT_LOADING_BAR ),
			        'top-center' => __( 'Top Center', GAMBIT_LOADING_BAR ),
			        'top-right' => __( 'Top Right', GAMBIT_LOADING_BAR ),
			        'middle-left' => __( 'Middle Left', GAMBIT_LOADING_BAR ),
					'middle-center' => __( 'Centered', GAMBIT_LOADING_BAR ),
					'middle-right' => __( 'Middle Right', GAMBIT_LOADING_BAR ),
					'bottom-left' => __( 'Bottom Left', GAMBIT_LOADING_BAR ),
					'bottom-center' => __( 'Bottom Center', GAMBIT_LOADING_BAR ),
					'bottom-right' => __( 'Bottom Right', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'middle-center',
				'depends' => array(
					'use_loadingbar_text' => true,
				),
			) );
			$panel->createOption( array(
			    'name' => __( 'Margin Left & Right', GAMBIT_LOADING_BAR ),
			    'id' => 'loadingbar_text_margin_horizontal',
			    'type' => 'number',
			    'desc' => __( 'The left & right paddings of the text. You can use this setting to push or pull your text left or right.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
				'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'use_loadingbar_text' => true,
				),
				'css' => '#loading-bar-text { margin-left: valuepx; margin-right: valuepx; }',
			) );

			$panel->createOption( array(
			    'name' => __( 'Margin Top & Bottom', GAMBIT_LOADING_BAR ),
			    'id' => 'loadingbar_text_margin_vertical',
			    'type' => 'number',
			    'desc' => __( 'The top & bottom paddings of the text. You can use this setting to push or pull your text up or down.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
				'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'use_loadingbar_text' => true,
				),
				'css' => '#loading-bar-text { margin-top: valuepx; margin-bottom: valuepx; }',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Style', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_style',
			    'type' => 'select',
			    'desc' => __( 'The type of loading bar to display.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'none' => __( 'Don&apos;t display a loading bar', GAMBIT_LOADING_BAR ),
			        'line' => __( 'Horizontal line', GAMBIT_LOADING_BAR ),
			        'fill' => __( 'Fill up screen', GAMBIT_LOADING_BAR ),
			        'classic' => __( 'Classic progress bar', GAMBIT_LOADING_BAR ),
			        'circular' => __( 'Circular indicator', GAMBIT_LOADING_BAR ),
					'gif' => __( 'Custom Image / GIF animation', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'gif',
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Movement Speed', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_transition_speed',
			    'type' => 'number',
			    'desc' => __( 'The speed of the transitions of the movement of the progress bar.', GAMBIT_LOADING_BAR ),
			    'default' => '0.4',
				'min' => '0.0',
			    'max' => '1.0',
				'step' => '0.1',
				'unit' => __( 'seconds', GAMBIT_LOADING_BAR ),
				'depends' => array(
					'bar_style' => array( 'line', 'fill', 'classic', 'classic', 'circular' ),
				),
				'css' => '#loading-bar-progress {
                    -webkit-transition: all values ease-in-out;
                    -moz-transition: all values ease-in-out;
                    -ms-transition: all values ease-in-out;
                    -o-transition: all values ease-in-out;
                    transition: all values ease-in-out;
                }
                #loading-bar-progress > span {
                    -webkit-transition: all values cubic-bezier(0.175, 0.885, 0.32, 1.275);
                    -moz-transition: all values cubic-bezier(0.175, 0.885, 0.32, 1.275);
                    -ms-transition: all values cubic-bezier(0.175, 0.885, 0.32, 1.275);
                    -o-transition: all values cubic-bezier(0.175, 0.885, 0.32, 1.275);
                    transition: all values cubic-bezier(0.175, 0.885, 0.32, 1.275);
                }',
			) );

			$panel->createOption( array(
			    'name' => __( 'Custom Image / Animation', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_gif_type',
			    'type' => 'select',
			    'options' => array(
			        'upload' => __( 'Upload your own image', GAMBIT_LOADING_BAR ),
			        'included' => __( 'Choose from our GIF list', GAMBIT_LOADING_BAR ),
			    ),
				'default' => 'included',
			    'desc' => __( 'Choose a custom loading image or animation to display', GAMBIT_LOADING_BAR ),
				'depends' => array(
					'bar_style' => 'gif',
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Custom Image', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_gif_image',
			    'type' => 'upload',
			    'desc' => __( 'Upload your own image here. Animated GIFs are supported.', GAMBIT_LOADING_BAR ),
				'depends' => array(
					'bar_style' => 'gif',
					'bar_gif_type' => 'upload',
				),
			) );

			$gifs = array(
		        'pixelbuddha/64x64/dots-2d-rotate.gif' => __( '2D Rotating Dots', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dots-2d-rotate.gif' => __( '2D Rotating Dots', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dots-3d-rotate.gif' => __( '3D Rotating Dots', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dots-3d-rotate.gif' => __( '3D Rotating Dots', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dots-move.gif' => __( '4 Moving Dots', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dots-move.gif' => __( '4 Moving Dots', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dot-bounce.gif' => __( 'Bouncing Dot', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dot-bounce.gif' => __( 'Bouncing Dot', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dot-target.gif' => __( 'Dot Target', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dot-target.gif' => __( 'Dot Target', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dots-enlarge.gif' => __( 'Enlarged Dots', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dots-enlarge.gif' => __( 'Enlarged Dots', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dots-fade.gif' => __( 'Fading Line of Dots', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dots-fade.gif' => __( 'Fading Line of Dots', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dots-flip.gif' => __( 'Flipping Colors Dot', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dots-flip.gif' => __( 'Flipping Colors Dot', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/dot-fold.gif' => __( 'Folding Dot', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/dot-fold.gif' => __( 'Folding Dot', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/snake.gif' => __( 'Retro Snake', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'transparent', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/snake.gif' => __( 'Retro Snake', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'transparent', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/rotating-cube.gif' => __( 'Rotating Cube', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/rotating-cube.gif' => __( 'Rotating Cube', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/rubiks-cube.gif' => __( 'Rubik&apos;s Cube', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/rubiks-cube.gif' => __( 'Rubik&apos;s Cube', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/shuffle-cube.gif' => __( 'Shuffling Squares', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/shuffle-cube.gif' => __( 'Shuffling Squares', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/rotate-blur.gif' => __( 'Spinning Dots', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/rotate-blur.gif' => __( 'Spinning Dots', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/split-line.gif' => __( 'Square into Line', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/split-line.gif' => __( 'Square into Line', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/split-rotate.gif' => __( 'Square Splitting', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/split-rotate.gif' => __( 'Square Splitting', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'white', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/64x64/tetris.gif' => __( 'Tetris', GAMBIT_LOADING_BAR ) . ' (32x32 ' . __( 'transparent', GAMBIT_LOADING_BAR ) . ')',
		        'pixelbuddha/128x128/tetris.gif' => __( 'Tetris', GAMBIT_LOADING_BAR ) . ' (128x128 ' . __( 'transparent', GAMBIT_LOADING_BAR ) . ')',
			);
			$firstKey = array_keys( $gifs );
			$firstKey = $firstKey[0];
			$gifList = '<span style="display: block">';
			foreach ( $gifs as $path => $name ) {
				if ( false === stripos( $path, '64x64' ) ) {
					continue;
				}
				$path = plugins_url( 'the-loading-bar/images/' . $path, __FILE__ );
				preg_match( '/^([^\(]+)\s/', $name, $matches );
				$name = $matches[0];
				$gifList .= "<span><img src='{$path}'/><span>{$name}</span></span>";
			}
			$gifList .= '</span>';

			$panel->createOption( array(
			    'name' => __( 'Select Loading GIF animation', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_gif_select',
			    'type' => 'select',
			    'options' => $gifs,
				'default' => 'pixelbuddha/128x128/rubiks-cube.gif',
			    'desc' => sprintf( __( 'Select a GIF animation from this awesome list of preloaders created by %s. Note that only some of these have transparent backgrounds, most of them need your background to be white. The background color is indicated in the dropdown.', GAMBIT_LOADING_BAR ), '<a href="http://pixelbuddha.net/freebie/flat-preloaders" target="_blank">Pixel Buddha</a>' ) . $gifList,
				'depends' => array(
					'bar_style' => 'gif',
					'bar_gif_type' => 'included',
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Placement', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_location',
			    'type' => 'select',
			    'desc' => __( 'Select the location where to align your bar. You can use the margin setting below to fine tune the location of your loading bar.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'top-left' => __( 'Top Left', GAMBIT_LOADING_BAR ),
			        'top-center' => __( 'Top Center', GAMBIT_LOADING_BAR ),
			        'top-right' => __( 'Top Right', GAMBIT_LOADING_BAR ),
			        'middle-left' => __( 'Middle Left', GAMBIT_LOADING_BAR ),
					'middle-center' => __( 'Centered', GAMBIT_LOADING_BAR ),
					'middle-right' => __( 'Middle Right', GAMBIT_LOADING_BAR ),
					'bottom-left' => __( 'Bottom Left', GAMBIT_LOADING_BAR ),
					'bottom-center' => __( 'Bottom Center', GAMBIT_LOADING_BAR ),
					'bottom-right' => __( 'Bottom Right', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'middle-center',
				'depends' => array(
					'bar_style' => array( 'line', 'classic', 'circular', 'gif' ),
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Color', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_color',
			    'type' => 'color',
			    'desc' => __( 'The color of the progress bar', GAMBIT_LOADING_BAR ),
			    'default' => '#3498db',
				'depends' => array(
					'bar_style' => array( 'line', 'classic', 'fill', 'circular' ),
				),
				'css' => "#loading-bar-progress[data-style='line'],
					 	  #loading-bar-progress[data-style='fill'],
					 	  #loading-bar-progress[data-style='classic'],
					 	  #loading-bar-progress[data-style='classic'] > span { background-color: value }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Background Color', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_circular_bg_color',
			    'type' => 'color',
			    'desc' => __( 'The background color of the circular indicator, this is the unfilled part of the bar. Leave blank for transparent.', GAMBIT_LOADING_BAR ),
			    'default' => '',
				'depends' => array(
					'bar_style' => array( 'circular' ),
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Thickness', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_line_thickness',
			    'type' => 'number',
			    'desc' => __( 'The thickness of the loading bar line', GAMBIT_LOADING_BAR ),
			    'default' => '1',
				'min' => '1',
			    'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => array( 'line', 'classic', 'circular' ),
				),
				'css' => "#loading-bar-progress[data-style='line'],
					 	  #loading-bar-progress[data-style='classic'] { height: valuepx }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Width', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_classic_width',
			    'type' => 'number',
			    'desc' => __( 'The maximum width of your loading bar', GAMBIT_LOADING_BAR ),
			    'default' => '300',
				'min' => '0',
			    'max' => '600',
				'step' => '2',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => array( 'classic' ),
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Indicator Radius', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_circular_radius',
			    'type' => 'number',
			    'desc' => __( 'The radius of the circular indicator', GAMBIT_LOADING_BAR ),
			    'default' => '100',
				'min' => '50',
			    'max' => '400',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => array( 'circular' ),
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Margin', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_line_margin',
			    'type' => 'number',
			    'desc' => __( 'The side margins of the loading bar, you can use this to fine tune the position of your loading bar.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
			    'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => array( 'line' ),
				),
				'css' => "#loading-bar-progress[data-style='line'] { margin: valuepx 0 }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Margin Left & Right', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_line_margin_horizontal',
			    'type' => 'number',
			    'desc' => __( 'The left & right paddings of the loading bar. You can use this setting to push or pull your loading bar left or right', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
			    'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => array( 'classic', 'gif', 'circular' ),
				),
				'css' => "#loading-bar-progress[data-style='gif'],
						  #loading-bar-progress[data-style='classic'],
						  #loading-bar-progress[data-style='circular'] { margin-left: valuepx; margin-right: valuepx; }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Margin Top & Bottom', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_line_margin_vertical',
			    'type' => 'number',
			    'desc' => __( 'The top & bottom paddings of the loading bar. You can use this setting to push or pull your loading bar up or down', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
			    'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => array( 'classic', 'gif', 'circular' ),
				),
				'css' => "#loading-bar-progress[data-style='gif'],
						  #loading-bar-progress[data-style='classic'],
						  #loading-bar-progress[data-style='circular'] { margin-top: valuepx; margin-bottom: valuepx; }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Fill Direction', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_fill_direction',
			    'type' => 'select',
			    'desc' => __( 'The direction of the fill direction.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'up' => __( 'Bottom to top', GAMBIT_LOADING_BAR ),
			        'down' => __( 'Top to bottom', GAMBIT_LOADING_BAR ),
			        'left' => __( 'Right to left', GAMBIT_LOADING_BAR ),
			        'right' => __( 'Left to right', GAMBIT_LOADING_BAR ),
			        'horizontal' => __( 'Center to sides', GAMBIT_LOADING_BAR ),
			        'vertical' => __( 'Center to top and bottom', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'up',
				'depends' => array(
					'bar_style' => 'fill',
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Fill Image', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_fill_image',
			    'type' => 'upload',
			    'desc' => __( 'You can put an image inside your loading bar. The loading bar loads first so be mindful of your image file size, it should be small in order to be seen.', GAMBIT_LOADING_BAR ),
				'depends' => array(
					'bar_style' => 'fill',
				),
				'css' => "#loading-bar-progress[data-style='fill'] { background-image: value }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Fill Image Attachment', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_fill_image_attachment',
			    'type' => 'checkbox',
			    'desc' => __( 'Make the background image fixed (not moving)', GAMBIT_LOADING_BAR ),
				'default' => true,
				'depends' => array(
					'bar_style' => 'fill',
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Border Radius', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_classic_border_radius',
			    'type' => 'number',
			    'desc' => __( 'The roundness of the corners of your loading bar.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '0',
			    'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => 'classic',
				),
				'css' => "#loading-bar-progress[data-style='classic'],
						  #loading-bar-progress[data-style='classic'] * { border-radius: valuepx; }",
			) );

			$panel->createOption( array(
			    'name' => __( 'Classic Bar Type', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_classic_type',
			    'type' => 'select',
			    'desc' => __( 'The animation type to use for your bar', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'square' => __( 'A solid bar', GAMBIT_LOADING_BAR ),
			        'pop-bars' => __( 'Small bars that pop up', GAMBIT_LOADING_BAR ),
			        'grow-bars' => __( 'Small bars that grow', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'pop-bars',
				'depends' => array(
					'bar_style' => 'classic',
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Sections', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_classic_sections',
			    'type' => 'number',
			    'desc' => __( 'The number of sections to split the bar into', GAMBIT_LOADING_BAR ),
			    'default' => '10',
				'min' => '0',
			    'max' => '30',
				'step' => '2',
				'depends' => array(
					'bar_style' => 'classic',
					'bar_classic_type' => array( 'pop-bars', 'grow-bars' ),
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Bar Section Gap', GAMBIT_LOADING_BAR ),
			    'id' => 'bar_classic_section_gap',
			    'type' => 'number',
			    'desc' => __( 'The amount of gap between sections', GAMBIT_LOADING_BAR ),
			    'default' => '1',
				'min' => '0',
			    'max' => '10',
				'unit' => 'px',
				'depends' => array(
					'bar_style' => 'classic',
					'bar_classic_type' => array( 'pop-bars', 'grow-bars' ),
				),
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Page Loaded Transition', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Choose a Transition', GAMBIT_LOADING_BAR ),
			    'id' => 'transition',
			    'type' => 'select',
			    'desc' => __( 'The type of animation to play when your loading screen finishes and transitions into your site.<br><br><strong>If you have a single-page website, non-vertical transitions would perform better for your site.</strong>', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'fade' => __( 'Fade Out', GAMBIT_LOADING_BAR ),
			        'push-rotate-top' => __( 'Rotate / Push from Top', GAMBIT_LOADING_BAR ),
			        'push-rotate-bottom' => __( 'Rotate / Push from Bottom', GAMBIT_LOADING_BAR ),
			        'push-rotate-right' => __( 'Rotate / Push from Right', GAMBIT_LOADING_BAR ),
			        'push-rotate-left' => __( 'Rotate / Push from Left', GAMBIT_LOADING_BAR ),
			        'push-top-fade' => __( 'Fade / Push from Top', GAMBIT_LOADING_BAR ),
			        'push-bottom-fade' => __( 'Fade / Push from Bottom', GAMBIT_LOADING_BAR ),
			        'push-right-fade' => __( 'Fade / Push from Right', GAMBIT_LOADING_BAR ),
			        'push-left-fade' => __( 'Fade / Push from Left', GAMBIT_LOADING_BAR ),
			        'diff-easing-top' => __( 'Different Speed from Top', GAMBIT_LOADING_BAR ),
			        'diff-easing-bottom' => __( 'Different Speed from Bottom', GAMBIT_LOADING_BAR ),
			        'diff-easing-right' => __( 'Different Speed from Right', GAMBIT_LOADING_BAR ),
			        'diff-easing-left' => __( 'Different Speed from Left', GAMBIT_LOADING_BAR ),
			        'rotate-top-rotate-bottom' => __( 'Rotate Top / Rotate Bottom', GAMBIT_LOADING_BAR ),
			        'rotate-bottom-rotate-top' => __( 'Rotate Bottom / Rotate Top', GAMBIT_LOADING_BAR ),
			        'rotate-left-rotate-right' => __( 'Rotate Left / Rotate Right', GAMBIT_LOADING_BAR ),
			        'rotate-right-rotate-left' => __( 'Rotate Right / Rotate Left', GAMBIT_LOADING_BAR ),
			        'move-top' => __( 'Move from Top', GAMBIT_LOADING_BAR ),
			        'move-bottom' => __( 'Move from Bottom', GAMBIT_LOADING_BAR ),
			        'move-right' => __( 'Move from Right', GAMBIT_LOADING_BAR ),
			        'move-left' => __( 'Move from Left', GAMBIT_LOADING_BAR ),
			        'scale-up-scape-up' => __( 'Scale Up / Scale Up', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'push-bottom-fade',
			) );

			$panel->createOption( array(
			    'name' => '<div class="dashicons dashicons-admin-tools"></div> ' . __( 'Compatibility Mode', GAMBIT_LOADING_BAR ),
			    'id' => 'transition_compatibility_mode',
			    'type' => 'enable',
			    'desc' => __( 'In the majority of the transitions below, we adjust the structure of your site in order to create some cool animations. However, if you notice that your theme/site looks broken during the transition, your theme/site styles may be getting affected with our adjustments. In those cases, turn on compatibility mode.<br><br><strong>In compatibility mode, your site itself will NOT animate, only the loading screen will have animations and some transition opacities will not be applied.</strong><br><strong>Only turn this on when you are noticing problems during the finishing transitions.</strong>', GAMBIT_LOADING_BAR ),
				'default' => false,
				'enabled' => 'Compatibility mode',
				'disabled' => 'Normal mode',
			) );

			$panel->createOption( array(
			    'name' => __( 'Transition Delay', GAMBIT_LOADING_BAR ),
			    'id' => 'transition_delay',
			    'type' => 'number',
			    'desc' => __( 'You can add a short delay in milliseconds before the transition starts playing.', GAMBIT_LOADING_BAR ),
				'default' => '0',
				'min' => '0',
				'max' => '5000',
				'step' => '100',
				'unit' => 'milliseconds',
			) );

			$panel->createOption( array(
			    'name' => __( 'Transition Duration', GAMBIT_LOADING_BAR ),
			    'id' => 'transition_duration',
			    'type' => 'number',
			    'desc' => __( 'You can finetune the duration of the transition for a more dramatic effect here.', GAMBIT_LOADING_BAR ),
				'default' => '1000',
				'min' => '1000',
				'max' => '5000',
				'step' => '100',
				'unit' => 'milliseconds',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Placement', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Where to Show the Loading Bar?', GAMBIT_LOADING_BAR ),
			    'id' => 'where',
			    'type' => 'select',
			    'desc' => __( 'Choose the locations where your loading bar should show up. We recommend that you choose only your landing pages.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'all' => 'All Pages',
			        'homepage' => 'Homepage',
			        'select' => 'Let me select the pages, post and custom post types where to show it',
			    ),
			    'default' => 'homepage',
			) );

			$panel->createOption( array(
			    'name' => __( 'Pages with a Loading Bar', GAMBIT_LOADING_BAR ),
			    'id' => 'where_pages',
			    'type' => 'multicheck-pages',
			    'desc' => __( 'Choose specific pages that will show the loading bar. We recommend that you choose only your landing pages.', GAMBIT_LOADING_BAR ),
				'depends' => array(
					'where' => 'select',
				),
			) );

			$panel->createOption( array(
			    'name' => __( 'Posts with a Loading Bar', GAMBIT_LOADING_BAR ),
			    'id' => 'where_posts',
			    'type' => 'multicheck-posts',
			    'desc' => __( 'Choose specific posts that will show the loading bar. Choose wisely.', GAMBIT_LOADING_BAR ),
				'depends' => array(
					'where' => 'select',
				),
			) );

			// This section will add multiple checkbox for all detected custom post types and their posts.
			/**
			CURRENTLY DOES NOT WORK DUE TO get_post_types ALWAYS RETURNING BLANKS WHEN $args IS SPECIFIED!!!!!!!
			$cpts = $this->gambit_tlb_cpt();
			if ( count( $cpts ) > 0 ) {
				foreach ( $cpts as $eachCPT ) {
					$panel->createOption( $eachCPT );
				}

				// A holding area for a list of custom post types.
				$panel->createOption( array(
					'name' => __( 'Custom Post Types detected', GAMBIT_LOADING_BAR ),
					'id' => 'where_cpts',
					'type' => 'text',
					'placeholder' => implode( ',', $this->gambit_tlb_cpt( 'csv' ) ),
				) );
			}
			*/

			// A workaround for custom post types.
			$panel->createOption( array(
				'name' => __( 'Posts from Custom Post Types with a Loading Bar', GAMBIT_LOADING_BAR ),
				'id' => 'where_custom',
				'type' => 'textarea',
				'desc' => __( 'Enter the Post ID (a number found in the URL while editing) of the custom post type that you want to apply The Loading Bar. Separate each entry in a new line.', GAMBIT_LOADING_BAR ),
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Loading Bar Skipping', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Skip button', GAMBIT_LOADING_BAR ),
			    'id' => 'use_skip_button',
			    'type' => 'enable',
			    'desc' => __( 'Check this to display a link that will allow users to skip the loading bar.', GAMBIT_LOADING_BAR ),
			    'default' => false,
				'enabled' => __( 'Show Skip Link', GAMBIT_LOADING_BAR ),
				'disabled' => __( 'Hide Skip Link', GAMBIT_LOADING_BAR ),
			) );

			$panel->createOption( array(
			    'name' => __( 'Display delay', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_display_delay',
			    'type' => 'number',
			    'desc' => __( 'Indicate the delay in seconds before the skip button appears.', GAMBIT_LOADING_BAR ),
			    'default' => '3',
				'min' => '0',
				'max' => '60',
				'unit' => 'seconds',
				'depends' => array(
					'use_skip_button' => true,
				),
			) );

			$panel->createOption( array(
				'name' => __( 'Text Caption', GAMBIT_LOADING_BAR ),
				'id' => 'skip_text_caption',
				'type' => 'textarea',
				'default' => 'Click here to skip loading.',
				'desc' => 'Add text to be displayed during loading.',
			) );

			$panel->createOption( array(
			    'name' => __( 'Text Font', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_font',
			    'type' => 'font',
			    'desc' => __( 'Select the font to use for the text. We recommend choosing a <strong>web safe font</strong> so that the loading screen will load faster. Using a Google WebFont will delay the appearance of the loading bar since the font file would have to be loaded also.', GAMBIT_LOADING_BAR ),
				'default' => array(
			        'font-family' => '"Trebuchet MS", Helvetica, sans-serif',
			        'color' => '#333333',
			        'font-size' => '40px',
			        'line-height' => '1em',
			    ),
				'css' => '.skip-button-link { value }',
				'depends' => array(
					'use_skip_button' => true,
				),
			) );
			$panel->createOption( array(
			    'name' => __( 'Hyperlink Color', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_hyperlink_color',
			    'type' => 'color',
			    'desc' => __( 'Select the color of the hyperlink for the skip button.', GAMBIT_LOADING_BAR ),
			    'default' => '#333333',
				'css' => '.skip-button-link, .skip-button-link:visited, .skip-button-link:active, .skip-button-link:hover { color: value }',
			) );
			$panel->createOption( array(
			    'name' => __( 'Background Color', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_bg_color',
			    'type' => 'color',
			    'desc' => __( 'The background color of the skip button. Leave blank for transparent.', GAMBIT_LOADING_BAR ),
			    'default' => '',
				'css' => '.skip-button-link { background-color: value }',
			) );
			$panel->createOption( array(
			    'name' => __( 'Border Radius', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_border-radius',
			    'type' => 'number',
			    'desc' => __( 'If desired, specify the border radius for the skip button. Only works if you have defined a background color.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '0',
				'max' => '100',
				'unit' => 'px',
				'css' => '.skip-button-link { border-radius: valuepx; }',
			) );

			$panel->createOption( array(
			    'name' => __( 'Text Placement', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_location',
			    'type' => 'select',
			    'desc' => __( 'The alignment of the text within the screen. You can use the margin settings below to fine tune the location of the text.', GAMBIT_LOADING_BAR ),
			    'options' => array(
			        'top-left' => __( 'Top Left', GAMBIT_LOADING_BAR ),
			        'top-center' => __( 'Top Center', GAMBIT_LOADING_BAR ),
			        'top-right' => __( 'Top Right', GAMBIT_LOADING_BAR ),
			        'middle-left' => __( 'Middle Left', GAMBIT_LOADING_BAR ),
					'middle-center' => __( 'Centered', GAMBIT_LOADING_BAR ),
					'middle-right' => __( 'Middle Right', GAMBIT_LOADING_BAR ),
					'bottom-left' => __( 'Bottom Left', GAMBIT_LOADING_BAR ),
					'bottom-center' => __( 'Bottom Center', GAMBIT_LOADING_BAR ),
					'bottom-right' => __( 'Bottom Right', GAMBIT_LOADING_BAR ),
			    ),
			    'default' => 'bottom-right',
				'depends' => array(
					'use_skip_button' => true,
				),
			) );
			$panel->createOption( array(
			    'name' => __( 'Margin Left & Right', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_margin_horizontal',
			    'type' => 'number',
			    'desc' => __( 'The left & right paddings of the text. You can use this setting to push or pull your text left or right.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
				'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'use_skip_button' => true,
				),
				'css' => '.skip-button-link { margin-left: valuepx; margin-right: valuepx; }',
			) );

			$panel->createOption( array(
			    'name' => __( 'Margin Top & Bottom', GAMBIT_LOADING_BAR ),
			    'id' => 'skip_text_margin_vertical',
			    'type' => 'number',
			    'desc' => __( 'The top & bottom paddings of the text. You can use this setting to push or pull your text up or down.', GAMBIT_LOADING_BAR ),
			    'default' => '0',
				'min' => '-100',
				'max' => '300',
				'unit' => 'px',
				'depends' => array(
					'use_skip_button' => true,
				),
				'css' => '.skip-button-link { margin-top: valuepx; margin-bottom: valuepx; }',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Custom CSS and JavaScript', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Custom CSS', GAMBIT_LOADING_BAR ),
			    'id' => 'custom_css',
			    'type' => 'code',
			    'desc' => __( 'If you want to style The Loading Bar further, you can add here your additional CSS rules. The loading bar is split into just 3 elements, to make things easier, here they are:<br><ul><li><code>#loading-bar-container</code> - This is the main container the spans the whole page and is the background,</li><li><code>#loading-bar-label</code> - The progress percentage text label, and</li><li><code>#loading-bar-progress</code> - The bar itself, this is the one that&apos;s moving.</li></ul>', GAMBIT_LOADING_BAR ),
			    'lang' => 'css',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			$panel->createOption( array(
			    'name' => __( 'Custom Javascript', GAMBIT_LOADING_BAR ),
			    'type' => 'heading',
			) );

			$panel->createOption( array(
			    'name' => __( 'Custom Javascript', GAMBIT_LOADING_BAR ),
			    'id' => 'custom_js',
			    'type' => 'code',
			    'desc' => __( 'If you have other stuff you want The Loading Bar to wait on, you can add additional Javascript code here if you don&apos;t have an area to do so. You can make TLB wait for other stuff to load by using these snippets in tandem with each other:<br><pre><code>document.addEventListener(\'DOMContentLoaded\', function() {<br>window.dispatchEvent(new Event(\'tlb-wait\'));<br>});</code></pre><br><p class="description">This lets TLB know that you want it to wait for something. afterwards, you will need to put the following code somewhere that gets triggered when your something finishes loading (e.g. in a success handler for an ajax call):</p><pre><code>window.dispatchEvent(new Event(\'tlb-done\'))</code></pre><p class="description"><strong>Each <code>tlb-wait</code> needs to be paired with a <code>tlb-done</code>, or else the loading page will not hide itself.</strong>', GAMBIT_LOADING_BAR ),
			    'lang' => 'javascript',
			) );

			$panel->createOption( array(
			    'type' => 'save',
			) );

			// Include our necessary styles.
			$titan->createCSS( '
                body {
                    visibility: hidden !important;
					overflow: hidden;
                }
                #loading-bar-container {
                    position: fixed;
                    top: 0;
                    bottom: 0;
                    left: 0;
                    right: 0;
                    z-index: 9999999;
                    background-position: center center;
                    overflow: hidden;
                }
                #loading-bar-label, #loading-bar-progress, #loading-bar-text {
                    -moz-box-sizing: border-box;
                    box-sizing: border-box;
                    position: absolute;
                    z-index: 1;
                }
                #loading-bar-progress {
                    z-index: 0;
                    white-space: nowrap;
                }
                #loading-bar-progress > span {
                    vertical-align: top;
                    height: 100%;
                }
                ' .
				// Fix for VC fade animations showing up while prior to being animated.
			'#loading-bar-body-animator [data-animate*="fadeIn"]  { opacity: 0 !important; }' );
		}


		/**
		 * Checks whether the current page should have a loading bar.
		 *
		 * @return	boolean - True if there should be a loading bar.
		 * @since	1.0
		 */
		protected function current_page_has_loading_bar() {
			$titan = TitanFramework::getInstance( GAMBIT_LOADING_BAR );

			if ( ! $titan->getOption( 'enable' ) ) {
				return false;
			}

			$where = $titan->getOption( 'where' );

			if ( 'all' == $where ) {
				return true;

			} else if ( 'homepage' == $where ) {
				if ( is_front_page() ) {
					return true;
				}
			} else { // Select.
				if ( in_array( get_the_ID(), $titan->getOption( 'where_pages' ) ) ) {
					return true;
				} elseif ( in_array( get_the_ID(), $titan->getOption( 'where_posts' ) ) ) {
					return true;
				}

				/** CURRENTLY DOES NOT WORK DUE TO get_post_types ALWAYS RETURNING BLANKS WHEN $args IS SPECIFIED!!!!!!!
				$theCPTs = explode( ',', $titan->getOption( 'where_cpts' ) );
				if ( count( $theCPTs ) > 0 ) {
					foreach ( $theCPTs as $eachCPT ) {
						if ( in_array( get_the_ID(), $titan->getOption( 'where_' . $eachCPT ) ) ) {
							return true;
						}
					}
				}
				*/

				$theCPTs = explode( PHP_EOL, $titan->getOption( 'where_custom' ) );
				if ( count( $theCPTs ) > 0 ) {
					foreach ( $theCPTs as $eachCPT ) {
						if ( get_the_ID() == $eachCPT && ( ! is_front_page() && ! is_home() ) ) {
							return true;
						}
					}
				}
			}

			return false;
		}


		/**
		 * Shows the loading bar.
		 *
		 * @return	void
		 * @since	1.0
		 */
		public function hide_the_page() {
			if ( ! $this->current_page_has_loading_bar() ) {
				return;
			}

			if ( ! class_exists( 'TitanFramework' ) ) {
				return;
			}

			$titan = TitanFramework::getInstance( GAMBIT_LOADING_BAR );

			echo '<style>';

			echo $titan->generateCSS();

			$useLabel = $titan->getOption( 'use_label' );
			if ( ! empty( $useLabel ) ) {

				$labelLocation = $titan->getOption( 'label_location' );
				$labelFont = $titan->getOption( 'label_font' );

				$labelStyles = '';

				if ( false !== stripos( $labelLocation, 'bottom' ) ) {
					$labelStyles .= 'bottom: 0;';
				} elseif ( false !== stripos( $labelLocation, 'middle' ) ) {
					$labelStyles .= 'top: calc(50% - ' . $labelFont['line-height'] . ' / 2);';
				}

				if ( false !== stripos( $labelLocation, 'center' ) ) {
					$labelStyles .= 'text-align: center; left: 0; right: 0;';
				} elseif ( false !== stripos( $labelLocation, 'right' ) ) {
					$labelStyles .= 'text-align: right; right: 0;';
				} else {
					$labelStyles .= 'text-align: left; left: 0;';
				}

				echo "#loading-bar-label {
					$labelStyles
				}";
			}

			$useText = $titan->getOption( 'use_loadingbar_text' );
			if ( ! empty( $useText ) ) {

				$textLocation = $titan->getOption( 'loadingbar_text_location' );
				$textFont = $titan->getOption( 'loadingbar_text_font' );

				$textStyles = '';

				if ( false !== stripos( $textLocation, 'bottom' ) ) {
					$textStyles .= 'bottom: 0;';
				} elseif ( false !== stripos( $textLocation, 'middle' ) ) {
					$textStyles .= 'top: calc(50% - ' . $textFont['line-height'] . ' / 2);';
				}

				if ( false !== stripos( $textLocation, 'center' ) ) {
					$textStyles .= 'text-align: center; left: 0; right: 0;';
				} elseif ( false !== stripos( $textLocation, 'right' ) ) {
					$textStyles .= 'text-align: right; right: 0;';
				} else {
					$textStyles .= 'text-align: left; left: 0;';
				}

				echo "#loading-bar-text {
					$textStyles
				}";
			}

			include( 'the-loading-bar/lib/transitions.php' );

			echo '</style>';

			$barStyle = $titan->getOption( 'bar_style' );
			if ( ! empty( $barStyle ) && 'none' != $barStyle ) {
				include( 'the-loading-bar/bar/bar-' . $barStyle . '.php' );
			}

			// Load skip button elements if enabled.
			if ( $titan->getOption( 'use_skip_button' ) ) {
				include( 'the-loading-bar/lib/skip.php' );
			}
		}


		/**
		 * Enqueues the loading bar scripts.
		 *
		 * @return	void
		 * @since	1.0
		 */
		public function enqueue_loading_bar() {
			if ( ! $this->current_page_has_loading_bar() ) {
				return;
			}

			if ( ! class_exists( 'TitanFramework' ) ) {
				return;
			}

			$titan = TitanFramework::getInstance( GAMBIT_LOADING_BAR );

			if ( 'circular' == $titan->getOption( 'bar_style' ) ) {
				wp_enqueue_script( 'loading-bar-circular', plugins_url( 'the-loading-bar/js/min/circles-min.js', __FILE__ ), array( 'jquery' ), VERSION_GAMBIT_LOADING_BAR, false );
			}

			wp_enqueue_script( 'loading-bar', plugins_url( 'the-loading-bar/js/min/script-min.js', __FILE__ ), array( 'jquery' ), VERSION_GAMBIT_LOADING_BAR, false );
			wp_localize_script( 'loading-bar', 'loadingBarObj', array(
				'use_label' => $titan->getOption( 'use_label' ),
				'use_loadingbar_text' => $titan->getOption( 'use_loadingbar_text' ),
				'loadingbar_text_caption' => $titan->getOption( 'loadingbar_text_caption' ),
				'bar_style' => $titan->getOption( 'bar_style' ),
				'bar_location' => $titan->getOption( 'bar_location' ),
				'bar_fill_direction' => $titan->getOption( 'bar_fill_direction' ),
				'testing_mode' => $titan->getOption( 'testing_mode' ),
				'testing_mode_halt' => $titan->getOption( 'testing_mode_halt' ),
				'force_overflow' => $titan->getOption( 'force_overflow' ),
				'bar_classic_type' => $titan->getOption( 'bar_classic_type' ),
				'bar_classic_sections' => $titan->getOption( 'bar_classic_sections' ),
				'bar_transition_speed' => $titan->getOption( 'bar_transition_speed' ),
				'transition_compatibility_mode' => $titan->getOption( 'transition_compatibility_mode' ),
				'transition' => $titan->getOption( 'transition' ),
				'load_once' => $titan->getOption( 'load_once' ),
				'transition_delay' => $titan->getOption( 'transition_delay' ),
				'transition_duration' => $titan->getOption( 'transition_duration' ),
				'domains' => $titan->getOption( 'domains' ),
				'disable_mobile' => $titan->getOption( 'disable_mobile' ),
				'use_skip_button' => $titan->getOption( 'use_skip_button' ),
				'skip_text_display_delay' => $titan->getOption( 'skip_text_display_delay' ),
				'skip_text_caption' => $titan->getOption( 'skip_text_caption' ),
				'skip_text_font' => $titan->getOption( 'skip_text_font' ),
				'skip_text_location' => $titan->getOption( 'skip_text_location' ),
				'skip_text_margin_horizontal' => $titan->getOption( 'skip_text_margin_horizontal' ),
				'skip_text_margin_vertical' => $titan->getOption( 'skip_text_margin_vertical' ),
			) );

		}


		/**
		 * Loads necessary styles for the admin section.
		 **/
		public function enqueue_admin_scripts() {
			wp_enqueue_style( 'loading-bar-admin', plugins_url( 'the-loading-bar/css/admin.css', __FILE__ ), array(), VERSION_GAMBIT_LOADING_BAR );
		}


		/**
		 * Adds plugin settings link.
		 *
		 * @access	public
		 * @param	array  $links - The current set of links.
		 * @param   string $pluginFile - The file module to use.
		 * @since	1.0
		 **/
		public function plugin_settings_link( $links, $pluginFile ) {

			if ( ! class_exists( 'TitanFramework' ) ) {
				return $links;
			}

			// Get this plugin's base folder.
			static $plugin;
			if ( ! isset( $plugin ) ) {
				$plugin = plugin_basename( __FILE__ );
				$plugin = trailingslashit( dirname( $plugin ) );
			}

			// If we are in the links of our plugin, add the settings link.
			if ( false !== stripos( $pluginFile, $plugin ) ) {
				$settingsURL = admin_url( 'options-general.php?page=options-general.php-the-loading-bar' );

				array_unshift( $links, '<a href="' . $settingsURL . '">' . __( 'Settings', GAMBIT_LOADING_BAR ) . '</a>' );

			}

			return $links;
		}
	}
	new GambitLoadingBar();
}