Forum Replies Created

Viewing 15 replies - 16 through 30 (of 50 total)
  • Thread Starter jrvcosta

    (@jrvcosta)

    Hi @prasunsen!

    From my side, since the last WatuPRO update (6.6.0.7) everything is working fine, no conflicts, no errors.

    How can I send you my e-mail privately here?

    Thread Starter jrvcosta

    (@jrvcosta)

    By the way, WatuPRO is another essential plugin for me. You two guys are doing an excellent job. It’s inspiring to see you working seriously ─ and together. I really made excellent choices for my website.

    Success!

    Thread Starter jrvcosta

    (@jrvcosta)

    Thank you @tobiasbg and @prasunsen!

    The WatuPRO plugin just release an update temporarily disabling TablePress integration due these errors. I hope a definitive solution arrives soon.

    And sorry for for my mistake, Tobias. “Tablepress” was mentioned so many times in the error message that I didn’t realize the relationship with another plugin.

    Best wishes!

    Thread Starter jrvcosta

    (@jrvcosta)

    It didn’t work for me. Not even when I set the priority to 999.

    Is the line admin.php?page=foobox-image-lightbox really correct??

    Thread Starter jrvcosta

    (@jrvcosta)

    Sure! I just added one line to the previous code:

    
    function wpse_custom_menu_order( $menu_ord ) {
        if ( !$menu_ord ) return true;
        return array(
            'index.php', // Dashboard
            'edit.php', // Posts
            'edit.php?post_type=page', // Pages
            'upload.php', // Media
            'options-general.php', // Configura??es
            'tools.php', // Ferramentas
            'plugins.php', // Plugins
            'themes.php', // Aparência
            'users.php', // Usuários
            'separator-last', // Separador
    	'admin.php?page=foobox-image-lightbox', //Foobox
    	'edit.php?post_type=foogallery' // FooGallery
        );
    }
    add_filter( 'custom_menu_order', 'wpse_custom_menu_order', 10, 1 );
    add_filter( 'menu_order', 'wpse_custom_menu_order', 10, 1 );

    `

    Thread Starter jrvcosta

    (@jrvcosta)

    Well, this is very strange!

    See what happens to me: I have both plugins installed on my WordPress 5.8: FooBox Image Lightbox 2.7.16 and FooGallery 2.0.39.

    They work fine without the minify snippet but when I activate this code the galleries keeps showing normally but without the image modal. The most curious thing is that if I go to the menu of the Foobox plugin (wp-admin/admin.php?page=foobox-image-lightbox) all demos works normally!

    Only the front-end of site stops showing the modal images. When I click on an image that I know has the class=”foobox” the image itself is displayed instead (no dialog box/popup window over the CURRENT page).

    I thought it might be some error because the minify compression of the Foobox JS, but apparently it isn’t.

    Thread Starter jrvcosta

    (@jrvcosta)

    Thank you very much for the effort, Elvis.

    There may have been a problem pasting here. I can only say that I copied it directly from the snippet on my website (Code Snippets plugin).

    May I ask you to do just one last test with the original code, from Github?
    It′s here: https://gist.github.com/MrJoshFisher/481251d1e89d1c5a25c8aa82482cd747

    Best wishes,
    José.

    Thread Starter jrvcosta

    (@jrvcosta)

    Absolutely, Elvis! And thanks so much for your quick reply!
    Here’s the minify snippet I was using:

    class FLHM_HTML_Compression
    {
        protected $flhm_compress_css = true;
        protected $flhm_compress_js = true;
        protected $flhm_info_comment = true;
        protected $flhm_remove_comments = true;
        protected $html;
        public function __construct($html)
        {
            if (!empty($html)) {
                $this->flhm_parseHTML($html);
            }
        }
        public function __toString()
        {
            return $this->html;
        }
        protected function flhm_bottomComment($raw, $compressed)
        {
            $raw = strlen($raw);
            $compressed = strlen($compressed);
            $savings = (($raw - $compressed) / $raw) * 100;
            $savings = round($savings, 2);
            return '<!--Código compactado. Redu??o de ' .
                $savings .
                '%. De ' .
                $raw .
                ' bytes para ' .
                $compressed .
                ' bytes-->';
        }
        protected function flhm_minifyHTML($html)
        {
            $pattern =
                '/<(?<script>script).*?<\/script\s*>|<(?<style>style).*?<\/style\s*>|<!(?<comment>--).*?-->|<(?<tag>[\/\w.:-]*)(?:".*?"|\'.*?\'|[^\'">]+)*>|(?<text>((<[^!\/\w.:-])?[^<]*)+)|/si';
            preg_match_all($pattern, $html, $matches, PREG_SET_ORDER);
            $overriding = false;
            $raw_tag = false;
            $html = '';
            foreach ($matches as $token) {
                $tag = isset($token['tag']) ? strtolower($token['tag']) : null;
                $content = $token[0];
                if (is_null($tag)) {
                    if (!empty($token['script'])) {
                        $strip = $this->flhm_compress_js;
                    } elseif (!empty($token['style'])) {
                        $strip = $this->flhm_compress_css;
                    } elseif (
                        $content == '<!-- Sem redu??o -->'
                    ) {
                        $overriding = !$overriding;
                        continue;
                    } elseif ($this->flhm_remove_comments) {
                        if (!$overriding && $raw_tag != 'textarea') {
                            $content = preg_replace(
                                '/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->/s',
                                '',
                                $content
                            );
                        }
                    }
                } else {
                    if ($tag == 'pre' || $tag == 'textarea') {
                        $raw_tag = $tag;
                    } elseif ($tag == '/pre' || $tag == '/textarea') {
                        $raw_tag = false;
                    } else {
                        if ($raw_tag || $overriding) {
                            $strip = false;
                        } else {
                            $strip = true;
                            $content = preg_replace(
                                '/(\s+)(\w++(?<!\baction|\balt|\bcontent|\bsrc)="")/',
                                '$1',
                                $content
                            );
                            $content = str_replace(' />', '/>', $content);
                        }
                    }
                }
                if ($strip) {
                    $content = $this->flhm_removeWhiteSpace($content);
                }
                $html .= $content;
            }
            return $html;
        }
        public function flhm_parseHTML($html)
        {
            $this->html = $this->flhm_minifyHTML($html);
            if ($this->flhm_info_comment) {
                $this->html .= "\n" . $this->flhm_bottomComment($html, $this->html);
            }
        }
        protected function flhm_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 flhm_wp_html_compression_finish($html)
    {
        return new FLHM_HTML_Compression($html);
    }
    
    function flhm_wp_html_compression_start()
    {
        ob_start('flhm_wp_html_compression_finish');
    }
    add_action('get_header', 'flhm_wp_html_compression_start');
    
    Thread Starter jrvcosta

    (@jrvcosta)

    Well, since I didn’t quite understand the implementation of the JS you gave at the beginning of this post – and since all the tables I need to insert these attributes are in two specific categories, my work-around solution was pure PHP:

    function ada_tablepress_add_scope( $tag_attributes, $table_id, $cell_content, $row_number, $col_number, $colspan, $rowspan ) {
    if (in_category(array('123','321')) ) {
    $data_tags = array("Data 1","Data 2","Data 3","Data 4");
    for ($i = 1; $i <= 4; $i++) {
    	if ( $col_number === $i ) {	$tag_attributes['data-column'] = $data_tags[$i - 1]; }
    	}
    } 
    return $tag_attributes;
    }
    add_filter( 'tablepress_cell_tag_attributes', 'ada_tablepress_add_scope', 10, 7 );

    it’s far from the best solution and it may not be nice-looking, but for now it works for me!

    Thank you for your time, Tobias! Take care.

    Thread Starter jrvcosta

    (@jrvcosta)

    Hi Tobias.

    It worked! Thank you!

    But, please, I need some guidance to reach my goal.

    I will try to be very clear. Let′s take this simple table:

    <table>
       <thead>
          <tr>
             <th>Column 1</th>
             <th>Column 2</th>
          </tr>
       </thead>
       <tbody>
          <tr>
             <td>Data 1</td>
             <td>Data 2</td>
          </tr>
       </tbody>
    </table>

    I would like to add the data-column attribute to each TD with the value of the corresponding column header. The final table would be:

    <table>
       <thead>
          <tr>
             <th>Column 1</th>
             <th>Column 2</th>
          </tr>
       </thead>
       <tbody>
          <tr>
             <td data-column="Column 1">Data 1</td>
             <td data-column="Column 2">Data 2</td>
          </tr>
       </tbody>
    </table>

    It is important to me that this happens for all tables generated by TablePress.

    But I have no clue how to code this (using tablepress_cell_tag_attributes filter? tablepress_cell_content filter?). How? Can you help me?

    • This reply was modified 3 years, 8 months ago by jrvcosta.
    Thread Starter jrvcosta

    (@jrvcosta)

    The first time I tested I was logged-in into WordPress. But then I saved a “test page” and searched in the source code (not logged in). I also flushed CDN cache and browser cache… But nope. No sign of scope=”col” in any part of the table.

    Can you please suggest me a simple filter that alter something in the table, just for testing purposes? I need to understand what’s going on

    • This reply was modified 3 years, 8 months ago by jrvcosta.
    • This reply was modified 3 years, 8 months ago by jrvcosta.
    Thread Starter jrvcosta

    (@jrvcosta)

    Was the Watu Quiz plugin.
    And – sure! – I just rated TablePress 5 stars!

    Thread Starter jrvcosta

    (@jrvcosta)

    Thank you very much, Tobias!

    Well, my first approach was trying to add scope=”col” like I saw in other posts in this forum (It’s not what I want to do, but it would be my first step.)

    function ada_tablepress_add_scope( $tag_attributes, $table_id, $cell_content, $row_number, $col_number, $colspan, $rowspan ) {
        if ( $row_number === 1 ) {
            $tag_attributes['scope'] = "col";
        }
        return $tag_attributes;
    }
    add_filter( 'tablepress_cell_tag_attributes', 'ada_tablepress_add_scope', 10, 7 );

    Wouldn’t be expected this filter add scope=”col” on first TH tag?

    I put it in functions.php but nothing happened with the table I created using Tablepress.

    What could I be doing wrong?

    Thread Starter jrvcosta

    (@jrvcosta)

    Thank you Tobias!

    I did as recommended and found the plugin causing the error.

    It was strange how I made it work: first I activated the responsive tables and then the other plugin. In that order the error no longer happened.

    Thread Starter jrvcosta

    (@jrvcosta)

    Please, any thoughts?

Viewing 15 replies - 16 through 30 (of 50 total)