Add Admin menus or submenus depending on conditions

I managed to find a solution: File 1: //Count the number of active plugins whose Author is “My Brand”, and store the number in a global variable. $GLOBALS[‘mybrand_active_plugins’]=0; if (!function_exists(‘get_plugins’)){require_once ABSPATH.’wp-admin/includes/plugin.php’;} $plugins=get_plugins(); $activated_plugins=get_option(‘active_plugins’); foreach ($activated_plugins as $p){ if( (isset($plugins[$p])) AND ($plugins[$p][‘Author’]==’My Brand’)){ $GLOBALS[‘mybrand_active_plugins’]++; } } // Add menus on sidebar if($GLOBALS[‘mybrand_active_plugins’]<2) { function sub1_setup_menu() { … Read more

How to add a menu page for options in wordpress for user that has the role of vendor?

The third argument to add_menu_page() is $capability. add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); That governs who can see the page. You’ve registered yours as “administrator”, which is a user role. Presumably your vendors are not of that role. To fix this, you will need to change that argument to a capability (preferably … Read more

add menu page in loop menu order

Ok it took me a while, but I think I have it. I had to use usort. I also included the code for the get_top_level_pages() method. $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array(‘post_type’ => ‘page’, ‘posts_per_page’ => ‘-1’)); $top_level_pages = get_page_by_title(‘Locations’); $menuArray = get_page_children( $top_level_pages->ID, $all_wp_pages ); function compareOrder($a, $b) { return $a->menu_order – $b->menu_order; … Read more

How to get data from option page [closed]

I echoed out this $google_map_api_key = get_option(‘talimi_mapapi’); and its working fine. try in functions.php add require_once get_template_directory() . ‘/page-templates/theme-settings.php’; or add wp-load.php in your file. if you are using multi-site then try <?php get_site_option( $option, $default , $use_cache ) ?> reference https://codex.wordpress.org/Function_Reference/get_site_option

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)