Skip to content

Instantly share code, notes, and snippets.

/**
* Recent_Posts widget w/ category exclude class
* This allows specific Category IDs to be removed from the Sidebar Recent Posts list
* Copypasted from http://pastebin.com/jxDnqPqR
*/
class WP_Widget_Recent_Posts_Exclude extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
parent::__construct('recent-posts', __('Recent Posts with Exclude'), $widget_ops);
server {
..... bla bla bla .....
# Редиректы
rewrite "^/page/([0-9]+)(/?)$" /index.php?cstart=$1 last;
# Сам пост
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6&seourl=$6 last;
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5&seourl=$5 last;
@donchenko
donchenko / display_cats_in_ul
Created May 11, 2016 13:28
Делаем вывод рубрик которые дочерние от 76й рубрики списком для виджета.
<?php
if( $terms = get_terms( 'category', array(
'orderby' => 'name',
'hide_empty' => 0,
'parent' => 76,
) ) ) :
echo '<ul class="sidebar_countries\">';
foreach ($terms as $term) :
@donchenko
donchenko / days_in_month_calc.js
Created October 7, 2016 05:55
Функция JS которая считает количество дней по номеру месяца.
function f(x) { return 28 + (x + Math.floor(x/8)) % 2 + 2 % x + 2 * Math.floor(1/x); }
@donchenko
donchenko / functions.php
Created November 9, 2016 11:51
Wordpress custom Walker for Bootstraping menu and wp_list_pages
// Add custom walker to functions.php
class BS_Page_Walker extends Walker_Page {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class='dropdown-menu' role='menu'>\n";
}
public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
@donchenko
donchenko / CreateWordpressUser.php
Last active March 21, 2019 08:38 — forked from jawinn/CreateWordpressUser.php
Create WordPress Admin User from PHP
<?php
// ДОБАВЛЯЕМ НОВОГО АДМИНА НА САЙТ WORDPRESS
// ----------------------------------
// Загрузите этот файл в папку с сайтом и откройте в браузере.
// Удалите этот файл когда закончите.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// ----------------------------------------------------
@donchenko
donchenko / fix-wordpress-permissions.sh
Created October 29, 2018 14:14 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@donchenko
donchenko / remove_checkout_fields.php
Created February 6, 2019 18:21 — forked from cryptexvinci/remove_checkout_fields.php
Remove fields from WooCommerce checkout page.
add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields' );
function custom_remove_woo_checkout_fields( $fields ) {
// remove billing fields
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
@donchenko
donchenko / pulse-gym.js
Created June 21, 2019 09:58
pulse-gym.at.ua редиректы
<script type='text/javascript'>
if (window.location.href== "http://pulse-gym.at.ua/") {
window.location.href = 'https://pulse-gym.com.ua/';
}
</script>
<script type='text/javascript'>
if (window.location.href== "http://pulse-gym.at.ua/publ/1/vidy_sportivnogo_pitanija/2-1-0-3") {
window.location.href = 'https://pulse-gym.com.ua/vidy-sportivnogo-pitaniya/';
}
</script>