Forum Replies Created

Viewing 15 replies - 1 through 15 (of 29 total)
  • Thread Starter docbt

    (@docbt)

    Hi guys!
    @nicmare: With a relative path some other plugins might break. For me Ultimate Member for example.
    So you should really use the second code I posted together with
    define('WP_ADMIN_DIR', 'wp-admin');
    in your wp-config.php

    The CORS problem can be solved by adding the following code for all your domains to your functions.php

    function add_allowed_origins($origins) {
        $origins[] = 'https://www.domain.de';
        $origins[] = 'https://ja.domain.de';
        $origins[] = 'https://en.domain.de';        
        return $origins;
    }
    add_filter('allowed_http_origins', 'add_allowed_origins');

    This way noone needs to install a browser plugin ??

    Your solution with the include style and script loader src is not relevant for me, cause I am using a static URL for all of my inlcudes/scripts/images/stylesheets (static.domain.de) anyway. This is good for the page speed and search engines (see cookie-free domain).

    Here is my complete wp-config stuff for dynamic URLs with SSO (Single Sign On):

    $currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME']));
    $currentpath = preg_replace('/\/wp.+/','',$currentpath);
    $protocol=$_SERVER['PROTOCOL'] = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http';
    $currenthost = $protocol . "://".$_SERVER['HTTP_HOST'];
    define('WP_HOME',$currenthost.$currentpath);
    define('WP_SITEURL',$currenthost.$currentpath);
    define("WP_CONTENT_URL", "https://static.domain.de/wp-content"); 
    define('WP_PLUGIN_URL', 'https://static.domain.de/wp-content/plugins');
    //define('DOMAIN_CURRENT_SITE', $currenthost );
    define('COOKIE_DOMAIN', '.domain.de'); // Added by W3 Total Cache
    define('COOKIEPATH', '/');
    define('COOKIEHASH', '####Secret_Random_String###');
    //define('SITECOOKIEPATH', '/');
    define('AUTH_KEY', '####Secret_Random_String###);
    define('SECURE_AUTH_KEY', '####Secret_Random_String###');
    define('LOGGED_IN_KEY', '####Secret_Random_String###');
    define('AUTH_SALT', '####Secret_Random_String###');
    define('SECURE_AUTH_SALT', '####Secret_Random_String###');
    define('LOGGED_IN_SALT', '####Secret_Random_String###');
    ini_set('session.cookie_domain', '.domain.de');
    
    define('WP_ADMIN_DIR', 'wp-admin');

    @isuruxcode
    What did you try already?

    Thread Starter docbt

    (@docbt)

    After investigating the problem, it seems that the wordpress function human_time_diff() in formatting.php doens′t return translated strings (although the _n() function is called).

    I tried to override the locale variable and added a text-domain, but that doesn′t help, so I ended up in translating it in my themes functions manually.

    add_filter('human_time_diff', 'new_human_time_diff', 10, 2);
    function new_human_time_diff($from, $to) {
    
        // remove filter to prevent the loop
        remove_filter('human_time_diff', 'new_human_time_diff');
    
        $locale = get_locale();
    
        $timediff = human_time_diff($from, $to);
        if($locale == "en_US"){
            return $timediff;
         } else {
            $translate_from_plural = array("seconds", "mins", "days", "hours", "months", "weeks", "years");
            $translate_from_singular = array("second", "min", "day", "hour", "month", "week", "year");
            If ($locale == "de_DE"){
                $translate_to_plural = array("Sekunden", "Minuten", "Tagen", "Stunden", "Monaten", "Wochen", "Jahren");
                $translate_to_singluar = array("Sekunde", "Minute", "Tag", "Stunde", "Monat", "Woche", "Jahr");
            } elseif ($locale == "ja"){
                $translate_to_plural = array("秒", "分", "日々", "時間", "月", "週", "年");
                $translate_to_singluar = array("秒", "分", "日", "時間", "月", "週間", "年");
            }
            $timediff = str_replace($translate_from_singular,$translate_to_singluar,str_replace($translate_from_plural, $translate_to_plural, $timediff));
        
        }
        // restore the filter
        add_filter( 'human_time_diff', 'new_human_time_diff', 10, 2);     
    
        return $timediff;
    }
    Thread Starter docbt

    (@docbt)

    The above code won′t work in sub-subpaths. So better use this one:

    function modify_adminy_url_for_ajax( $url, $path, $blog_id ) {
        if ( "admin-ajax.php" == $path ) {
            $url = home_url( '/' ) . WP_ADMIN_DIR . "/admin-ajax.php";
        }
        return $url;
    }
    add_filter("admin_url", "modify_adminy_url_for_ajax", 10, 3 );
    Thread Starter docbt

    (@docbt)

    Ok, I solved it myself ?? The solution is to change the URL of the admin-ajax.php to a relative path, instead of absolute.

    Add this to your themes functions.php:

    function modify_adminy_url_for_ajax( $url, $path, $blog_id ) {
        if ( "admin-ajax.php" == $path ) {
            $url = "admin-ajax.php";
        }
        return $url;
    }
    add_filter("admin_url", "modify_adminy_url_for_ajax", 10, 3 );

    And add all your domains to the allowe origins:

    add_filter('allowed_http_origins', 'add_allowed_origins');
    function add_allowed_origins($origins) {
        $origins[] = 'https://www.domain.de';
        $origins[] = 'https://ja.domain.de';
        $origins[] = 'https://en.domain.de';        
        return $origins;
    }
    • This reply was modified 4 years, 1 month ago by docbt.
    Thread Starter docbt

    (@docbt)

    I tested your new version and it workes perfect ????

    Everything got converted and I tested the WebP images successfully with chrome ??

    Well done and thank you very much!

    The only thing that might be better is, that new images will not be detected automatically, if they are not uploaded to the media library.

    Would be nice, if the plugin could detect plugin/theme changes and then suggest generating the files again (or do it automatically).
    Alternatively users might use your manual custom function in their themes functions and fire it on upload of images, if their plugins have an event/hook for that…

    • This reply was modified 4 years, 5 months ago by docbt.
    Thread Starter docbt

    (@docbt)

    EDIT:
    I forgot the first line ??

    It works perfect for me.

    Right know it runs everytime you open the admin dashboard. Would be better to run it only when the convert button is pressed.

    Is there an existing hook?

    Thread Starter docbt

    (@docbt)

    I wrote a little custom function to generate the webp files manually for custom folders:

    add_action( 'admin_init', 'manual_webpc_convert_paths' );
    function manual_webpc_convert_paths() {  
        $testmode = false;
        $uploadpath = ABSPATH . "wp-content/uploads/";
    	// Custom folders in uploads
    	$custom_folders = array(
    		'ultimatemember/',
    		'wpdiscuz/'
        );  
        foreach ($custom_folders as $key => $custom_folder) {
            $paths = array();          
            $path = $uploadpath . $custom_folder;
            // Known linux problem with "." ".." in scandir()
            $folders = array_diff(scandir($path), array('..', '.'));
            foreach ($folders as $key => $folder) {
                if(is_file($folder)){
                    $paths[] = $path . $folder;
                } else {
                    // Known linux problem with "." ".." in scandir()
                    $subfolders[$folder] = array_diff(scandir($path . $folder), array('..', '.'));
                }
            }
            foreach ($subfolders as $folder => $file) {
                foreach ($file as $key => $filename) {
                    if(is_file($path . $folder . "/" . $filename)){
                        $paths[] = $path . $folder . "/" . $filename;
                    } else {
                        // Known linux problem with "." ".." in scandir()
                        $subsubfolders[$folder . "/" . $filename] = array_diff(scandir($path . $folder . "/" . $filename), array('..', '.'));
                    }
                }
            }
            foreach ($subsubfolders as $folder => $file) {
                foreach ($file as $key => $filename) {
                    if(is_file($path . $folder . "/" . $filename)){
                        $paths[] = $path . $folder . "/" . $filename;
                    }
                }
            }                
            if($testmode){
                //debug output in admin dashboard
                echo '<pre>' . print_r($paths) . '</pre>';             
            } else {
                // image checks are done in webpc 
                do_action('webpc_convert_paths', $paths);
            }
            unset($paths);      
            unset($subfolders);
            unset($subsubfolders);
        }
    }

    Goes to your theme -> functions.php

    You can check the files first with $testmode = true in the first line. This will print the files in your admin dashboard instead of generating anything.

    Add your custom folders in this section:

    	$custom_folders = array(
    		'ultimatemember/',
    		'wpdiscuz/'
        );  
    • This reply was modified 4 years, 5 months ago by docbt.
    • This reply was modified 4 years, 5 months ago by docbt. Reason: forgot the first line
    Thread Starter docbt

    (@docbt)

    The plugin is working. WebP images were created for all my image folders except ultimatemember and wpdiscuz.

    I could resolve the problem by activating minify/combine and enabling the debug option (only for Admin). After that I deativated minify/combine again.

    Hi @gabelivan !

    I have the same problem.

    I just want to use Asset cleanup to cleanup assets, cause I use antoher plugin to minify/cache…

    I have deactivated css and js minification/combination/defer, but the plugin still is generating cached versions.

    I reinstalled the plugin reset all my settings, but nothing helps. I can′t disable the features.

    • This reply was modified 4 years, 6 months ago by docbt.
    • This reply was modified 4 years, 6 months ago by docbt.
    • This reply was modified 4 years, 6 months ago by docbt.
    Thread Starter docbt

    (@docbt)

    Finally fixed! Thank you ??

    Thread Starter docbt

    (@docbt)

    It works, if I delete all generated thumbnails manually from the upload directory ??

    Is it possible to deactivate the thumbnail generation on upload?

    If I delete all upload thumbnail sizes and click on save, it doesn′t save…

    Thread Starter docbt

    (@docbt)

    2 upload cover thumbnail sizes are set 300px and 600px.

    Minimum and maximum cover widths are set to 822px.

    On my tablet and smartphone I see the 300px version of the cover…

    <img src="/wp-content/uploads/ultimatemember/1/cover_photo-300.jpg" alt="" />

    I deleted the 300px thumbnail upload size for testing and still see the 300px version.

    Unbenannt

    Unbenannt2

    • This reply was modified 4 years, 11 months ago by docbt.
    • This reply was modified 4 years, 11 months ago by docbt.
    Thread Starter docbt

    (@docbt)

    Hi @champsupertramp,

    thanks. I changed the values for profile and cover sizes to “original size” and it workes for the desktop version.

    But on mobile devices I still see the thumbnails for the covers and the quality is poor…

    Is there a way to disable the mobile versions completely?
    Shouldn′t it be original size with my settings?

    Greetings,
    doc

    Thread Starter docbt

    (@docbt)

    Hi,
    the problem is still present. I changed the status back to “not resolved”.
    Greetings doc

Viewing 15 replies - 1 through 15 (of 29 total)