• Resolved 10bradders10

    (@10bradders10)


    Hi,

    Can you put ‘Groups’ under Affiliates in the correct menu structure as a best practice, please?

    See – https://app.screencast.com/4NBSxtAB0Mt9o

    This is currently causing us an issue as we can’t select it, to turn it on in SolidWP Central, as we like to customise our users dashboards and the plugins they can see.

    The other menu items are all working, apart from ‘Groups’.

    Thanks.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    Thank you for reaching out! The “Groups” menu item is registered using the same method used for all of our other pages.

    The two differences are:

    1. We’re registering it only when the Affiliates and Groups pages are in view.
    2. We’ve prepended an icon to the menu item’s text.

    I’m guessing that because point #1, you’re not seeing the menu item as selectable in SolidWP.

    I’m afraid that, for the time being, we will not modifying the way this works, as we do not want to show the menu item all the time.

    However, as a workaround, you can use this code snippet:

    /**
     * Register the Affiliate Groups admin submenu page.
     * 
     * @param array $submenu_pages
     * 
     * @return array
     *
     */
    function slicewp_custom_register_submenu_page_affiliate_groups( $submenu_pages ) {
    
        if ( empty( $_GET['page'] ) ) {
            return $submenu_pages;
        }
    
    	if ( ! is_array( $submenu_pages ) ) {
    		return $submenu_pages;
    	}
    
    	$submenu_pages['affiliate_groups'] = array(
    		'class_name' => 'SliceWP_Submenu_Page_Affiliate_Groups',
    		'data' 		 => array(
    			'page_title' => __( 'Groups', 'slicewp' ),
    			'menu_title' => '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 20 20"><path fill="currentColor" d="M10.72 16.78a.75.75 0 0 0 1.06 0l4-4a.75.75 0 0 0 0-1.06l-4-4a.75.75 0 1 0-1.06 1.06l2.72 2.72H7A1.5 1.5 0 0 1 5.5 10V3.75a.75.75 0 0 0-1.5 0V10a3 3 0 0 0 3 3h6.44l-2.72 2.72a.75.75 0 0 0 0 1.06Z"></path></svg>' . __( 'Groups', 'slicewp' ),
    			'capability' => apply_filters( 'slicewp_submenu_page_capability_affiliate_groups', 'manage_options' ),
    			'menu_slug'  => 'slicewp-affiliate-groups'
    		)
    	);
    
    	return $submenu_pages;
    
    }
    remove_filter( 'slicewp_register_submenu_page', 'slicewp_register_submenu_page_affiliate_groups', 20 );
    add_filter( 'slicewp_register_submenu_page', 'slicewp_custom_register_submenu_page_affiliate_groups', 20 );

    This will decouple our own page registration callback and couple a custom registration function that does not take into account point #1.

    Please copy the code and add it to your website. If you’re not sure how to add code snippets to your site, you can use the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/).

    Thank you and best wishes,

    Mihai

    Thread Starter 10bradders10

    (@10bradders10)

    Thanks for the reply.

    I’ve tried the code, but unfortunately, ‘Groups’ does still not appear in Solid Central.

    See – https://app.screencast.com/QVRJ90dUptYv5

    Any ideas please?

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    Please update the code I’ve previously sent with the one below:

    /**
     * Register the Affiliate Groups admin submenu page.
     * 
     * @param array $submenu_pages
     * 
     * @return array
     *
     */
    function slicewp_custom_register_submenu_page_affiliate_groups( $submenu_pages ) {
    
    	if ( ! is_array( $submenu_pages ) ) {
    		return $submenu_pages;
    	}
    
    	$submenu_pages['affiliate_groups'] = array(
    		'class_name' => 'SliceWP_Submenu_Page_Affiliate_Groups',
    		'data' 		 => array(
    			'page_title' => __( 'Groups', 'slicewp' ),
    			'menu_title' => '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 20 20"><path fill="currentColor" d="M10.72 16.78a.75.75 0 0 0 1.06 0l4-4a.75.75 0 0 0 0-1.06l-4-4a.75.75 0 1 0-1.06 1.06l2.72 2.72H7A1.5 1.5 0 0 1 5.5 10V3.75a.75.75 0 0 0-1.5 0V10a3 3 0 0 0 3 3h6.44l-2.72 2.72a.75.75 0 0 0 0 1.06Z"></path></svg>' . __( 'Groups', 'slicewp' ),
    			'capability' => apply_filters( 'slicewp_submenu_page_capability_affiliate_groups', 'manage_options' ),
    			'menu_slug'  => 'slicewp-affiliate-groups'
    		)
    	);
    
    	return $submenu_pages;
    
    }
    remove_filter( 'slicewp_register_submenu_page', 'slicewp_register_submenu_page_affiliate_groups', 20 );
    add_filter( 'slicewp_register_submenu_page', 'slicewp_custom_register_submenu_page_affiliate_groups', 20 );

    I believe that with this code snippet, it should work.

    Please let me know how it goes.

    Thank you and best wishes,

    Mihai

    Thread Starter 10bradders10

    (@10bradders10)

    Hi,

    No change I’m afraid. See the screenshot below with the URL.

    https://app.screencast.com/SGOwHvveG3ND5

    Any further ideas?

    Thanks.

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    Hmm… I’m not experiencing this. While I don’t have SolidWP Central, meaning that I cannot test how it works, the affiliate groups page loads normally for me with the code snippet inserted in the site.

    Can you please share a screenshot with how you’ve added the snippet to your website?

    Also, does the page now appear in SolidWP Central? If yes, does the error that you last shared appear after checking/unchecking the “Groups” page from SolidWP Central?

    Thank you and best wishes,

    Mihai

    Thread Starter 10bradders10

    (@10bradders10)

    Hi,

    The code has been added in functions.php and the cache purged.

    However, ‘Groups’ does still not display in Solid Central to check/uncheck, so therefore it still won’t show. This is the error from my previous reply. – https://app.screencast.com/SGOwHvveG3ND5

    This is why we’ve suggested to have the ‘Groups’ menu appear exactly the same as the others, as Best Practice.

    Any further code options to get this working?

    Thanks.

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    I’ve just added the code snippet to the active theme’s functions.php file and everything is running normally for me. The “Groups” menu item is showing up all the time and the page is accessible.

    The last code snippet I shared is the exact method we use to register all of our pages, which in turn uses the hooks that WordPress provides.

    I’m not sure how you have everything set up, but I cannot replicate the error you’re facing.

    I recommend you to double check that the code snippet has been copied entirely. Also, please add the snippet via a code snippet plugin, as an alternative to the functions.php file, just to check if something is changing.

    Thank you and best wishes,

    Mihai

    Thread Starter 10bradders10

    (@10bradders10)

    Thanks,

    We’ve now moved the code to FluentSnippets, and as you can see here, groups does not show to check – https://app.screencast.com/Qkl7a062ApXjj

    The Groups menu item is still showing like this – https://app.screencast.com/IHvaX1ii13Baz

    I’m fairly certain if you can update your plugin to have the menu navigation showing correctly as the same standards as the other menu items, then SolidCentral will instantly recognise it and allow us to check it, so the user can then see it.

    Can you update SliceWP with Groups as the correct menu item, please?

    Thanks.

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    As I mentioned before, this page is registered the same as all of our other pages and in line with WordPress’ standard of adding admin pages.

    The only difference is that we’ve added an SVG icon in front of the “Groups” text, but this by itself, I believe, should not influence SolidWP Central’s page detection.

    However, to test this out, you can replace the code I previously sent, with the one below:

    /**
     * Register the Affiliate Groups admin submenu page.
     * 
     * @param array $submenu_pages
     * 
     * @return array
     *
     */
    function slicewp_custom_register_submenu_page_affiliate_groups( $submenu_pages ) {
    
    	if ( ! is_array( $submenu_pages ) ) {
    		return $submenu_pages;
    	}
    
    	$submenu_pages['affiliate_groups'] = array(
    		'class_name' => 'SliceWP_Submenu_Page_Affiliate_Groups',
    		'data' 		 => array(
    			'page_title' => __( 'Groups', 'slicewp' ),
    			'menu_title' => __( 'Groups', 'slicewp' ),
    			'capability' => apply_filters( 'slicewp_submenu_page_capability_affiliate_groups', 'manage_options' ),
    			'menu_slug'  => 'slicewp-affiliate-groups'
    		)
    	);
    
    	return $submenu_pages;
    
    }
    remove_filter( 'slicewp_register_submenu_page', 'slicewp_register_submenu_page_affiliate_groups', 20 );
    add_filter( 'slicewp_register_submenu_page', 'slicewp_custom_register_submenu_page_affiliate_groups', 20 );

    This will register the page without the arrow icon.

    I’ve just tested this with FluentSnippets and it’s working nicely.

    Please check the screenshot for reference: https://ibb.co/kMpVF5T

    Now, I can’t say why it’s not showing up in SolidWP Central. You may need to play with the priority of the snippet to have the code run earlier.

    Thank you and best wishes,

    Mihai

    Thread Starter 10bradders10

    (@10bradders10)

    Thanks,

    The icon has now been removed successfully – https://app.screencast.com/smqinyrYJdoth

    However, this still doesn’t get pulled through. There must be something different with that page compared to the Affiliates page or any of the others.

    I’ve also decreased the priority to 10, and still the same.

    Is it the Pro plugin element?

    Can you compare the other pages with the Groups page, please?

    Thanks.

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    The Groups page is added by the Pro plugin. I can’t say how SolidWP is detecting the pages, but maybe this is why it isn’t showing up.

    It is registered from another plugin technically, but it’s registered the same as all other pages from core.

    Thank you and best wishes,

    Mihai

    Thread Starter 10bradders10

    (@10bradders10)

    Hi iova,

    Had to turn off the snippet due to the following error below.

    We’re still working with SolidWP to get the menu appear.

    Error Details
    =============
    An error of type E_ERROR was caused in line 560 of the file ..../public_html/wp-content/plugins/slicewp/index.php. Error message: Uncaught Error: Class "SliceWP_Submenu_Page_Affiliate_Groups" not found in ..../public_html/wp-content/plugins/slicewp/index.php:560
    Stack trace:
    #0 ..../public_html/wp-includes/class-wp-hook.php(324): SliceWP->load_admin_submenu_pages('')
    #1 ..../public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
    #2 ..../public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #3 ..../public_html/wp-admin/includes/menu.php(161): do_action('admin_menu', '')
    #4 ..../public_html/wp-admin/menu.php(417): require_once('/home/customer/...')
    #5 ..../public_html/wp-admin/admin.php(158): require('/home/customer/...')
    #6 .../public_html/wp-admin/plugins.php(10): require_once('/home/customer/...')
    #7 {main}
    thrown

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @10bradders10,

    That particular error can indeed appear if you have the Pro plugin inactive. As the page in question is loaded by pro, not core, pro is required to be active.

    I have adapted the code to take this into account. Here’s the code snippet:

    /**
     * Register the Affiliate Groups admin submenu page.
     * 
     * @param array $submenu_pages
     * 
     * @return array
     *
     */
    function slicewp_custom_register_submenu_page_affiliate_groups( $submenu_pages ) {
    	
    	if ( ! class_exists( 'SliceWP_Submenu_Page_Affiliate_Groups' ) ) {
    		return $submenu_pages;
    	}
    
    	if ( ! is_array( $submenu_pages ) ) {
    		return $submenu_pages;
    	}
    
    	$submenu_pages['affiliate_groups'] = array(
    		'class_name' => 'SliceWP_Submenu_Page_Affiliate_Groups',
    		'data' 		 => array(
    			'page_title' => __( 'Groups', 'slicewp' ),
    			'menu_title' => __( 'Groups', 'slicewp' ),
    			'capability' => apply_filters( 'slicewp_submenu_page_capability_affiliate_groups', 'manage_options' ),
    			'menu_slug'  => 'slicewp-affiliate-groups'
    		)
    	);
    
    	return $submenu_pages;
    
    }
    remove_filter( 'slicewp_register_submenu_page', 'slicewp_register_submenu_page_affiliate_groups', 20 );
    add_filter( 'slicewp_register_submenu_page', 'slicewp_custom_register_submenu_page_affiliate_groups', 20 );

    With this new iteration of the code, you should no longer see the error you’ve shared.

    Thank you and best wishes,

    Mihai

    Ben Meredith

    (@benmeredithgmailcom)

    For any who might stumble onto this and still have trouble getting that above code to work, a few things:

    First, after you implement the snippet in @iovamihai’s last note here, make sure to deactivate and reactivate *any* plugin. Solid Central (currently) only goes and fetches a fresh list of Menu items when a plugin is activated.

    Next, our team (on the SolidWP side) is looking into how we can better handle the situation where plugins (SliceWP is not the only one!) who conditionally display menu items. For now this workaround will do, but we ultimately want to find a less hacky solution.

    Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.