August 2017
Beginner
412 pages
10h 30m
English
The core of any plugin is the unique PHP code that you bring to the table. This is the part of the plugin that makes it what it is. Since this plugin is so simple, it only has a few lines of code in the middle.
The second requirement the plugin has to meet is have a PHP function that identifies links to documents and adds a special class to them. The following function does just that. Note that in keeping with my efforts to ensure that my code is unique, I've prefixed both of my functions with doctype_styles_new:
function doctype_styles_new_regex($text) { $text = preg_replace('/href=([\'|"][[:alnum:]| [:punct:]]*)\.(pdf|doc|mp3|zip)([\'|"])/', 'href=\\1.\\2\\3 class="link \\2"', $text); return $text; } ...Read now
Unlock full access