If a function requires add_action(‘init’) how can I run it only once on plugin activation?

I don’t think there is a need to add the items to the init hook from the activation function. I think you can call them directly: private static function single_activate() { self::add_partner_terms(); //$this->add_partner_terms(); self::add_geo_terms(); //$this->add_geo_terms(); } I’m not really sure if it should be self:: or $this-> because I’m a little bit fuzzy about OOP, … Read more

Hide Theme options and Customize Admin menu

Direct answer: add_action( ‘admin_menu’, function() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition for the user means show menu for this user if(is_admin() && $user_name != ‘USERNAME’) { //We need this because the submenu’s link (key from the array too) will always be generated with the current SERVER_URI in mind. $customizer_url = … Read more

Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]

WordPress as a project has extreme commitment to backwards compatibility. Whatever new things you add the old things need to work still. Whatever things you change still need to work in old way as well. So regardless of how WP started as non–MVC application, it cannot become one without retaining all of its non–MVC ways. … Read more