getURL() public static method

Acts the same way as plugins_url( 'script', __FILE__ ) but returns then correct url when called from inside a theme.
Since: 1.1.2
public static getURL ( string $script, string $file ) : string
$script string the script to get the url to, relative to $file.
$file string the current file, should be __FILE__.
return string the url to $script
 /**
  * Enqueues the jQuery UI scripts
  *
  * @return	void
  * @since	1.4
  */
 public function enqueueDatepicker()
 {
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-slider');
     wp_enqueue_script('jquery-ui-datepicker');
     wp_enqueue_script('tf-jquery-ui-timepicker-addon', TitanFramework::getURL('js/min/jquery-ui-timepicker-addon-min.js', __FILE__), array('jquery-ui-datepicker', 'jquery-ui-slider'));
 }
 public function loadUploaderScript()
 {
     wp_enqueue_media();
     wp_enqueue_script('tf-theme-customizer-serialize', TitanFramework::getURL('js/serialize.js', __FILE__));
     wp_enqueue_style('tf-admin-theme-customizer-styles', TitanFramework::getURL('css/admin-theme-customizer-styles.css', __FILE__));
     wp_enqueue_style('tf-font-awesome', TitanFramework::getURL('css/font-awesome/css/font-awesome.min.css', __FILE__));
 }
 public function loadUploaderScript()
 {
     wp_enqueue_media();
     wp_enqueue_script('tf-theme-customizer-admin', TitanFramework::getURL('js/admin.js', __FILE__));
     wp_enqueue_style('tf-admin-theme-customizer-styles', TitanFramework::getURL('css/admin.css', __FILE__));
     wp_enqueue_script('tf-theme-customizer-jquery.fileDownload', TitanFramework::getURL('js/jquery.fileDownload.js', __FILE__));
     wp_enqueue_script('tf-theme-customizer-serialize', TitanFramework::getURL('js/serialize.js', __FILE__));
     wp_enqueue_style('tf-admin-theme-customizer-styles', TitanFramework::getURL('css/admin-theme-customizer-styles.css', __FILE__));
 }
Exemplo n.º 4
0
 /**
  * Enqueues the jQuery UI scripts
  *
  * @return	void
  * @since	1.4
  */
 public function enqueueDatepicker()
 {
     //		global $wp_scripts;
     //		$jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2';
     //		wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version );
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-slider');
     wp_enqueue_script('jquery-ui-datepicker');
     wp_enqueue_script('tf-jquery-ui-timepicker-addon', TitanFramework::getURL('js/jquery-ui-timepicker-addon.js', __FILE__), array('jquery-ui-datepicker', 'jquery-ui-slider'));
 }
Exemplo n.º 5
0
 public function loadUploaderScript()
 {
     wp_enqueue_media();
     wp_enqueue_script('tf-theme-customizer-serialize', TitanFramework::getURL('../js/min/serialize-min.js', __FILE__));
     wp_enqueue_style('tf-admin-theme-customizer-styles', TitanFramework::getURL('../css/admin-theme-customizer-styles.css', __FILE__));
 }
