public static function editItem() { $model = new \Testimonials\Models\TestimonialModel(); if (!empty($_POST)) { $model->updateItem($_POST); } if (isset($_GET['action'])) { //If action is set delete the testimonial and redirect to the main page if ($_GET['action'] == 'delete') { $model->deleteItem($_GET['id']); self::manageItems(); } } else { if (isset($_GET['id'])) { //Else load the testimonial data $testimonial = $model->getItemById($_GET['id']); include ABSPATH . 'wp-content/plugins/wordpress-testimonials/views/edit_testimonial.php'; } } }
/** * Create shortcode for testimonial listing */ function list_testimonials($atts) { $model = new \Testimonials\Models\TestimonialModel(); if (!empty($atts)) { $post_id = $atts['id']; } else { $post_id = get_the_ID(); } $testimonials = $model->getItemsForPost($post_id); TestimonialsTemplateHandler::listItems($testimonials); }