Created
February 11, 2013 21:53
-
-
Save jafstar/4757947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Demo | |
Plugin URI: http://demo.com | |
Description: Demo Plugin | |
Version: 1.0 | |
Author: Demo LLC | |
Author URI: http://demo.com | |
License: GPL2 | |
*/ | |
/* Copyright 2013 DEMO LLC (email : [email protected]) | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License, version 2, as | |
published by the Free Software Foundation. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
*/ | |
//ADMIN | |
add_action( 'admin_menu', 'my_admin_menu' ); | |
//MAIN MENU | |
function my_admin_menu() { | |
add_menu_page('Demo', 'demo', 'manage_options', 'demo-index', 'index_page',null,4); | |
add_submenu_page('demo-index','Add','Add Entry','manage_options','demo-add','add_page'); | |
add_submenu_page('demo-index','Edit','Edit Entry','manage_options','demo-edit','edit_page'); | |
} | |
//INDEX | |
function index_page() { | |
if ( !current_user_can( 'manage_options' ) ) { | |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | |
} | |
include_once('views/index.php'); | |
} | |
//ADD | |
function add_page() { | |
if ( !current_user_can( 'manage_options' ) ) { | |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | |
} | |
include_once('views/add.php'); | |
} | |
//EDIT | |
function edit_page() { | |
if ( !current_user_can( 'manage_options' ) ) { | |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | |
} | |
include_once('views/edit.php'); | |
} | |
function my_enqueue($hook) { | |
wp_enqueue_style( 'css', plugins_url('/mesh/css/scripts.css',dirname(__FILE__))); | |
wp_enqueue_script( 'js', plugins_url('/mesh/js/styles.js',dirname(__FILE__))); | |
} | |
add_action( 'admin_enqueue_scripts', 'my_enqueue' ); | |
//AJAX | |
add_action('wp_ajax_nopriv_AdminQuery', 'AdminQueryFunction'); | |
add_action('wp_ajax_AdminQuery', 'AdminQueryFunction'); | |
function AdminQueryFunction(){ | |
//VARS | |
global $wpdb; | |
//POST | |
$date = $wpdb->escape($_POST['date']); | |
//QUERY SQL | |
$rows = $wpdb->get_results( "SELECT * FROM db_table WHERE date = '$date' "); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment