/**
  * Short Description. (use period)
  *
  * Long Description.
  *
  * @since    1.0.0
  */
 public static function activate()
 {
     require_once 'My-slider-table.php';
     require_once 'My-images-table.php';
     $slider = new My_slider();
     $slider->create();
     $images = new My_images();
     $images->create();
 }
Example #2
0
<?php

require_once '../../../wp-config.php';
require_once 'includes/My-slider-table.php';
$admin = new My_slider();
if (empty($_GET['act'])) {
    die('display');
}
switch ($_GET['act']) {
    case 'add':
        $result = $admin->add(array('name' => $_POST['sl_name'], 'status' => $_POST['sl_status']));
        if ($result) {
            $result = 'save success';
        }
        header('location:' . $_SERVER['HTTP_REFERER'] . '&save=' . $result);
        break;
    case 'edit':
        if (isset($_GET['id']) && !empty($_GET['id'])) {
            $result = $admin->edit($_GET['id'], array('name' => $_POST['sl_name'], 'status' => $_POST['sl_status']));
            if ($result) {
                header('location:' . admin_url('admin.php?page=my_slider'));
            } else {
                header('location:' . $_SERVER['HTTP_REFERER'] . '&error');
            }
        }
        break;
    case 'del':
        if (!empty($_GET['id'])) {
            $admin->delete($_GET['id']);
            header('location:' . $_SERVER['HTTP_REFERER']);
        }
<?php

if (!isset($_GET['id'])) {
    die('no found slider');
}
if (isset($_GET['error'])) {
    echo "<p class='notify'>can not edit</p>";
}
require_once PLUGIN_PATH . 'includes/My-slider-table.php';
$obj = new My_slider();
$slider = $obj->find($_GET['id']);
$slider = $slider[0];
//var_dump($slider);
?>
<h2>Edit slider:</h2>
<div class="my-block">
	<form action="<?php 
echo PLUGIN_URL . 'save-slider.php?act=edit&id=' . $slider['id'];
?>
" method="post" accept-charset="utf-8">
		<table class="form-table">
			<tbody>
 				<tr>
					<td><label for="sl-name">name :</label></td>
					<td> 
						<input type="text" name="sl_name" id="sl-name" class="regular-text" value="<?php 
echo $slider['name'];
?>
" >
					</td>
				</tr>
<?php

if (isset($_GET['result'])) {
    echo "<p>" . $_GET['result'] . "</p>";
}
if (!isset($_GET['id']) || empty($_GET['id'])) {
    echo 'not found';
    return;
}
require_once PLUGIN_PATH . 'includes/My-slider-table.php';
$sl_obj = new My_slider();
$slider = $sl_obj->select($_GET['id'], 'name');
$slider = $slider[0];
?>
<h2>Add image to "<?php 
echo $slider['name'];
?>
"</h2>
<?php 
require_once PLUGIN_PATH . 'includes/My-images-table.php';
$images = new My_images();
$img_list = $images->find_images_slider($_GET['id']);
//var_dump($img_list);
?>
<div class="my-block">
	 <table class="wp-list-table widefat fixed striped">
	 	<caption><h3>List images.</h3></caption>
	 	<thead>
	 		<tr>
	 			<th>Id</th>
	 			<th>image</th>
 * @link       http://example.com
 * @since      1.0.0
 *
 * @package    Plugin_Name
 * @subpackage Plugin_Name/admin/partials
 */
?>

<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<?php 
if (isset($_GET['save'])) {
    echo "<p class='notify'>" . $_GET['save'] . "</p>";
    //echo PLUGIN_PATH;
}
require_once PLUGIN_PATH . 'includes/My-slider-table.php';
$slider = new My_slider();
?>
<h2>Setting images in slider</h2>
<div class="my-block">
	<?php 
$res = $slider->find_all();
//var_dump($res);
?>
	 <table class="wp-list-table widefat fixed striped">
	 	<caption><h3>List sliders.</h3></caption>
	 	<thead>
	 		<tr>
	 			<th>Id</th>
	 			<th>Name</th>
	 			<th>Status</th>
	 			<th>Action</th>