This file contains hidden or 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
/** | |
* Utilize WordPress' media library. Easy select/upload files for your plugin/theme admin page. | |
* It uses build-in jQuery 1.4.1 | |
* Tested with WordPress 5.2.4 | |
*/ | |
$('.my-upload-button').click(function(e) { | |
e.preventDefault(); | |
// setup our media library frame |
This file contains hidden or 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
// jQuery UI is required | |
<form action="" class="form-filters"> | |
<label for="from">From</label> | |
<input type="text" id="from" name="from"> | |
<label for="to">to</label> | |
<input type="text" id="to" name="to"> | |
<script> | |
$(function() { | |
var dateFrom = new Date(); |
This file contains hidden or 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
// SweetAlert.js is required | |
$('.trigger').click(function(e) { | |
e.preventDefault(); | |
swal({ | |
title: "Are you sure?", | |
text: "If you're sure click YES", | |
icon: "warning", | |
buttons: true, | |
dangerMode: true |
This file contains hidden or 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
// jQuery UI is required | |
$("#target_input").autocomplete({ | |
minLength: 2, | |
source: "ajax/autocomplete.php", // expects JSON | |
select: function(event, ui) { | |
$("#target_input").val(ui.item.label); // display the selected text | |
$("#target_input-id").val(ui.item.value); // save selected id to hidden input | |
event.preventDefault(); // prevent autocomplete from updating the textbox | |
return false; // prevent from inserting id into the input instead of label |
This file contains hidden or 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
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> | |
<div id="map" style="width: 100%; height: 600px"></div> | |
<script type="text/javascript"> | |
var elementExists = document.getElementById("map"); | |
if (elementExists != null) { | |
ymaps.ready(init); | |
var myMap, | |
myPlacemark; |
This file contains hidden or 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
// In order to use an external css file in the plugin's admin panel: | |
// 1. Copy following code to the main php file of your plugin (plugins/your_plugin/your_plugin_name.php) | |
// 2. Create admin.css (or adjust the name below) | |
function plugin_name_admin_css() | |
{ | |
$siteurl = get_option('siteurl'); | |
$url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/admin.css'; | |
echo "<link rel='stylesheet' type='text/css' href='$url' />\n"; | |
} |