WordPress.org

Forums

[resolved] P2 Theme with a fatal error - worked initially ok? (7 posts)

  1. warebloke
    Member
    Posted 6 years ago #

    Hi guys

    I have looked through the forums and this appears to be a new P2 error:-

    Fatal error: Call to undefined function: str_split() in /nfs/c03/h03/mnt/55103/domains/newsdesk.thedailydust.co.uk/html/wp-content/themes/p2/functions.php on line 352

    I am running WP 2.7.1
    And P2 Version P2 1.0.4

    I added around 7 posts this am, but this error suddenly displayed. Any help or fixes would be great, thanks

    Just realised this is a Theme issue - can someone let me know how to remove the (now) duplicate post from the How-to and troubleshooting?

  2. warebloke
    Member
    Posted 6 years ago #

    This is still not solved guys, thanks

  3. warebloke
    Member
    Posted 6 years ago #

    It may also help to add that there are zero plugins on this theme

  4. warebloke
    Member
    Posted 6 years ago #

    I managed to fix this by simply changing the PHP version from 4 to 5. It seems version 4 does not work with P2.

  5. tjeastmond
    Member
    Posted 6 years ago #

    Yeh, str_split() is PHP 5 only. Maybe they should mention that on the theme details page...or write a custom function to replicate it in PHP 4 environments

  6. tjeastmond
    Member
    Posted 6 years ago #

    Anyone else that has this problem, try adding this to the bottom of your theme's function.php file:

    if (!function_exists('str_split')) {
    	function str_split($string, $string_length = 1) {
    		if ($string_length < 1 || !$string_length) {
    			return false;
    		}
    
    		$parts = array();
    
    		if ($parts === 1 || $string_length > strlen($string)) {
    			$parts = array($string);
    		} else {
    			do {
    				$parts[] = substr($string, 0, $string_length);
    				$string = substr($string, $string_length);
    			} while ($string !== false);
    		}
    
    		return $parts;
    	}
    }

    Again, this is really only a problem for people in PHP 4 environments.

  7. noel
    Member
    Posted 5 years ago #

    Thanks for your help providing a fix @tjeastmond

Topic Closed

This topic has been closed to new replies.

About this Topic