Skip to content

Instantly share code, notes, and snippets.

View SErr0r's full-sized avatar

Gennady Yudenko SErr0r

View GitHub Profile
@SErr0r
SErr0r / function.php
Created June 20, 2016 14:16
Enqueue asset for IE only
<?php
function add_ie_scripts () {
global $is_IE;
if ($is_IE) {
wp_enqueue_script( 'selectivizr', get_template_directory_uri() . '/scripts/libraries/selectivizr-min.js' );
wp_enqueue_script( 'respondJS', get_template_directory_uri() . '/scripts/libraries/respond.min.js' );
}
}
add_action('wp_enqueue_scripts', 'add_ie_scripts', 1);
?>
@SErr0r
SErr0r / wp-config.php
Created June 20, 2016 14:01
Add FTP settings to wp-config
<?php
/**
* FTP Settings
*/
//define('FS_METHOD', 'ftpext');
//define('FTP_BASE', '/path/to/wordpress/');
//define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/');
//define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/');
//define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub');
//define('FTP_PRIKEY', '/home/username/.ssh/id_rsa');
@SErr0r
SErr0r / function.php
Created June 20, 2016 13:58
Add active class to menu items of current taxonomy
<?php
function current_taxonomy_item($classes, $item) {
global $naventries;
$naventries[$item->ID] = $item;
if($item->type == 'taxonomy') {
global $post;
$terms = get_the_terms($post->ID, $item->object);
$currentTerms = array();
foreach($terms as $term) {
$currentTerms[] = $term->slug;
@SErr0r
SErr0r / index.html
Created June 20, 2016 13:55
Social sharing URL schemes
# Email
mailto:{email_address}?subject={subject}&body=<?php echo urlencode(get_the_title()); ?>%0A<?php the_permalink(); ?>
# Google+
https://plus.google.com/share?url=<?php the_permalink(); ?>
# Twitter
https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>&via={username}&text=<?php echo urlencode(get_the_title()); ?>&in_reply_to={username}&hashtags={hash,tags}&related={usernames,usernames}
# Facebook
@SErr0r
SErr0r / function.php
Created June 20, 2016 12:08
Override WordPress core template with custom one
<?php
function custom_search_template($template) {
global $wp_query;
$post_type = get_query_var('post_type');
if (!$wp_query->is_admin
&& $wp_query->is_search
&& isset($post_type)
&& $post_type === 'faq') {
@SErr0r
SErr0r / .htaccess
Created June 20, 2016 11:59
Mapping multiple domains to different folders with .htaccess
# Source: https://wordpress.org/support/topic/success-mapping-multiple-domains-to-different-folders-with-htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# ---------------------------------------
# BEGIN Domain to folder mapping
# pointing domain_1.com to folder_1
@SErr0r
SErr0r / login.php
Created January 18, 2016 23:50
A login page template for WordPress.
<?php
/*
Template Name: Login/Logout Page
*/
//* Remove our default page content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
//* Add custom login form to our page content
add_action( 'genesis_entry_content', 'ck_do_login_form' );
@SErr0r
SErr0r / index.html
Created December 24, 2015 16:02
Scroll Up
<div id="scrollUp"><img src="http://s014.radikal.ru/i328/1512/c1/1c1585b88ebc.png" alt="Up" title="Scroll window up"></div>
@SErr0r
SErr0r / index.php
Created November 13, 2015 20:48
Show user information (IP address, Browser (User Agent), Referrer)
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$referrer = $_SERVER['HTTP_REFERER'];
if ($referred == "") {
$referrer = "This page was accessed directly";
}
echo "<b>Visitor IP address:</b><br/>" . $ip . "<br/>";
echo "<b>Browser (User Agent) Info:</b><br/>" . $browser . "<br/>";
echo "<b>Referrer:</b><br/>" . $referrer . "<br/>";
@SErr0r
SErr0r / author.php
Created November 13, 2015 01:31
Расширенная регистрация и профиль пользователя
<? if ( $curauth->user_country ): ?>
<div class="user-format">Страна: <span class="color-user"><?php echo $curauth->user_country; ?></span></div>
<? endif?>
<? if ( $curauth->user_city ): ?>
<div class="user-format">Город: <span class="color-user"><?php echo $curauth->user_city; ?></span></div>
<? endif?>