WordPress.org

Ready to get started?Download WordPress

Forums

GYS Themed Categories
[plugin: GYS Themed Categories][plugin: podpress] conflict (9 posts)

  1. tom_a_sparks
    Member
    Posted 1 year ago #

    when I go to active podpress and/or GYS Themed Categories I get "Fatal error: Call to a member function wp_rewrite_rules() on a non-object in /opt/lampp/htdocs/wp-includes/rewrite.php on line 294"

  2. ntm
    Member
    Posted 1 year ago #

    Hi Tom,

    I'm trying to find out why this problem occurs.

    It could be helpful if you could tell me your current podPress version.

    Thanks,
    Tim

  3. ntm
    Member
    Posted 1 year ago #

    The problem occurs somehow in the function url_to_postid() which gets called by the GYS Themed Categories plugin. The problem is that the PHP variable $wp_rewrite is not of the type object in the moment the plugin calls this function.
    The reason is possible that the plugin calls this function to early during the page load process.
    One solution could be to modify the GYS Themed Categories plugin a little bit (the last lines of the gys-themed-categories.php file).
    Wrap the initialization of the class GYSThemedCategories and the add_action and add_filter calls in a function

    function init_gys_themed_categories() {
    	if ( class_exists('GYSThemedCategories') && !isset($GYSThemedCategories) ) {
    		$GYSThemedCategories=new GYSThemedCategories(__FILE__);
    		add_action('category_edit_form_fields',array(&$GYSThemedCategories,'EditCategoryForm'));
    		add_action('category_add_form_fields',array(&$GYSThemedCategories,'EditCategoryForm'));
    		add_action('create_category',array(&$GYSThemedCategories,'SaveCategory'));
    		add_action('edit_category',array(&$GYSThemedCategories,'SaveCategory'));
    		add_filter('template',array(&$GYSThemedCategories,'Template'));
    		add_filter('stylesheet',array(&$GYSThemedCategories,'Stylesheet'));
    	}
    }

    and add this function to the WP Action Hook "plugins_loaded"

    add_action( 'plugins_loaded', 'init_gys_themed_categories' );

    This way the plugin gets initialized still early during a page load process. But at a defined moment.

    That resolves the error for me.

    Regards,
    Tim

  4. Luke Rumley
    Member
    Plugin Author

    Posted 1 year ago #

    Wow, thanks Tim! I will do a bit of testing and get your code added if that is all that is needed.

  5. Luke Rumley
    Member
    Plugin Author

    Posted 1 year ago #

    OK, fighting with the code now and getting this error a LOT, which then breaks the rest of the site (especially the themes area) completely:

    Notice: Undefined property: GYSThemedCategories::$Theme in /Users/lrumley/Documents/Websites/rumleydesign.dev/wp-content/plugins/gys-themed-categories/gys-themed-categories.php on line 263

    Any ideas? I tried 'init' instead of 'plugins_loaded' as well as several other hooks, but no love yet.

  6. ntm
    Member
    Posted 1 year ago #

    Luke,

    I would say that this notice points out that GYSThemedCategories has no property with the name Theme at a certain moment. I'm not sure but it has probably nothing to do with the used action hook. The class GYSThemedCategories has a sub function with the same name which you use to define 3 variables which available for all functions inside the class and these class-internal variable are always available and have default values. But the variable $this->Theme never gets initialized like that. But in function Stylesheet() the variable gets returned although it is not defined. My guess is that is what this notice is about.
    Maybe it helps if you add a new line in function GYSThemedCategories() which says $this->Theme='';.

    Could you describe a little bit better where or when this notice occurs? I haven't seen this one so far.

    Since you are debugging your plugin on this level: I'm getting on the Posts > Categories page some other notices:

    Notice: Trying to get property of non-object in D:\xampp\htdocs\wp33en\wp-content\plugins\gys-themed-categories-2\gys-themed-categories.php on line 119

    This line contains in my case $cid=$cid->cat_ID; and the $cid does not seem to have property with the name cat_ID.
    To avoid this notice I would check that first:
    if ( is_object($cid) AND isset($cid->cat_ID) ) { $cid=$cid->cat_ID; }

    Above the select-box on the Posts > Categories page:

    Notice: Undefined index: in D:\xampp\htdocs\wp33en\wp-content\plugins\gys-themed-categories-2\gys-themed-categories.php on line 30

    This is related to the for-loop in function GetOption()
    Activating your debug line, it prints $options: Arguments: Array ( [0] => CategoryThemes [1] => ). The second element in the array is empty and no array. One solution is to check in the loop whether $option[$o] is exists. This will solve also a further notice
    Which I get on Posts > Categories > Edit Category pages of categories for which I haven't selected a certain theme before.

    foreach($options AS $o) {
    	//echo "o: " . $o . "<br />";
    	if ( isset($option[$o]) ) {
    		$option=$option[$o];
    	}
    }

    I get a further notice at the same place:

    Notice: Undefined index: tag_ID in D:\xampp\htdocs\wp33en\wp-content\plugins\gys-themed-categories-2\gys-themed-categories.php on line 49

    It is regarding the line:

    $template=$this->GetOption('CategoryThemes', $_GET['tag_ID']);

    $_GET does not always contain the key 'tag_ID'. One solution would be

    if ( isset($_GET['tag_ID']) ) {
    	$template = $this->GetOption('CategoryThemes', $_GET['tag_ID']);
    } else {
    	$template = '';
    }
  7. Luke Rumley
    Member
    Plugin Author

    Posted 1 year ago #

    Wow, I am learning a lot here, and I really appreciate you taking the time to dig into this with me. It is definitely confirming my love of the WordPress community. I am super embarrassed of all my commented debug lines and random coding methods!

    I added the checks you mentioned and got rid of the undefined index errors. However, I am currently stuck with a white screen of death on the front end when the plugin is active at all. The admin / category screens work fine.

    Here is where I am at so far: http://pastebin.com/ygWB7CR4

  8. ntm
    Member
    Posted 1 year ago #

    You are right plugins_loaded is probably not the correct hook - at least to add all the actions and filters. I will do further tests.

    I still don't know exactly why the podPress and your plugin interfere this way.

    I look to this...

  9. ntm
    Member
    Posted 1 year ago #

    Hi Luke,

    I have made some more tests with your code from the pastebin and it seems that setup_theme the correct hook is (see also http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request).

    But I have tested with a WP3.3 blog and stumbled over a little incompatibility. The function wp_get_theme() is pretty new and works only with WP 3.4 and newer.
    I had to insert a version_compare():

    if (version_compare($wp_version, '3.4', '<')) {
    	$themedata = get_theme_data($tempstyleloc);
    } else {
    	$themedata = wp_get_theme($tempstyleloc);
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic