Skip to content

Instantly share code, notes, and snippets.

const cors = (req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET, PUT, POST, PATCH, DELETE");
res.header("Access-Control-Allow-Headers", "Content-Typer");
next();
}
module.exports = cors;
add_filter( 'wp_mail_content_type','set_content_type' );
function contact_ajax(){
wp_verify_nonce( 'my-special-string', 'security' );
$name = htmlspecialchars(stripslashes(trim($_POST['name'])));
$email = htmlspecialchars(stripslashes(trim($_POST['email'])));
$message = htmlspecialchars(stripslashes(trim($_POST['message'])));
$options = get_option('feedback-page',array());
@mixin respond-to($media) {
@if $media == phone {
@media only screen and (max-width: $small) { @content; }
}
@else if $media == tablet {
@media only screen and (min-width: $small + 1) and (max-width: $large - 1) { @content; }
}
@else if $media == notebook {
@media only screen and (min-width: $large) and (max-width: $slarge - 1) { @content; }
}
@inoirman
inoirman / Preferences.sublime-settings
Created January 16, 2017 12:57
preferences.sublime
{
"auto_complete_commit_on_tab": true,
"auto_indent": true,
"bold_folder_labels": true,
"caret_extra_bottom": 2,
"caret_extra_top": 2,
"caret_extra_width": 1,
"caret_style": "phase",
"color_scheme": "Packages/User/Afterglow (SublimePythonIDE).tmTheme",
"draw_minimap_border": true,
@inoirman
inoirman / wp-breadcrumbs.php
Created October 7, 2016 14:14
Breadcrumbs
function wfs_breadcrumbs() {
/* === ОПЦИИ === */
$text['home'] = 'Главная'; // текст ссылки "Главная"
$text['category'] = 'Архив рубрики "%s"'; // текст для страницы рубрики
$text['search'] = 'Результаты поиска по запросу "%s"'; // текст для страницы с результатами поиска
$text['tag'] = 'Записи с тегом "%s"'; // текст для страницы тега
$text['author'] = 'Статьи автора %s'; // текст для страницы автора
$text['404'] = 'Ошибка 404'; // текст для страницы 404
$text['page'] = 'Страница %s'; // текст 'Страница N'
@inoirman
inoirman / sftp-config.json
Last active July 15, 2018 09:27
Sublime SFTP params
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "ftp",
"save_before_upload": true,
"upload_on_save": true,
@inoirman
inoirman / wp_count_view.php
Created July 13, 2016 17:48
Wordpress count view's functions
// function to display number of posts.
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0";
}
@inoirman
inoirman / excerpt_limit_words.php
Created July 12, 2016 21:23
excerpt limit words
function do_excerpt($post_id, $word_limit = 80) {
$temp = $post;
$post = get_post($post_id);
setup_postdata($post);
$excerpt = get_the_content();
wp_reset_postdata();
$post = $temp;
$words = explode(' ', $excerpt, ($word_limit + 1));
if (count($words) > $word_limit)
array_pop($words);
@inoirman
inoirman / all-rights-reserved.php
Created June 29, 2016 13:08
all-rights-reserved
&copy; <?php echo date('Y'); ?> <?php bloginfo( 'name' ); ?>. All rights reserved.