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

I am using wp_insert_term() to insert a large number of taxonomy terms from a csv file. The contents of that csv file might change occasionally. According to the codex, wp_insert_term() needs to run on add_action(‘init’) but I only want to run it once. How can I achieve that on plugin activation? I am currently just … Read more

Hide Theme options and Customize Admin menu

Under the appearance admin menu, I have customizer added by the theme, and theme options added by a plugin. I’m using this code to hide both menus ( submenu’s of Appearance )for ALL admins apart from a certain USERNAME. function hide_menu() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition for the user … Read more

Why are two functions over-riding each other?

I have function in my plugin that is: add_filter(‘comment_text’, ‘commentimage_comment_text’); function commentimage_comment_text($comment=””) { $options = get_option(‘commentimage’); $id = get_comment_ID(); $images = $options[‘images’]; if (!isset($images) || !is_numeric($images)) $images = 1; $url = get_option(‘siteurl’); for ($i=0; $i<$images; $i++) { if (file_exists(ABSPATH . ‘wp-content/comment-image/’ . $id . ($i==0?”:(‘-‘.$i)) . ‘-tn.jpg’)) { $comment .= ‘<p><a href=”‘ . $url . … Read more