• Resolved Marc Troendle

    (@mtnetcontrolde)


    Hallo,

    my theme get on Theme Check the following Warning.

    WARNING: file_get_contents was found in the file js/theme.js.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.

    Line 23: echo file_get_contents($jss);

    I use this script for compressing my css and javascript…

    <?php
    /**
     * Pressonry dynamic All in One Styles
     * www.phpdevtips.com
     *
     * @package pressonry
     */
    header("Content-Type: text/css;charset: UTF-8");
    function compress($buffer) {
    	$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
    	$buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
    	return $buffer;
    }
    $get_styles = array(
    	'bootstrap.min.css',
    	'theme-plugins.css',
    	'theme-custom.css'
    );
    foreach($get_styles as $sheet) {
    	$sheets = trim($sheet);
    	if(file_exists($sheets)) {
    		ob_start("compress");
    		echo file_get_contents($sheets);
    		ob_end_flush();
    	}
    }
    ?>

    Can someone tell me how I can write this code wordpress friendly.

    Thanks in advance
    Marc

Viewing 1 replies (of 1 total)
  • Thread Starter Marc Troendle

    (@mtnetcontrolde)

    Hallo,

    I solved it by I have used in place

    echo file_get_contents($sheets);
    
    // with
    
    include($sheets);

    Maybe it helps any of you.

    Regards
    Marc

Viewing 1 replies (of 1 total)
  • The topic ‘Theme check warning’ is closed to new replies.