<?php

/*
Plugin Name: Pendataan SMA
Plugin URI: https://code.google.com/p/logbook-lenny/
Description: Pendataan SMA oleh DISDIKPORA <a href="http://kamparkab.go.id">Kabupaten Kampar</a>, dibuat oleh Leni Rapika Oktapiani sebagai Tugas Akhir di <a href="http://tif.poltek-kampar.ac.id">Teknik Informatika</a> <a href="http://poltek-kampar.ac.id">Politeknik Kampar</a>.
Author: Leni Rapika Oktapiani
Version: 1.0.0
Author URI: https://code.google.com/u/114844818880194934018/

*/

/** Jika dipanggil langsung dari http, bukan sebagai plugin, maka
  langsung tewas.
  (Perlindungan dari hacker yang mengakses langsung ke file ini, misal:
  ke /wp-content/plugins/logbook-lenny/
*/
if(!function_exists('add_action'))die('Maaf, jangan dijalankan langsung ya ...!');

/*
#####=====#####=====#####=====#####=====#####=====#####=====
#####=====#####=====#####=====#####=====#####=====#####=====
 ADMIN MENU
#####=====#####=====#####=====#####=====#####=====#####=====
#####=====#####=====#####=====#####=====#####=====#####=====
*/

//saat wordpress memanggil fungsi admin_menu, panggil juga fungsi kita pendataan_create_menu
add_action( 'admin_menu', 'pendataan_create_menu' );

function pendataan_create_menu() {

  //create custom top-level menu
  //add_menu_page( page_title, menu_title, capability, menu_slug, function, icon_url, position );
  //  page_title  —   The title of the page as shown in the    <title>   tags
  //  menu_title  —   The name of your menu displayed on the dashboard
  //  capability  —   Minimum capability required to view the menu
  //  menu_slug   —   Slug name to refer to the menu; should be a unique name
  //  function    —   Function to be called to display the page content for the item
  //  icon_url    —   URL to a custom image to use as the Menu icon
  //  position    —   Location in the menu order where it should appear

   
  add_menu_page( 
  	'SISMA', 			// page_title = judulnya 
  	'Sistem Informasi SMA', 	//menu_title
	'read',  			//capability
					//agar operator bisa melihat menu ini, jadikan capability nya menjadi read
	__FILE__, 			//menu_slug
	'data_sekolah_page',		//function // fungsi yang dipanggil saat menu ini diklik
	plugins_url( 'logbook16x16.png', __FILE__ ), 	//icon URL
	0 				// position
	);// 2012-06-06


  //create submenu items
  //add_submenu_page( parent_slug, page_title, menu_title, capability, menu_slug, function );
  
  add_submenu_page( __FILE__, 'Dispora > Data Guru', 'Data Guru', 'read', 
	__FILE__.'data_guru_page', 'data_guru_page' );
	



  //Following is a list of all available submenu functions in WordPress.
  //add_dashboard_page  —   Adds a submenu to the Dashboard menu
  //add_posts_page      —   Adds a submenu to the Posts menu
  //add_media_page      —   Adds a submenu to the Media menu
  //add_links_page      —   Adds a submenu to the Links menu
  //add_pages_page      —   Adds a submenu to the Pages menu
  //add_comments_page   —   Adds a submenu to the Comments page
  //add_theme_page      —   Adds a submenu to the Appearance menu
  //add_plugins_page    —   Adds a submenu to the Plugins menu
  //add_users_page      —   Adds a submenu to the Users menu
  //add_management_page —   Adds a submenu to the Tools menu
  //add_options_page    —   Adds a submenu to the Settings menu

  //create a submenu under Settings
  //add_options_page( 'PMB Settings Page', 'PMB', 'manage_options', __FILE__, 'data_sekolah_page' );
}

require_once('data_sekolah_page.php');
require_once('data_guru_page.php');
//require_once('data_siswa_page.php');







//untuk dashboard widgets yang tampil di halaman utama admin di WordPress
require_once('sisma_dashboard_widgets.php');







/*
#####=====#####=====#####=====#####=====#####=====#####=====
 WIDGETS
 /wp-admin/widgets.php
#####=====#####=====#####=====#####=====#####=====#####=====
*/

// use widgets_init action hook to execute custom function
add_action( 'widgets_init', 'sisma_register_widgets' );
             
 //register our widget
function sisma_register_widgets() {
  register_widget( 'sisma_widgetexample_widget_my_info' );
}


class sisma_widgetexample_widget_my_info extends WP_Widget {
  //process the new widget
  function sisma_widgetexample_widget_my_info() {
      $widget_ops = array(
          'classname' =>  'sisma_widgetexample_widget_class',
          'description' =>  'Display a user\'s favorite movie and song.'
      );
      $this->WP_Widget( 'sisma_widgetexample_widget_my_info', 'PMB Info',
          $widget_ops );
  }

    //build the widget settings form
    function form($instance) {
        $defaults = array( 'title' =>  'My Info', 'movie' =>  '', 'song' =>  '' );
        $instance = wp_parse_args( (array) $instance, $defaults );
        $title = $instance['title'];
        $movie = $instance['movie'];
        $song = $instance['song'];
        ?> 
         <p>Title: <input class="widefat" name="<?php echo $this->get_field_name('title');?>" type="text"
            value="<?php echo esc_attr($title); ?>" /></p> 
         <p>Favorite Movie:  <input class="widefat" name="<?php echo $this->get_field_name( 'movie' ); ?>"  type="text" value=" <?php echo esc_attr( $movie ); ?>" /></p> 
         <p>Favorite Song:   <textarea class="widefat" name="<?php echo $this->get_field_name( 'song' ); ?>" /><?php echo esc_attr( $song ); ?></textarea></p> 
         <?php
    }


  //save the widget settings
  function update($new_instance, $old_instance) {
      $instance = $old_instance;
      $instance['title'] = strip_tags( $new_instance['title'] );
      $instance['movie'] = strip_tags( $new_instance['movie'] );
      $instance['song'] = strip_tags( $new_instance['song'] );
           
      return $instance;
  }
  //display the widget
  function widget($args, $instance) {
    extract($args);
    echo $before_widget;
    $title = apply_filters( 'widget_title', $instance['title'] );
    $movie = empty( $instance['movie'] ) ? ' &nbsp;' : $instance['movie'];
    $song = empty( $instance['song'] ) ? ' &nbsp;' : $instance['song'];

    if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
    echo ' <p> Fav Movie: ' . $movie . ' </p> ';
    echo ' <p> Fav Song: ' . $song . ' </p> ';
    echo $after_widget;
  }
}

//shortcode untuk [data_guru]
require_once("data_guru.php");
require_once("data_sekolah.php");


?>