Skip to content

Instantly share code, notes, and snippets.

@egmalt
egmalt / gist:0e1598fce25433d80be0cf138f80720f
Created December 8, 2020 07:04
Get access token — request and response (real)
// request
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.timewave.nu/v3/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
@egmalt
egmalt / gist:46541ab47f6bde1846b393a81be0f2d1
Last active December 8, 2020 07:09
Get access token on timewave api – curl request and response (example data)
// request
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.timewave.nu/v3/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
/**
* Генерирует webp копии изображений сразу после загрузки изображения в медиабиблиотеку
*
* - новые файлы сохраняет с именем name.ext.webp, например, thumb.jpg.webp
*/
function gt_webp_generation($metadata) {
$uploads = wp_upload_dir(); // получает папку для загрузки медиафайлов
$file = $uploads['basedir'] . '/' . $metadata['file']; // получает исходный файл
$ext = wp_check_filetype($file); // получает расширение файла
function openModal(modalId){
$('.modal-wrapper').children().unwrap();
if(!$(modalId).length){
alert('Ошибка вызова модального окна');
return false;
}
$(modalId).wrap('<div class="modal-wrapper" style="display:none" />');
$('.modal-wrapper').fadeIn(400);
if($('body').height() > $(window).height()){
// функция circle выполняет до тех пор пока количестве элементов в списке @posts меньше, чем @index
// @index = 1, если не указано иное
.circle(@index: 1) when (@index =< length(@posts)){
// задаем переменную @post - достаем из списка @posts элемент с порядковым номером @index (который мы сейчас проходим)
@post: extract(@posts, @index);
// выводим нужные css свойства используя переменную @post
.post-type-@{post}{
<!-- Создание формы -->
<div class="pay__wrap">
<form action="<?php echo bloginfo("template_directory") ?>/includes/etc/pay.php" method="post">
<input type="text" name="name" placeholder="Ваше имя" required="">
<input type="text" name="sum" placeholder="Сумма к оплате" required="">
<input type="hidden" name="id" value="<?php the_sub_field('pay__id'); ?>">
<input type="submit" class="pay__btn btn" value="<?php the_sub_field('pay__btn'); ?>" >
</form>
</div>
<?php
$message = ' ';
$message .= $_REQUEST;
mail('egmalt@ya.ru', 'Связь есть', $message);
<!-- Шаблон для создания сниппета для sublime text 3
В <tabTrigger> вместо название_сниппета вставьте его сокращенное название, примеры:
- prp - в <?php ?> поле repeater
- ptf - в <?php ?> the_field();
- acft - acf поле text
- lbenefits - layout benefits
- gimg - <img> для темы garnet
В <scope> можно указать расширение документа в котором можно использовать сниппет, например:
<?php
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
// подключение файлов в вордпресс
get_template_part('/includes/GetCourse/autoload');
get_template_part('/includes/GetCourse/core/exceptions/FormatError');
get_template_part('/includes/GetCourse/core/exceptions/ServerError');
get_template_part('/includes/GetCourse/core/exceptions/TokenError');
get_template_part('/includes/GetCourse/core/Config');
get_template_part('/includes/GetCourse/core/Core');