[PHP] Forms and settings admin panel

Discussion in 'PHP' started by Xtrapsp, Aug 21, 2012.

  1. #1
    Hey guys, I'm slowly getting the hang of php.I was wondering how I would make it so that i could add buttons next the the names of the plugins which activate and deactivate when you click on them, like a slider?


    
    <?php
    /*
    Plugin Name: Minepress Plugin Manager
    Plugin URI: http://minepress.co.uk
    Description: A Minepress plugin which allows control of other minepress plugins
    Author: Bradly Spicer
    Version: 0.02
    Author URI: http://minepress.co.uk
    */
    
    
    /********
     * global
     *******/
    
    
     
     /*******
      * Admin Panel
      *******/
      
    // Hook for adding admin menus
    add_action('admin_menu', 'minepress_add_pages');
    
    
    // action function for above hook
    function minepress_add_pages() {
        // Add a new submenu under Settings:
       // add_options_page(__('Test Settings','menu-Minepress'), __('Test Settings','menu-Minepress'), 'manage_options', 'testsettings', //'minepress_settings_page');
    
    
        // Add a new submenu under Tools:
        //add_management_page( __('Test Tools','menu-Minepress'), __('Test Tools','menu-Minepress'), 'manage_options', 'testtools', 
        //'minepress_tools_page');
    
    
        // Add a new top-level menu (ill-advised):
        add_menu_page(__('Minepress','menu-Minepress'), __('Minepress','menu-Minepress'), 'manage_options', 'minepress-top-level-handle', 'minepress_toplevel_page' );
    
    
        // Add a submenu to the custom top-level menu:
        add_submenu_page('minepress-top-level-handle', __('Settings','menu-Minepress'), __('Settings','menu-Minepress'), 'manage_options', 'sub-page', 'minepress_sublevel_page');
    
    
        // Add a second submenu to the custom top-level menu:
        add_submenu_page('minepress-top-level-handle', __('Blog','menu-Minepress'), __('Blog','menu-Minepress'), 'manage_options', 'sub-page2', 'minepress_sublevel_page2');
    }
    
    
    // minepress_settings_page() displays the page content for the Test settings submenu
    function minepress_settings_page() {
        echo "<h2>" . __( 'Test Settings', 'menu-Minepress' ) . "</h2>";
    }
    
    
    // minepress_tools_page() displays the page content for the Test Tools submenu
    //function minepress_tools_page() {
    //   echo "<h2>" . __( 'Test Tools', 'menu-Minepress' ) . "</h2>";}
    
    
    // minepress_toplevel_page() displays the page content for the custom Test Toplevel menu
    function minepress_toplevel_page() {
        echo "<h2>" . __( 'Test Toplevel', 'menu-Minepress' ) . "</h2>";
        ?>
        <div class ="wrap">
        <table class="widefat">
        <thead>
        <tr>
        <th>Plugin Header</th>
        <th> Activate/Inactive</th>
        </tr>        
        </thead>
        <tfoot>
        <tr>
        <th>Plugin Header 2</th>
        <th>Activate/Inactive 2</th>
        </tr>
        </tfoot>    
        <tbody>
        </tbody>    
        </table>    
        </div>
    <?php
    }
    
    
    // minepress_sublevel_page() displays the page content for the first submenu
    // of the custom Test Toplevel menu
    function minepress_sublevel_page() {
        echo "<h2>" . __( 'Minepress Settings', 'menu-Minepress' ) . "</h2>";
    }
    
    
    // minepress_sublevel_page2() displays the page content for the second submenu
    // of the custom Test Toplevel menu
    function minepress_sublevel_page2() {
        echo "<h2>" . __( 'Minepress Dev Blog', 'menu-Minepress') . "</h2>";
    }
    
    
    function my_plugin_menu() {
        add_options_page( 'Minepress Dynmap Plugin Options', 'Minepress Dynmap Plugin Options', 'manage_options', 'my-unique-identifier', 'mp_dynmap_plugin_options' );
    }
    
    
    function my_plugin_options() {
        if ( !current_user_can( 'manage_options' ) )  {
            wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
        }
        echo '<div class="wrap">';
        echo '<p>Here is where the form would go if I actually had options.</p>';
        echo '</div>';
    }
    
    
    
    
    
    /******
     * OutCome
     ******/
    function mpm_dynmap_shortcode() {
            $minepress_options = get_option('minepress');
     
            if($minepress_options['101'] == '') {
                    echo 'Oops! No test server specified!';
            } else {
                    echo '<iframe src="' . $test_options['101'] . ':' . ($test_options['102'] == '' ? '1234' : $test_options['102']) . '" width="100%" height="' . ($minepress_options['103'] == '' ? '500' : $test_options['103']) . '">';
            }
    }
    add_shortcode('testshortcode', 'test_shortcode'); 
    
    ?>
    Code (markup):
     
    Xtrapsp, Aug 21, 2012 IP
  2. lemonsquad

    lemonsquad Greenhorn Affiliate Manager

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    lemonsquad, Aug 21, 2012 IP