Minify HTML with voku / HtmlMin?

I want use voku/HtmlMin in wordpress functions.php, i install composerr in theme folder and i use code:

class WP_HTML_Compression

    // Settings
    protected $compress_css = true;
    protected $compress_js = true;
    protected $info_comment = true;
    protected $remove_comments = true;

    // Variables
    protected $html;

    public function __construct($html) 

        if (!empty($html)) {

    public function __toString()
        return $this->html;

    protected function bottomComment($raw, $compressed)
        $raw = strlen($raw);
        $compressed = strlen($compressed);

        $savings = ($raw-$compressed) / $raw * 100;

        $savings = round($savings, 2);

        return '<!--HTML compressed, size saved '.$savings.'%. From '.$raw.' bytes, now '.$compressed.' bytes-->';

    protected function minifyHTML($html)
    $htmlMin = new vokuhelperHtmlMin();

        return $htmlMin->doRemoveComments->doSortCssClassNames()->doSortHtmlAttributes()->minify($html);

    $htmlMin = vokuhelperHtmlMin;
        $htmlMin = new HtmlMin();

    public function parseHTML($html)
        $this->html = $this->minifyHTML($html);

        if ($this->info_comment) {
            $this->html .= "n" . $this->bottomComment($html, $this->html);

    protected function removeWhiteSpace($str)
        $str = str_replace("t", ' ', $str);
        $str = str_replace("n",  '', $str);
        $str = str_replace("r",  '', $str);

        while (stristr($str, '  ')) {
            $str = str_replace('  ', ' ', $str);

        return $str;

function wp_html_compression_finish($html) {
    return new WP_HTML_Compression($html);

function wp_html_compression_start() {
add_action('get_header', 'wp_html_compression_start');

but it’s not work. How add voku/htmlmin correct?

Go to Source
Author: johm

How Can I Create a Friendly Slug for a Dynamic Page?

I built a dynamic page template that pulls biography information from a MySQL table.

The page works fine but the URL is ugly.


I have a set of canonical slugs that I want to use for each officer.

for example, Officer-Firstname-Lastname

I’ve tried both htacess and add_rewrite_rule and both give me 404.

example: add_rewrite_rule('Officer-Erich-Abberger', 'Officer-Biography/?ID=1', 'top');

What am I missing?

Go to Source
Author: jpollar

How to reorder hooks output order of Seconday menu and Product search (Storefront theme)

I would like to center Product search on about the same line with Site logo and align right on the same line the secondary menu on site (I’m not advertising or something… I put a link just to be more concrete on the subject. Hopely it is not against rules).
The default hooks’ output for Storefront theme is like this

  1. Site Branding (logo e.t.c.)
  2. Secondary menu
  3. Product search
  4. Primary navigation menu


I was trying to play with CSS with that set up but it seems pretty hard for me (I’m a noob, ha ha) to center Product Search for all resolutions with that hooks order.
My Idea how to do habdle this is to change output priorities: show Product search right after Site Branding and then Show Secondary menu. Only after that play with CSS rules/styling.

What I’m see at storefront-template-hooks.php is

add_action( 'storefront_header', 'storefront_header_container', 0 );
add_action( 'storefront_header', 'storefront_skip_links', 5 );
add_action( 'storefront_header', 'storefront_site_branding', 20 );
add_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
add_action( 'storefront_header', 'storefront_header_container_close', 41 );
add_action( 'storefront_header', 'storefront_primary_navigation_wrapper', 42 );
add_action( 'storefront_header', 'storefront_primary_navigation', 50 );
add_action( 'storefront_header', 'storefront_primary_navigation_wrapper_close', 68 );

No call for search function. My logic was like that: find output for product search and set priority higher than storefront_secondary_navigation: let say 25. But I can not find where the search priority is set up. I’m using AJAX Search for WooCommerce plugin and that makes things to be a bit more complicated, he he.
Can someone please suggest how to reorder items in header?
Will it work for my target: center cearch and align secondary menu right?

Go to Source
Author: 0LEg

Naming convention for a function which checks whether scroll required or not?

There is function which checks whether scroll required or not by doing some DOM height width calucation before enabling the scroll in the webpage.

I named the function as checkScrollNeeded. Is there a better name or any naming conventions to refer.

Go to Source
Author: Sivashanmugam Kannan

How to change users avatar with specific e-mail addresses

How to set user avatar ( for e-mails:

Go to Source
Author: UserUser-name

Create a Postgresql trigger that updates column with PK of other table

Hello and thanks for taking the time in advance to look at my question. This is my first try at using triggers and functions in PostgreSQL (using DBeaver) and I appreciate your feedback.

I’d like to update a column (village_id) every time a new row is entered or updated with the primary key value of a different table (which is not connected as a foreign key directly). See below for an outline of my tables and trigger + function.

Unfortunately, after using the code below I received an error each time I was entering a new row with information. I used an UPDATE statement, but I also considered using an insert into statement, but wasn’t sure what is more preferable. Thank you in advance.

  CREATE TABLE register_table
(register_id integer CONSTRAINT register_id_pk PRIMARY KEY,
  village_id integer NOT NULL
      CREATE TABLE er_table
(er_id integer CONSTRAINT er_id_pk PRIMARY KEY,
  register_id integer NOT NULL,
  village_id integer NOT NULL

CREATE OR REPLACE FUNCTION update_village_id_column()
    RETURNS trigger AS
UPDATE schema_example.er_table
SET  village_id = register_table.village_id
from schema_example.register_table
WHERE (schema_example.register_id = new.register_id);

RETURN new; 
COST 100;

CREATE TRIGGER update_village_id
ON schema_example.er_table
EXECUTE PROCEDURE update_village_id_column();

Go to Source
Author: PGerrits

How would I go about replacing this function in my child theme located in inc/template-tags.php

How would I replace this function that lies inside inc/template-tags.php in my parent theme

function theme_navigation() {
        <div id="theme-nav-container">
            <nav id="site-navigation" class="main-navigation">
                <?php wp_nav_menu( array('theme_location' => 'theme-studios-primary', 'menu_class' => 'sf-menu', 'fallback_cb' => false, 'walker'  => new theme ) ); ?><div class="clearfix-pro"></div>
            <div class="clearfix-pro"></div>
        <!-- close #theme-nav-container -->

There is no add action that it is hooked on to, there is no check to see if the function already exists. How would I replace it without touching the parent theme. I have removed much of the code in the function for brevity but I think it still makes sense.

Thanks ahead of time

Go to Source
Author: Anders Kitson