PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Breaks Theme running in MAMP enviornment

s2Member Plugin. A Membership plugin for WordPress®.

Breaks Theme running in MAMP enviornment

Postby ptoledo1 » July 1st, 2011, 1:33 pm

Hi all.
I recently purchased this theme:
http://themeforest.net/item/folioway-pr ... eme/234219
and I really like it but I need s2member plugin to make it work for me. Problem is, everytime I enable the s2plugin it breaks the theme and gives me the "white screen of death." I'm running a local version of WP on MAMP/Mac enviornment. The theme works before I upload the plugin, breaks after I activate it, then works when I manually remove plugin. The plugin works on default themes that come with wordpress, which tells me it can work in a MAMP environment. I inquired with the theme owners and they didnt' feel that it was the theme that was bad but the plugin was doing something funky to it. They said that they'd work towards a solution if s2 community can figure out a problem with their theme. In any case, anyone have similar experience or recommendations? Not sure what other information to post, so if there is some tech info. that might help here, let me know and i'll post it. thanks for reading!
P
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby Cristián Lávaque » July 1st, 2011, 10:28 pm

Try adding this line to your /wp-config.php file:

Code: Select all
define("LOCALHOST", true);  


s2Member has a special routine, which we refer to as the Systematics Routine. It sees your IP address is the same as the server's IP; which is sometimes an issue on a WAMP/MAMP installation. It's fine so long as your domain is http://localhost/. However, if it's something other than that, you'll need to add that line in your /wp-config.php file so s2Member realizes it's running on a localhost installation.

I don't know if it has anything to do with your theme, but I thought I'd mention it since you're using MAMP.

Now, when you say the theme breaks, could you explain what you mean? Do you have a screenshot? Do you get errors?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Breaks Theme running in MAMP enviornment

Postby ptoledo1 » July 5th, 2011, 7:33 am

Hi Cristián,
Thanks for the reply, I really appreciate it. I didn't get right back to you because I was out for the holidays.

The local environment is indeed running from a http://localhost environment. s2member works just fine with another theme in the same MAMP install and set up. The problem happens when I enable the plugin. Everything goes white. I can't access any pages, even the admin page. I have to go in and manually delete the plugin for my Wordpress install to be accessible again.

Now, I can get s2member to work on the default WP theme in the same environment, no problem. And I can get the theme to work in the same environment. It only happens when I try and get the two to play together.

Any other thoughts or suggestions would be great. Not sure if WP generates error logs. if it does, and someone points me to thme, I can post when I go back in and activate the plugin which brings up the white screen.

P
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby Cristián Lávaque » July 5th, 2011, 12:21 pm

I see, then it's a conflict between the theme and s2Member, is that what you mean? Watch this video and see if it helps http://www.s2member.com/options-page-di ... ing-video/
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Breaks Theme running in MAMP enviornment

Postby ptoledo1 » August 1st, 2011, 12:17 pm

HI,
Thanks. Yes, you're right. it's a conflict between the theme and S2 member. I can't even get into the theme once I enable it. I get a blank white screen. I have to go in and remove S2 Member from the plugins folder to get my theme back. Not sure where to go from here when it' a theme vs. plugin conflict - where to look an where to adjust is the question I suppose. Any advise would be be great.

Also, it's a MAMP environment so maybe that also throws another wrench into the situation as well. I haven't tested the theme and the plugin in a live environment. UPDATE: just tested on live environment, broke theme once I activated plugin as well, with this error:
Code: Select all
Fatal error: Class 'iWaK_Cache' not found in /home1/halofdcc/public_html/mobiledemo/wp-content/themes/folioway/core/itools.php on line 75

Thanks!

P
Last edited by ptoledo1 on August 1st, 2011, 12:50 pm, edited 1 time in total.
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby ptoledo1 » August 1st, 2011, 12:24 pm

error message:
file.jpg
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby ptoledo1 » August 1st, 2011, 12:31 pm

BTW, tried the wp-config mentioned above; theme still goes white upon plugin activation. the authors of the theme said they'd welcome some insight if you feel the problems are on the theme side. This is what the theme author wrote regarding the error:
Code: Select all
Fatal error: Class 'iWaK_Cache' not found in /home1/halofdcc/public_html/mobiledemo/wp-content/themes/folioway/core/itools.php on line 75



'iWaK_Cache' is an essential class in Folioway, i don't know how and why it is not loaded (per the message you pasted) with your plugin. Please contact the plugin author first, i'd like to help if the author says the problem is on my theme, thanks!
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby Cristián Lávaque » August 1st, 2011, 6:00 pm

Thanks for the updates. I'll notify Jason of this and wait for his comments. :)

Could you post a copy of the file that spits the error here so Jason takes a look at their code? Where the 'iWaK_Cache' class is and itools.php where it tries to use it.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Breaks Theme running in MAMP enviornment

Postby Jason Caldwell » August 2nd, 2011, 11:21 pm

