Tooltipy

Wiki.TerraBase.info
Revision as of 11:38, 13 February 2020 by Root (talk | contribs) (Created page with "...ran into an issue with Tooltipy where it was causing an error. === The Error === <syntaxhighlight lang="text"> preg_match() unknown modifier </syntaxhighlight> === The So...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

...ran into an issue with Tooltipy where it was causing an error.

The Error

preg_match() unknown modifier

The Solution

Add the below code (comments can be omitted) to the /WhatEverPathToWordPressSite/wp-content/plugins/bluet-keywords-tooltip-generator/functions.php immediately before the line with: if(preg_match($term,$content_to_check)){

		// By default Tooltipy cannot handle forward slashes in the name of the title
		// This short script fixes the problem.
		// The assumption was made, based on all output of the $term string, that all instances of $term begin with a single forward slash (/) and end with a forward slash followed by two characters, iu, (IE /iu).
		// I couldn't figure out how to create a Regular Expression with the granular detail to do the same thing, but I'm sure it could be done, simplifying the below code
		// The below script could easily be condensed, but it is put in a long format to make it clear what is occuring.
		//
		// Original Term (Used for testing only)
		$original_term = $term;

		// Copy the last three characters of the string
		$last_three_characters = substr($term,-3);

		// Remove the leading Forward slash from the string
		$term = substr($term,1);

		// Remove the last three characters of the string, including a Forward Slash
		$term = substr($term,0,-3);

		// Replace any Forward Slashes (/) in the Title with an ESCAPED Forward Slash (\/)
		$term = str_replace("/","\/",$term);

		// Add the original leading and trailing strings
		//$term = $first_six_characters . $term . $last_three_characters;
		$term = '/' . $term . $last_three_characters;

		// ECHO command (Used for testing only)
		//echo 'ORIGINAL - ' . $original_term . '<br><br>Modified - ' . $term . '<br><br><br><br>';