Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:49:03+00:00 2026-06-17T13:49:03+00:00

I have built a very simple plugin and uploaded it on my wordpress account

  • 0

I have built a very simple plugin and uploaded it on my wordpress account which is run on localhost. Once I activate it, its output will be shown on every page, and it wont be added to the left hand side menu of wordpress. what should I add to it to be added to the menu? I suppose it should be done using add_action but do not know how !!

<?php
/*
Plugin Name: myphotos Plugin
Description: A simple wordpress plugin.
Version: 1.0
Author: Saeed Pirdost
Copyright: 2012,  Saeed Pirdost
*/
?>
<?php 
add_filter('admin_notices','myprint');
?>
function myprint()
{
    echo "hello";
}
?>

I used the following code as well but when I activate the plugin just a white page will be shown.

add_menu_page(__('My Menu Page'), __('My Menu'), 'edit_themes', 'my_new_menu', 'myprint', '', 7); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:49:04+00:00Added an answer on June 17, 2026 at 1:49 pm

    First, stop opening and closing PHP tags at every line, you don’t need that. This is used when some HTML is happening in the middle of your PHP.

    Also, the last closing ?> of a PHP file can/should be omitted. It may even break a site if there is a white-space after it…

    Refer to WordPress_Coding_Standards.


    Second, you need to decide if you want to use the function my_print as callback of admin_notices or of add_menu_page. Can it be both? In this case, yes, but really, do it only if you know what you are doing.


    Your plugin is breaking because add_menu_page cannot be called directly.
    Always check the documentation of each function that don’t work as expected:
    Function_Reference/add_menu_page


    Here’s a working version of your plugin:

    <?php
    /*
    Plugin Name: myphotos Plugin
    Description: A simple wordpress plugin.
    Version: 1.0
    Author: Saeed Pirdost
    Copyright: 2012,  Saeed Pirdost
    */
    
    add_filter( 'admin_notices', 'print_my_notice' );
    
    add_action( 'admin_menu', 'register_custom_menu_page' );
    
    function print_my_notice()
    {
        echo '<div class="updated">
               <p>I am a big notice that appears everywhere</p>
            </div>';
    }
    
    function register_custom_menu_page() 
    {
        add_menu_page(
            __( 'My Menu Page', 'my-plugin-text-domain' ), 
            __( 'My Menu', 'my-plugin-text-domain' ), 
            'edit_themes', 
            'my_new_menu', 
            'print_my_menu', 
            'http://upload.wikimedia.org/wikipedia/commons/a/aa/Wink%2816px%29.svg', 
            7
        );      
    }
    
    function print_my_menu()
    {
        echo '<div id="icon-post" class="icon32"></div>
            <h2>My plugin</h2>
                <p><a class="button-secondary" href="#"> ' 
                . __( 'I am a translation', 'my-plugin-text-domain' ) 
                . '</a>
                </p>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple class with Watin test which is built and run
I have a very simple node.js app built on express which has been handling
I have built a very simple blog application using Ruby on Rails. New to
I'm working with a website built in .net, I have a very simple popup
I have built a very simple internal messaging system inside my application, i want
I have built a variety of little scripts using Ruby's very simple Queue class,
I have a very simple chat system I've built using PHP and MySQL (this
I have built a very simple CakePHP website using the Auth component and have
I have a very simple page built to display a map and overlay a
I have two apps. One is a very simple app that I built with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.