• I have built a simple child module which I cannot seem to get to activate. I’ve followed the API instructions very carefully.

    I’ve created a directory under plugins/bwp-google-xml-sitemaps-modules and placed my module there: page_arg.php. I’ve registered this directory under Site Options | Custom module directory.

    The php file writes text to a file when it’s called and the file isn’t being written so I’m certain it’s never getting loaded. Is there something else I need to do to register the module?

    Here is the module code:

    
    <?php
    
    /**
    *  Module calls parent then finds fields-hub entry and sets high priority
    */
    
    add_action('bwp_gxs_modules_built', 'bwp_gxs_add_arg_module');
    function bwp_gxs_add_arg_module()
    {
        global $bwp_gxs;
        $bwp_gxs->add_module('page', 'arg');
    }
    
    file_put_contents('~/test.txt', 'CALLED');
    
    class BWP_GXS_MODULE_PAGE_ARG extends BWP_GXS_MODULE_PAGE
    {
    	public function __construct()
    	{
    		// @since 1.3.0 this is left blank
    	}
    
    	protected function generate_data()
    	{
    		
    		parent::generate_data();
    		
    		for ($i = 0; $i < sizeof($this->data); $i++)
    		{
    			$data = $this->data[i];
    
    			if (strpos($data['location'], 'fields-hub') > 0) {
    				$data['priority'] = 1.0;
    				$data['freq'] = 'daily';
    				$dateTime = new DateTime($myDate);
    				$formatted = $dateTime->format("Y-m-d\TH:i:s.z\Z");
    				$data['lastmod'] = $formatted;
    				$this->data[i] = $data;
    			}
    
    		}
    
    		// always return true if we can get here,
    		// otherwise we're stuck in a SQL cycling loop
    		return true;
    	}
    }
    
    
Viewing 1 replies (of 1 total)
  • Plugin Author Khang Minh

    (@oddoneout)

    Have you tried to actually visit the custom XML sitemap? Can you try echoing something (and then exit) instead of using file_put_contents? The PHP process might not have access to your home (~) folder.

Viewing 1 replies (of 1 total)
  • The topic ‘Unable to register module’ is closed to new replies.