/** * 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(); }
<?php require_once PLUGIN_PATH . 'includes/My-images-table.php'; $obj = new My_images(); $images = $obj->find_images_slider($arg); //var_dump($images); ?> <div id="car-slider"> <div class='car-images'> <?php foreach ($images as $img) { ?> <div class='car-img'> <img src="<?php echo $img['src']; ?> "> <div class="car-content"> <a href="<?php echo $img['href']; ?> "><?php echo $img['title']; ?> </a> </div> </div> <?php } ?>
<?php require_once '../../../wp-config.php'; require_once 'includes/My-images-table.php'; $my_images = new My_images(); if (empty($_GET['act'])) { die('display'); } switch ($_GET['act']) { case 'add': $result = $my_images->add(array('title' => $_POST['img_title'], 'description' => $_POST['img_des'], 'href' => $_POST['img_href'], 'src' => $_POST['img_src'], 'status' => $_POST['img_status'], 'slider_id' => $_POST['img_slider_id'])); if ($result) { $result = 'save success'; } header('location:' . $_SERVER['HTTP_REFERER'] . '&save=' . $result); break; case 'edit': if (!isset($_GET['id']) || empty($_GET['id'])) { die('error'); } $result = $my_images->edit($_GET['id'], array('title' => $_POST['img_title'], 'description' => $_POST['img_des'], 'href' => $_POST['img_href'], 'src' => $_POST['img_src'], 'status' => $_POST['img_status'], 'slider_id' => $_POST['img_slider_id'])); if ($result) { header('location:' . admin_url('admin.php?page=edit_image&id=' . $_POST['img_slider_id'])); } else { header('location:' . $_SERVER['HTTP_REFERER'] . '&error=true'); } break; case 'del': if (!empty($_GET['id'])) { $my_images->delete($_GET['id']); header('location:' . $_SERVER['HTTP_REFERER']);
<?php if (!isset($_GET['id'])) { die('no found image'); } if (isset($_GET['error']) && $_GET['error'] == 'true') { echo "edit fail"; } if (isset($_GET['error']) && $_GET['error'] == 'false') { echo "edit success"; } require_once PLUGIN_PATH . 'includes/My-images-table.php'; $obj = new My_images(); $image = $obj->find($_GET['id']); $image = $image[0]; //var_dump($image); ?> <h2>Edit image :</h2> <div class="my-block"> <form action="<?php echo PLUGIN_URL . 'my-images.php?act=edit&id=' . $image['id']; ?> " method="post" accept-charset="utf-8"> <table class="form-table"> <tbody> <tr> <td><label for="img-title">title :</label></td> <td> <input type="text" name="img_title" id="img-title" class="regular-text" value="<?php echo $image['title']; ?>
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> <th>Title</th> <th>description</th> <th>create</th> <th>status</th> <th>action</th>