gpo = $general_plugin_obg; } // FNC /** * Registers the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_register_styles_and_scripts() { require 'amo-team-showcase-public-enqueue.php'; } public function enqueue_public_scripts_on_demand( ) { static $enqueued= false; // IF scripts aren't enqueued yet if ( ! $enqueued ) { wp_enqueue_script( 'imagesloaded' ); // JS library needed for Wookmark to work properly wp_enqueue_script( AMO_TEAM_SHOWCASE_CSS_PREFIX . 'Wookmark-jQuery' ); // Masonry grid making jQuery plugin wp_enqueue_script( 'magnific-popup' ); // Magnific Popup CSS (jQuery plugin) wp_enqueue_script( $this->gpo->get_plugin_name() ); // Main plugin's JS file // CSS styles assembled from the plugin options add_action( 'wp_footer', array( $this, 'echo_assembled_css_styles' ) ); $enqueued = true; } } // FNC /** * Output CSS styles assembled from the plugin options * * @since 1.0.0 */ public function echo_assembled_css_styles() { echo ''; } // FNC /** * Sets plugin's main and global JavaScript variable in website frontend * * @since 1.0.0 */ public function set_amoteam_main_variable_script() { echo ''; } // FNC /** * Extend list of allowed protocols. * * @param array $protocols List of default protocols allowed by WordPress. * * @return array $protocols Updated list including new protocols. * @since 1.0.0 */ public function extend_allowed_url_protocols( $protocols ) { $protocols[] = 'skype'; return $protocols; } // FNC /*------------------------------------------------------------------- ▐ 10. Sanitizes HTML (mostly from JS) --------------------------------------------------------------------*/ /** * Sanitizes HTML, removes certain tags and their attributes * * @param string $html – HTML to sanitize * @param array $tags – Tags to remove * @param mixed $tag_attributes – Tags' attributes to remove * * @return string HTML * @since 1.0.0 */ function remove_tags_and_attributes_from_html( $html, $tags, $tag_attributes = null ) { if ( ! $tag_attributes ) $tag_attributes = array('onload', 'onclick'); $output_html = $tags_to_remove = ''; // Disable errors on invalid HTML libxml_use_internal_errors(true); $dom = new DOMDocument( '1.0','utf-8'); $dom->loadHTML( mb_convert_encoding( trim($html), 'HTML-ENTITIES', 'UTF-8')); # remove doctype $dom->removeChild($dom->doctype); # remove $dom->replaceChild($dom->firstChild->firstChild, $dom->firstChild); // Remove certain tags foreach($tags as $tag) { $tags_to_remove = $dom->getElementsByTagName( $tag ); foreach( $tags_to_remove as $tag_to_remove ){ $tag_to_remove->parentNode->removeChild( $tag_to_remove ); } // FOREACH 2 } // FOREACH 1 // Remove certain attributes from tags $nodes = $dom->getElementsByTagName('*');//just get all nodes, foreach($nodes as $node) { $current = null; foreach( $tag_attributes as $attr ) { if ( $node->hasAttribute($attr) ) { $node->removeAttribute($attr); } // IF } // FOREACH 2 } // FOREACH 1 # Remove and Save HTML foreach($dom->firstChild->childNodes as $child_node){ $output_html .= $dom->saveHTML($child_node); } return $output_html; } // FNC | remove_tags_and_attributes_from_html } // CLASS