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
function save_data_to_file(){ | |
// output headers so that the file is downloaded rather than displayed | |
header('Content-Type: text/csv; charset=utf-8'); | |
header('Content-Disposition: attachment; filename=data.csv'); | |
$output = fopen('php://output', 'w'); | |
$data = array( |
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
<?php | |
$key_oer = '???'; // тут указываем ключ API | |
$url_api_oer = 'https://openexchangerates.org/api/latest.json?app_id=' . $key_oer; | |
$response = wp_remote_get($url_api_oer); | |
$data_exchange = json_decode( wp_remote_retrieve_body( $response ) ); | |
var_dump($data_exchange); // вернет объект с данными, которые можно далее использовать в коде |
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> | |
//контроль цели отправки формы | |
(function ($) { | |
$('.menu-item-34927 a').click(function(){ | |
yaCounter27903495.reachGoal('help_click'); | |
}); | |
}(jQuery)); | |
</script> | |
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
//пример для плагина | |
function add_script_in_plugin_1(){ | |
wp_enqueue_script('custom-script', plugins_url( '/js/newscript.js', __FILE__ ), array('jquery')); | |
wp_enqueue_style( 'style-name', plugins_url( '/css/custom.css', __FILE__ ) ); | |
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
//Добавляем поля на форму категорий продуктов | |
function mss_uuid_product_cat_form($term){ | |
wp_nonce_field( basename( __FILE__ ), 'mss_uuid_product_cat_nonce' ); | |
?> | |
<div class="form-field mss_uuid_product_cat"> | |
<label for="mss_uuid_product_cat">uuid МойСклад</label><br/> | |
<input type="text" name="mss_uuid_product_cat" id="mss_uuid_product_cat" value="<?php echo get_term_meta( $term_id, 'uuid_product_category_mss', true ); ?>" /> | |
<p><small>Это поле идентификатор для синхронизации с МойСклад</small></p> |
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
//получает term_id категории продуктов WC по значению метаполя | |
//Возвращает значение term_id для uuid | |
// $term_id = get_term_id_by_uuid_mss($uuid); | |
function get_term_id_by_uuid_mss($uuid){ | |
global $wpdb; | |
$data = $wpdb->get_results("SELECT term_id FROM $wpdb->termmeta WHERE meta_value = '" . $uuid . "' LIMIT 1"); | |
$data = $data[0]->term_id; | |
return $data; | |
} |
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
//Сохранение данных поля uuid для категории продуктов | |
function mss_uuid_product_cat_form_edit($term_id){ | |
if ( ! isset( $_POST['mss_uuid_product_cat'] ) || ! wp_verify_nonce( $_POST['mss_uuid_product_cat_nonce'], basename( __FILE__ ) ) ) | |
return; | |
$mss_uuid_product_cat = $_POST['mss_uuid_product_cat']; | |
if(empty($mss_uuid_product_cat)) { | |
delete_term_meta( $term_id, 'uuid_product_category_mss' ); | |
} else { | |
update_term_meta( $term_id, 'uuid_product_category_mss', $mss_uuid_product_cat ); |
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
<?php | |
//Проверяем наличие комментария о нарушении срока | |
$cases = get_posts(array( | |
'post_type' => 'cases', | |
'numberposts' => 333, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'functions', | |
'field' => 'slug', |
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
<?php | |
/* | |
Plugin Name: Заголовок - автонаписание | |
Description: Скрывает поле написания заголовка на странице объектов и формирует его на базе данных объекта | |
Version: 1 | |
*/ | |
/** | |
* | |
*/ | |
class TitleAutomatS{ |
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
//Проверяем наличие комментария о нарушении срока | |
$items = get_posts(array( | |
'post_type' => 'post', | |
'numberposts' => 500, | |
)); | |
//Создаем массив и помещаем туда данные комментов | |
$data = array(); | |
foreach($items as $post): setup_postdata( $post ); | |