Exemplo n.º 6
0
 /**
  * Loads the ACE library for displaying our syntax highlighted code editor
  *
  * @return	void
  * @since	1.3
  */
 public function loadAdminScripts()
 {
     wp_enqueue_script('tf-ace', TitanFramework::getURL('js/ace-min-noconflict/ace.js', __FILE__));
     wp_enqueue_script('tf-ace-theme-' . $this->settings['theme'], TitanFramework::getURL('js/ace-min-noconflict/theme-' . $this->settings['theme'] . '.js', __FILE__));
     wp_enqueue_script('tf-ace-mode-' . $this->settings['lang'], TitanFramework::getURL('js/ace-min-noconflict/mode-' . $this->settings['lang'] . '.js', __FILE__));
 }
 public function loadAdminScripts()
 {
     wp_enqueue_media();
     wp_enqueue_script('tf-serialize', TitanFramework::getURL('js/serialize.js', __FILE__));
     wp_enqueue_script('tf-styling', TitanFramework::getURL('js/admin-styling.js', __FILE__));
     wp_enqueue_style('tf-admin-styles', TitanFramework::getURL('css/admin-styles.css', __FILE__));
     wp_enqueue_style('tf-font-awesome', TitanFramework::getURL('css/font-awesome/css/font-awesome.min.css', __FILE__));
 }
    /**
     * Creates the Javascript for running the font option
     *
     * @return	void
     * @since	1.4
     */
    public static function createFontScript()
    {
        if (!self::$firstLoad) {
            return;
        }
        self::$firstLoad = false;
        ?>
		<script>
		jQuery(document).ready(function($) {
			"use strict";

			var _tf_select_font_throttle = null;

			// Initialize color pickers
			$('.tf-font .tf-font-sel-color, .tf-font .tf-font-sel-shadow-color').wpColorPicker({
				change: function ( event, ui ) {
					// update the preview, but throttle it to prevent fast loading
					if ( _tf_select_font_throttle != null ) {
						clearTimeout( _tf_select_font_throttle );
						_tf_select_font_throttle = null;
					}
					var $this = $(this);
					_tf_select_font_throttle = setTimeout( function() {
						tf_select_font_update_preview( $this.parents('.tf-font:eq(0)'), true );
					}, 300 );
				}
			});


			// Initialize the option
			$('.tf-font').each(function() {

				// Update save field on change
				$(this).find('select,.tf-font-sel-dark').change(function() {
					tf_select_font_update_preview( $(this).parents('.tf-font:eq(0)'), true );
				});

				// Trigger for toggling light/dark preview backgrounds
				$(this).find('.btn-dark').click(function() {
					var darkInput = $(this).parent().find('.tf-font-sel-dark');
					if ( darkInput.val() == '' ) {
						darkInput.val('dark').trigger('change');
					} else {
						darkInput.val('').trigger('change');
					}
				})

				// initialize preview
				tf_select_font_update_preview( $(this), true );

				// We have to do this after 1ms for the theme customizer, or else the field's value
				// gets changed to a weird value
				var $this = $(this);
				setTimeout( function() {
					tf_select_font_update_preview( $this, false )
				}, 1 );
			});

			$('body.wp-customizer').on('click', function(e) {
				$('.tf-font .wp-color-result').each(function() {
					if ( $(this).hasClass('wp-picker-open') ) {
						$(this).parents('label:eq(0)').addClass('tf-picker-open');
					} else {
						if ( $(this).parents('label:eq(0)').hasClass('tf-picker-open') ) {
							$(this).parents('label:eq(0)').removeClass('tf-picker-open');
						}
					}
				});
			});
		});


		// Updates the option elements
		function tf_select_font_update_preview( $container, doTrigger ) {
			"use strict";
			var $ = jQuery;

			// Show / hide shadow fields
			if ( $container.find(".tf-font-sel-location").val() == 'none'
				 || $container.find('.tf-font-sel-location').parents('label:eq(0)').attr('data-visible') == 'false' ) {
				$container.find(".tf-font-sel-distance").parents('label:eq(0)').fadeOut();
				$container.find(".tf-font-sel-blur").parents('label:eq(0)').fadeOut();
				$container.find(".tf-font-sel-shadow-color").parents('label:eq(0)').fadeOut();
				$container.find(".tf-font-sel-opacity").parents('label:eq(0)').fadeOut();
			} else {
				$container.find(".tf-font-sel-distance").parents('label:eq(0)').fadeIn();
				$container.find(".tf-font-sel-blur").parents('label:eq(0)').fadeIn();
				$container.find(".tf-font-sel-shadow-color").parents('label:eq(0)').fadeIn();
				$container.find(".tf-font-sel-opacity").parents('label:eq(0)').fadeIn();
			}

			var family = $container.find('.tf-font-sel-family').val();

			// These are all our parameters
			var params = {
				'font-family': family,
				'font-type': $container.find(".tf-font-sel-family option[value='" + family + "']").parent().attr('class'),
				'color': $container.find(".tf-font-sel-color").val(),
				'font-size': $container.find(".tf-font-sel-size").val(),
				'font-weight': $container.find(".tf-font-sel-weight").val(),
				'font-style': $container.find(".tf-font-sel-style").val(),
				'line-height': $container.find(".tf-font-sel-height").val(),
				'letter-spacing': $container.find(".tf-font-sel-spacing").val(),
				'text-transform': $container.find(".tf-font-sel-transform").val(),
				'font-variant': $container.find(".tf-font-sel-variant").val(),
				'text-shadow-location': $container.find(".tf-font-sel-location").val(),
				'text-shadow-distance': $container.find(".tf-font-sel-distance").val(),
				'text-shadow-blur': $container.find(".tf-font-sel-blur").val(),
				'text-shadow-color': $container.find(".tf-font-sel-shadow-color").val(),
				'text-shadow-opacity': $container.find(".tf-font-sel-opacity").val(),
				'dark': $container.find(".tf-font-sel-dark").val(),
				'text': $container.find("iframe").attr('data-preview-text')
			}

			// Update preview
			if ( $container.find('iframe').is(':not([data-visible=false])') ) {
				$container.find('iframe').attr('src', '<?php 
        echo TitanFramework::getURL('iframe-font-preview.php?', __FILE__);
        ?>
' + $.param(params) );
			}

			// Update hidden save field
			$container.find('.tf-for-saving').val(serialize(params));
			if ( doTrigger ) {
				$container.find('.tf-for-saving').trigger('change');
			}
		}
		</script>
		<?php 
    }
 /**
  * Loads all the admin scripts used by Titan Framework
  *
  * @since 1.0
  *
  * @param string $hook The slug of admin page that called the enqueue.
  *
  * @return void
  */
 public function loadAdminScripts($hook)
 {
     // Get all options panel IDs.
     $panel_ids = array();
     if (!empty($this->mainContainers['admin-page'])) {
         foreach ($this->mainContainers['admin-page'] as $admin_panel) {
             $panel_ids[] = $admin_panel->panelID;
         }
     }
     // Only enqueue scripts if we're on a Titan options page.
     if (in_array($hook, $panel_ids) || !empty($this->mainContainers['meta-box'])) {
         wp_enqueue_media();
         wp_enqueue_script('tf-serialize', TitanFramework::getURL('../js/min/serialize-min.js', __FILE__));
         wp_enqueue_script('tf-styling', TitanFramework::getURL('../js/min/admin-styling-min.js', __FILE__));
         wp_enqueue_style('tf-admin-styles', TitanFramework::getURL('../css/admin-styles.css', __FILE__));
     }
 }
 public function loadAdminScripts($hook)
 {
     // Get all options panel IDs
     $panel_ids = array();
     foreach ($this->adminPanels as $admin_panel) {
         $panel_ids[] = $admin_panel->panelID;
     }
     // Only enqueue scripts if we're on a Titan options page
     if (in_array($hook, $panel_ids) || count($this->metaBoxes)) {
         wp_enqueue_media();
         wp_enqueue_script('tf-serialize', TitanFramework::getURL('js/serialize.js', __FILE__));
         wp_enqueue_script('tf-styling', TitanFramework::getURL('js/admin-styling.js', __FILE__));
         wp_enqueue_style('tf-admin-styles', TitanFramework::getURL('css/admin-styles.css', __FILE__));
     }
 }
 /**
  * Load the multicheck-selectall script
  *
  * @since 1.11
  * @return void
  */
 public function load_select_scripts()
 {
     wp_enqueue_script('tf-multicheck-select-all', TitanFramework::getURL('../js/multicheck-select-all.js', __FILE__), array('jquery'), TF_VERSION, true);
 }
 /**
  * Enqueue the colorpicker scripts
  *
  * @since 1.9
  *
  * @return void
  */
 public function enqueueColorPickerScript()
 {
     wp_enqueue_script('wp-color-picker');
     wp_enqueue_style('wp-color-picker');
     wp_enqueue_script('wp-color-picker-alpha', TitanFramework::getURL('../js/min/wp-color-picker-alpha-min.js', __FILE__), array('wp-color-picker'), TF_VERSION);
 }
    public function display()
    {
        $this->echoOptionHeader(true);
        // set a default value
        $value = $this->getValue();
        if (is_serialized($value)) {
            $value = unserialize($value);
        }
        if ($value == array() || empty($value['name']) || empty($value['variants']) || empty($value['subsets'])) {
            $value = array('name' => 'Open Sans', 'variants' => array('400'), 'subsets' => array('latin'));
        }
        if (self::$firstLoad) {
            self::$firstLoad = false;
            self::createScript();
        }
        $allFonts = titan_get_googlefonts();
        ?>
<select class='tf-select-googlefont'><?php 
        foreach ($allFonts as $key => $fontStuff) {
            printf("<option value='%s' data-subset='%s' data-variants='%s'>%s</option>", esc_attr($key), esc_attr(json_encode($fontStuff['subsets'])), esc_attr(json_encode($fontStuff['variants'])), $fontStuff['name']);
        }
        ?>
</select><?php 
        // preview
        printf("<iframe src='%s'></iframe>", TitanFramework::getURL('iframe-googlefont-preview.php?f=' . $value['name'], __FILE__));
        // select variants
        echo "<p class='description tf-variants'>Choose the styles to include:</p>";
        echo "<fieldset>";
        $allVariants = array('100', '100italic', '200', '200italic', '300', '300italic', '400', 'italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic');
        foreach ($allVariants as $key => $variant) {
            printf("<label style='display: none'><input type='checkbox' class='variant' data-variant='%s'/> %s</label>", esc_attr($variant), self::getVariantName($variant));
        }
        echo "</fieldset>";
        // select charsets
        echo "<p class='description tf-subsets'>Choose the subsets to include:</p>";
        echo "<fieldset>";
        $allSubsets = array("latin", "latin-ext", "greek", "vietnamese", "cyrillic", "cyrillic-ext", "khmer", "greek-ext");
        foreach ($allSubsets as $key => $subset) {
            printf("<label style='display: none'><input type='checkbox' class='subset' data-subset='%s'/> %s</label>", esc_attr($subset), $subset);
        }
        echo "</fieldset>";
        if (!is_serialized($value)) {
            $value = serialize($value);
        }
        printf("<input type='hidden' value='%s' name='%s' class='large-text'/>", esc_attr($value), esc_attr($this->getID()));
        $this->echoOptionFooter(false);
    }
 /**
  * Adds the our shortcode drop down plugin to TinyMCE
  *
  * @param 	array $plugins a list of enabled plugins in TinyMCE
  * @return	array TinyMCE plugins
  * @since	1.0
  **/
 public function addTinyMCEPlugin($plugins)
 {
     if (empty($plugins[self::JS_SHORTCODE_VAR])) {
         $plugins[self::JS_SHORTCODE_VAR] = TitanFramework::getURL('admin-shortcodes.js', __FILE__);
     }
     return $plugins;
 }
Exemplo n.º 15
0
    /**
     * Creates the Javascript for running the font option
     *
     * @return	void
     * @since	1.4
     */
    public static function createFontScript()
    {
        if (!self::$firstLoad) {
            return;
        }
        self::$firstLoad = false;
        ?>
		<script>
		jQuery(document).ready(function($) {
			"use strict";

			var _tf_select_font_throttle = null;

			// Initialize color pickers
			Color.prototype.toString = function(remove_alpha) {
				if (remove_alpha == 'no-alpha') {
					return this.toCSS('rgba', '1').replace(/\s+/g, '');
				}
				if (this._alpha < 1) {
					return this.toCSS('rgba', this._alpha).replace(/\s+/g, '');
				}
				var hex = parseInt(this._color, 10).toString(16);
				if (this.error) return '';
				if (hex.length < 6) {
					for (var i = 6 - hex.length - 1; i >= 0; i--) {
						hex = '0' + hex;
					}
				}
				return '#' + hex;
			};
			 
			jQuery('.color-picker-hex').each(function() {
				var $control = jQuery(this),
					value = $control.val().replace(/\s+/g, '');
				// Manage Palettes
				var palette_input = $control.attr('data-palette');
				if (palette_input == 'false' || palette_input == false) {
					var palette = false;
				} else if (palette_input == 'true' || palette_input == true) {
					var palette = true;
				} else {
					var palette = true;
					var palette = <?php 
        global $primary_color;
        echo $primary_color ? $primary_color : "true";
        ?>
;
				}
				$control.wpColorPicker({ // change some things with the color picker
					 clear: function(event, ui) {
					// TODO reset Alpha Slider to 100
					 },
					change: function(event, ui) {
						
						if (!$control.hasClass("tf-font-sel-color")) {
							// send ajax request to wp.customizer to enable Save & Publish button
							var _new_value = ui.color.toString();
							var key = $control.attr('data-customize-setting-link');
							try {
								wp.customize(key, function(obj) {
									//console.log(_new_value+ " - " +ui.color);
									obj.set(_new_value);
								});
							} catch(err) {
								console.log(err);
							}
						}else {
							// update the preview, but throttle it to prevent fast loading
							if (_tf_select_font_throttle != null) {
								clearTimeout(_tf_select_font_throttle);
								_tf_select_font_throttle = null;
							}
							var $this = $(this);
							_tf_select_font_throttle = setTimeout(function () {
								tf_select_font_update_preview($this.parents('.tf-font:eq(0)'), true);
							}, 300);
						}

						// change the background color of our transparency container whenever a color is updated
						var $transparency = $control.parents('.wp-picker-container:first').find('.transparency');

						// we only want to show the color at 100% alpha
						$transparency.css('backgroundColor', ui.color.toString('no-alpha'));
					},
					palettes: palette // remove the color palettes
				});
				jQuery('<div class="thim-alpha-container"><div class="slider-alpha"></div><div class="transparency"></div></div>').appendTo($control.parents('.wp-picker-container').find(".wp-picker-holder"));
				var $alpha_slider = $control.parents('.wp-picker-container:first').find('.slider-alpha');
				// if in format RGBA - grab A channel value
				if (value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)) {
					var alpha_val = parseFloat(value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)[1]) * 100;
					var alpha_val = parseInt(alpha_val);
				} else {
					var alpha_val = 100;
				}
				$alpha_slider.slider({
					slide: function(event, ui) {
						jQuery(this).find('.ui-slider-handle').text(ui.value); // show value on slider handle
						// send ajax request to wp.customizer to enable Save & Publish button
						var _new_value = $control.val();
						var key = $control.attr('data-customize-setting-link');
						try {
							wp.customize(key, function(obj) {
								obj.set(_new_value);
							});
						}
						catch(err) {
							console.log(err);
						}
						
					},
					create: function(event, ui) {
						var v = jQuery(this).slider('value');
						jQuery(this).find('.ui-slider-handle').text(v);
					},
					value: alpha_val,
					range: "max",
					step: 1,
					min: 0,
					max: 100
				}); // slider
				$alpha_slider.slider().on('slidechange', function(event, ui) {
					var new_alpha_val = parseFloat(ui.value),
						iris = $control.data('a8cIris'),
						color_picker = $control.data('wpWpColorPicker');
					iris._color._alpha = new_alpha_val / 100.0;
					$control.val(iris._color.toString());
					color_picker.toggler.css({
						backgroundColor: $control.val()
					});
					// fix relationship between alpha slider and the 'side slider not updating.
					var get_val = $control.val();
					jQuery($control).wpColorPicker('color', get_val);
				});
			}); // each

			// Initialize the option
			$('.tf-font').each(function() {

				// Update save field on change
				$(this).find('select,.tf-font-sel-dark').change(function() {
					tf_select_font_update_preview( $(this).parents('.tf-font:eq(0)'), true );
				});

				// Trigger for toggling light/dark preview backgrounds
				$(this).find('.btn-dark').click(function() {
					var darkInput = $(this).parent().find('.tf-font-sel-dark');
					if ( darkInput.val() == '' ) {
						darkInput.val('dark').trigger('change');
					} else {
						darkInput.val('').trigger('change');
					}
				})

				// initialize preview
				tf_select_font_update_preview( $(this), true );

				// We have to do this after 1ms for the theme customizer, or else the field's value
				// gets changed to a weird value
				var $this = $(this);
				setTimeout( function() {
					tf_select_font_update_preview( $this, false )
				}, 1 );
			});

			$('body.wp-customizer').on('click', function(e) {
				$('.tf-font .wp-color-result').each(function() {
					if ( $(this).hasClass('wp-picker-open') ) {
						$(this).parents('label:eq(0)').addClass('tf-picker-open');
					} else {
						if ( $(this).parents('label:eq(0)').hasClass('tf-picker-open') ) {
							$(this).parents('label:eq(0)').removeClass('tf-picker-open');
						}
					}
				});
			});

			// chosen font
			$(".chosen-select").chosen({
				allow_single_deselect: true,
				width: '60%'
			});
		});


		// Updates the option elements
		function tf_select_font_update_preview( $container, doTrigger ) {
			"use strict";
			var $ = jQuery;

			// Show / hide shadow fields
			if ( $container.find(".tf-font-sel-location").val() == 'none'
				 || $container.find('.tf-font-sel-location').parents('label:eq(0)').attr('data-visible') == 'false' ) {
				$container.find(".tf-font-sel-distance").parents('label:eq(0)').fadeOut();
				$container.find(".tf-font-sel-blur").parents('label:eq(0)').fadeOut();
				$container.find(".tf-font-sel-shadow-color").parents('label:eq(0)').fadeOut();
				$container.find(".tf-font-sel-opacity").parents('label:eq(0)').fadeOut();
			} else {
				$container.find(".tf-font-sel-distance").parents('label:eq(0)').fadeIn();
				$container.find(".tf-font-sel-blur").parents('label:eq(0)').fadeIn();
				$container.find(".tf-font-sel-shadow-color").parents('label:eq(0)').fadeIn();
				$container.find(".tf-font-sel-opacity").parents('label:eq(0)').fadeIn();
			}

			var family = $container.find('.tf-font-sel-family').val();

			// These are all our parameters
			var params = {
				'font-family': family,
				'font-type': $container.find(".tf-font-sel-family option[value='" + family + "']").parent().attr('class'),
				'color-opacity': $container.find(".tf-font-sel-color").val(),
				'font-size': $container.find(".tf-font-sel-size").val(),
				'font-weight': $container.find(".tf-font-sel-weight").val(),
				'font-style': $container.find(".tf-font-sel-style").val(),
				'line-height': $container.find(".tf-font-sel-height").val(),
				'letter-spacing': $container.find(".tf-font-sel-spacing").val(),
				'text-transform': $container.find(".tf-font-sel-transform").val(),
				'font-variant': $container.find(".tf-font-sel-variant").val(),
				'text-shadow-location': $container.find(".tf-font-sel-location").val(),
				'text-shadow-distance': $container.find(".tf-font-sel-distance").val(),
				'text-shadow-blur': $container.find(".tf-font-sel-blur").val(),
				'text-shadow-color': $container.find(".tf-font-sel-shadow-color").val(),
				'text-shadow-opacity': $container.find(".tf-font-sel-opacity").val(),
				'dark': $container.find(".tf-font-sel-dark").val(),
				'text': $container.find("iframe").attr('data-preview-text')
			}

			// Update preview
			if ( $container.find('iframe').is(':not([data-visible=false])') ) {
				$container.find('iframe').attr('src', '<?php 
        echo TitanFramework::getURL('iframe-font-preview.php?', __FILE__);
        ?>
' + $.param(params) );
			}

			// Update hidden save field
			$container.find('.tf-for-saving').val(serialize(params));
			if ( doTrigger ) {
				$container.find('.tf-for-saving').trigger('change');
			}
		}
		</script>
		<?php 
    }
 /**
  * Register and load the select2 script
  *
  * @since 1.9.3
  * @return void
  */
 public function load_select_scripts()
 {
     wp_enqueue_script('tf-select2', TitanFramework::getURL('../js/select2/select2.min.js', __FILE__), array('jquery'), TF_VERSION, true);
     wp_enqueue_style('tf-select2-style', TitanFramework::getURL('../css/select2/select2.min.css', __FILE__), null, TF_VERSION, 'all');
     wp_enqueue_style('tf-select-option-style', TitanFramework::getURL('../css/class-option-select.css', __FILE__), null, TF_VERSION, 'all');
 }