Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @package Jaya
- */
- /*
- Plugin Name: Jaya PLugin
- Plugin URI: https://fahrulsanjaya.it.student.ac.id/plugin
- Description: Plugin untuk prakikum Aplikasi dan Teknologi Web
- Version: 1.0.0
- Author: Fahrulsanjaya
- Author URI: https://fahrulsanjaya.it.student.ac.id/plugin
- License: GPLv2 or later
- */
- add_filter("the_content", "takeinput"); //
- add_filter("the_content", "contentfilter");
- add_filter("the_content", "tambahinput"); //
- add_action("wp_head", "sendInput"); //
- add_action("wp_head", "nambah_view");
- add_filter("the_content", "tampilkan_jum_view");
- add_filter("the_content", "eventKetik");
- //https://code.jquery.com/jquery-3.4.1.js
- function contentfilter($content)
- {
- $newcontent .= $content;
- $newcontent .= "<hr> ini tambahan contentnya: ";
- $newcontent .= "<script src='https://code.jquery.com/jquery-3.4.1.js' integrity='sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=' crossorigin='anonymous'></script>";
- $newcontent .= "<a href='mailto:paxtanto@gmail.com' title='silahkan isi judul disini'>" . get_the_title() . "</a>";
- return $newcontent;
- }
- function nambah_view()
- {
- if (is_single()) {
- global $post;
- $jumView = get_post_meta($post->ID, "jumView", true);
- if (!isset($jumView) or empty($jumView) or !is_numeric($jumView)) {
- $jumView = 0;
- }
- $new_jumview = $jumView + 1;
- update_post_meta($post->ID, "jumView", $new_jumview);
- return $new_jumview;
- }
- }
- function get_jumlah_view()
- {
- global $post;
- $jumView = get_post_meta($post->ID, "jumView", true);
- if (!isset($jumView) or empty($jumView) or !is_numeric($jumView)) {
- $jumView = 0;
- }
- return $jumView;
- }
- function tampilkan_jum_view($content, $teksintro = "posting ini memiliki jumlah view sebanyak ")
- {
- if (is_single()) {
- $newcontent = $content;
- $jumView = get_jumlah_view();
- $iconurl = plugins_url('img/icon.jpg', __FILE__);
- $teksnya = "<img title='gambar plugin' src='" . $iconurl . "'>";
- $teksnya .= $teksintro . $jumView . " ";
- $newcontent .= $teksnya;
- echo $newcontent;
- }
- }
- //tugasku
- function tambahinput($content)
- {
- $newcontent .= $content;
- $newcontent .= "
- <div id='count'></div>
- <form method='post'>
- <textarea placeholder='masukkan sesuatu' id='komen' name='angka' maxlength='280'> </textarea>
- <br>
- <input type='submit' value='Komen'/>
- </form>";
- return $newcontent;
- }
- function sendInput()
- {
- global $wpdb;
- $wpdb->insert('praktikum', array('inputUser' => $_POST['angka']));
- }
- function takeinput()
- {
- global $wpdb;
- $praktikum = $wpdb->get_results("SELECT * FROM praktikum");
- ?>
- <table>
- <tr>
- <th>id</th>
- <th>Input</th>
- </tr>
- <?php
- foreach ($praktikum as $val) {
- ?>
- <tr>
- <td><?php echo $val->id ?></td>
- <td><?php echo $val->inputUser ?></td>
- </tr>
- <?php
- }
- ?>
- </table>
- <?php
- }
- function eventKetik()
- {
- ?>
- <script>
- $(document).ready(function() {
- var max = 280;
- $("textarea").keyup(function(e) {
- $("#count").text("Sisa Karakter: " + (max - $(this).val().length));
- });
- });
- </script>
- <?php
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement