/** * Initialize the class and set its properties. * * @since 1.0.0 * @var string $plugin_slug The name of the plugin. * @var string $version The version of this plugin. */ public function __construct($plugin) { $this->plugin = $plugin; $this->plugin_slug = $this->plugin->get('slug'); $this->plugin_name = $this->plugin->get('name'); $this->version = $this->plugin->get('version'); }
/** * Get the ID of the auto menu object. * * @since 1.0.0 * * @return int ID of the auto menu. */ public function get_auto_menu_id() { $auto_menu_name = $menu_name = $this->plugin->get('menu_name'); $auto_menu = get_term_by('name', $auto_menu_name, 'nav_menu'); // Exit if the menu doesn't exist (edge case after deactivation) if (empty($auto_menu->term_id)) { return false; } return $auto_menu->term_id; }