You might ask the theme developer if his theme or any embedded plugins that he uses employs the use of PHP's "SPL Autoload functionality". If so, does he use spl_autoload_register(), or does the theme reply on a dedicated autoload handler? If so, please update the theme to use spl_autoload_register() to make room for other plugins.

Otherwise, if this does NOT help you any, please ask the theme developer to contact us. We'll be happy to provide a free copy of both s2Member and s2Member Pro for them to test against. Please ask them to use this private contact form: http://www.s2member.com/contact/
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Breaks Theme running in MAMP enviornment

Postby ptoledo1 » August 4th, 2011, 1:09 pm

Thanks Cristián and Jason. Thanks for the help. I posted in the theme developer's forum. I imagine they'll respond shortly either there or contact you directly.

Here is the itools php file from the theme that seems to be spitting out the error. Thanks for taking a look! I really appreciate the time and attention,

P

Code: Select all
<?php

    function iwak_var_dump($arr) {
        $retStr = '<ul>';
        if (is_array($arr)){
            foreach ($arr as $key=>$val){
                if (is_array($val)){
                    $retStr .= '<li>' . $key . ' => ' . iwak_var_dump($val) . '</li>';
                }else{
                    $retStr .= '<li>' . $key . ' => ' . $val . '</li>';
                }
            }
        }
        $retStr .= '</ul>';
        echo $retStr;
    }
   
    function iwak_array_merge ( array &$array1, array &$array2 )
    {
        $merged = $array1;
   
        foreach ( $array2 as $key => &$value )
        {
            if ( is_array ( $value ) && isset ( $merged [$key] ) && is_array ( $merged [$key] ) )
                $merged [$key] = iwak_array_merge ( $merged [$key], $value );
            else
                $merged [$key] = $value;
        }
   
        return $merged;
    }
   
    function iwak_array_unique($root_array) {
        if(!is_array($root_array))
               return $root_array;

        foreach ($root_array as &$child_array){
            $child_array=serialize($child_array);
        }

        $root_array=array_unique($root_array);

        foreach ($root_array as &$child_array){
            $child_array=unserialize($child_array);
        }

        return $root_array;
    }

    function iwak_get_options() {
        $cache = wp_cache_get(IWAK_OPTIONS, THEME_NAME);
        if(!is_array($cache)) {
            $cache = get_option(IWAK_OPTIONS);
            if(!empty($cache))
                wp_cache_add(IWAK_OPTIONS, $cache, THEME_NAME);
        }
       
        return $cache;
    }
   
    function iwak_default_options() {
        global $ikd;
        return $ikd;
    }
   
    function iwak_get_sidebar($name=null, $default=true) {
        global $iks;
        $iks->get_sidebar($name, $default);
    }
   
    function iwak_get_list($type) {
        global $iwak_cache;
       
        if(!isset($iwak_cache))
            $iwak_cache = new iWaK_Cache();
       
        switch($type) {
            case 'link_categories':
                $method = 'get_link_categories';
                break;
            case 'widget_areas':
                $method = 'get_widget_areas';
                break;
            case 'featured_posts':
                $method = 'get_featured_posts';
                break;
            case 'sticky_posts':
                $method = 'get_sticky_posts';
                break;
            case 'post_types':
                $method = 'get_ptypes_list';
                break;
            case 'category':
                $method = 'get_category_list';
                break;
            case 'tag':
                $method = 'get_tag_list';
                break;
            default:
                // Need to be optimized for a common operation thus do not have to add a 'case' whenever there is a new type of request
                if(taxonomy_exists($type))
                    $method = 'get_term_list';
                elseif(post_type_exists($type))
                    $method = 'get_post_list';
                $parameter = $type;
                break;
            // default:
                // $method = 'get_'. $type. '_list';
                // break;
        }
           
        if(!method_exists($iwak_cache, $method))
            return;
           
        return isset($parameter) ? $iwak_cache->$method($parameter) : $iwak_cache->$method();
    }

    function i_scandir($path) {
        if (function_exists(scandir)) {
            return scandir($path);
        }
        else {
            $dh = opendir($path);
            while (false !== ($filename = readdir($dh))) {
                $files[] = $filename;
            }
            closedir($dh);
            return $files;
        }
    }

    function showinfo($info) {
        echo '<script type="text/javascript">alert("'. $info. '")</script>';
    }
   
    //get sub string
    function i_substr($input, $start, $length, $end='...')  {
   
        $text = substr($input, $start, $length);
        $len = strlen($text);
       
        if( $len < $length ) return $text;
       
        if( $len > 0 && !seems_utf8($text[$len - 1]) ) {
       
            for( $i=0; $i>-3; $i--) {
           
                if( $len < 3 ) return '';
               
                if( !seems_utf8($text[$len - 3].$text[$len - 2].$text[$len - 1]) ) {
                    $len --;
                } else {
                    break;
                }
               
            }
           
        }

        if( $i != 0 )
            return substr($text, 0, $i). $end;
        else
            return $text. $end;
    }
       
    /**
     * Truncates text.
     *
     * Cuts a string to the length of $length and replaces the last characters
     * with the ending if the text is longer than length.
     *
     * @param string  $text String to truncate.
     * @param integer $length Length of returned string, including ellipsis.
     * @param string  $ending Ending to be appended to the trimmed string.
     * @param boolean $exact If false, $text will not be cut mid-word
     * @param boolean $considerHtml If true, HTML tags would be handled correctly
     * @return string Trimmed string.
    */
    function truncate($text, $length = 100, $ending = '', $removeImg = true, $exact = true, $considerHtml = true, $removeGallery = true) {
        if ($considerHtml) {
       
            // remove gallery shortcode
            //if($removeGallery) $text = preg_replace('/\[gallery[^\]]*\]/is', '', $text);
           
            // if the plain text is shorter than the maximum length, return the whole text
            if (strlen(preg_replace('/<.*?>/', '', $text)) <= $length) {
                $text = preg_replace('/<\s*\/?div(\s.+?)?>/is', '', $text);
                //$text = preg_replace('/<\s*\/div\s*>/is', '', $text);
                if($removeImg) $text = preg_replace('/<\s*(img)(\s.+?)?>/is', '', $text);
                return $text;
            }
            // splits all html-tags to scanable lines
            preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER);
            $total_length = 0;
            $open_tags = array();
            $truncate = '';
            foreach ($lines as $line_matchings) {
                // if there is any html-tag in this line, handle it and add it (uncounted) to the output
                if (!empty($line_matchings[1])) {
               
                    // exclude tag 'div' (f.e. <div ...>, </div>); and if $removeImg is true, exclude tag 'image' too (f.e. <img ... />)
                    if ( !preg_match('/^<!--more(.*?)?-->$/', $line_matchings[1]) && !($removeImg && preg_match('/^<\s*(img)(\s.+?)?>$/is', $line_matchings[1])) && !preg_match('/^<\s*\/?div(\s.+?)?>$/is', $line_matchings[1]) ) {
                   
                        // if it's an "empty element" with or without xhtml-conform closing slash (f.e. <br/>)
                        if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
                            // do nothing
                        // if tag is a closing tag (f.e. </b>)
                        } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
                            // delete tag from $open_tags list
                            $pos = array_search($tag_matchings[1], $open_tags);
                            if ($pos !== false) {
                                unset($open_tags[$pos]);
                            }
                        // if tag is an opening tag (f.e. <b>)
                        } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
                            // add tag to the beginning of $open_tags list
                            array_unshift($open_tags, strtolower($tag_matchings[1]));
                        }

                        // add html-tag to $truncate'd text
                        $truncate .= $line_matchings[1];
                    }
                }
                // calculate the length of the plain text part of the line; handle entities as one character
                $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
                if ($total_length+$content_length> $length) {
                    // the number of characters which are left
                    $left = $length - $total_length;
                    $entities_length = 0;
                    // search for html entities
                    if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) {
                        // calculate the real length of all entities in the legal range
                        foreach ($entities[0] as $entity) {
                            if ($entity[1]+1-$entities_length <= $left) {
                                $left--;
                                $entities_length += strlen($entity[0]);
                            } else {
                                // no more characters left
                                break;
                            }
                        }
                    }
                    $truncate .= i_substr($line_matchings[2], 0, $left+$entities_length);
                    // maximum lenght is reached, so get off the loop
                    break;
                } else {
                    $truncate .= $line_matchings[2];
                    $total_length += $content_length;
                }
                // if the maximum length is reached, get off the loop
                if($total_length>= $length) {
                    break;
                }
            }
        } else {
            if (strlen($text) <= $length) {
                return $text;
            } else {
                $truncate = i_substr($text, 0, $length - strlen($ending));
            }
        }
        // if the words shouldn't be cut in the middle...
        if (!$exact) {
            // ...search the last occurance of a space...
            $spacepos = strrpos($truncate, ' ');
            if (isset($spacepos)) {
                // ...and cut the text in this position
                $truncate = i_substr($truncate, 0, $spacepos);
            }
        }
        // add the defined ending to the text
        $truncate .= $ending;
        if($considerHtml) {
            // close all unclosed html-tags
            foreach ($open_tags as $tag) {
                $truncate .= '</' . $tag . '>';
            }
        }
        return $truncate;
    }
   
?>
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby ptoledo1 » August 8th, 2011, 10:58 am

Hi,
an update to the theme worked. FYI, here is what the theme developer wrote:
It was found the affected part in Folioway was the classes loading process that using the PHP native function __autoload(), and the function stopped working with several plugins for unknown reason.

Here a custom classes loading function was introduced to replace the native one in Folioway version 1.1.8, upgrade your Folioway to this latest version and your conflict issue gone


thanks for everyones help!

P
User avatar
ptoledo1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: Breaks Theme running in MAMP enviornment

Postby Cristián Lávaque » August 8th, 2011, 2:54 pm

Great! Glad it got sorted out. Thanks for the update. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron