Skip to content

Instantly share code, notes, and snippets.

View ideag's full-sized avatar

Arūnas Liuiza ideag

View GitHub Profile
@ideag
ideag / tiny_login.php
Last active November 22, 2022 13:49
WordPress front-end login and registration forms
<?php
/*
Plugin Name: tinyLogin
Plugin URI: http://wp.tribuna.lt/tiny-login
Description: A simple front-end login/registration system. Adds template tags and shortcodes. Shortcodes: [tiny_form_login]/[tiny_form_register]. Template tags: get_tiny_form_login()/get_tiny_form_register() and the_tiny_form_login()/the_tiny_form_register()
Version: 0.1
Author: Arūnas
Author URI: http://wp.tribuna.lt/
Text Domain: tiny_login
*/
@ideag
ideag / gist:5998414
Created July 15, 2013 08:39
Hosts file for Windows 95
# Copyright (c) 1994 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows 95
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
@ideag
ideag / psv.php
Last active January 1, 2016 14:29
post-section-votes bugfix
<?php
/* Register styles and scripts */
function post_section_voting_scripts() {
wp_register_style('post_section_voting_style', plugins_url('style.css',__FILE__ ));
wp_enqueue_style('post_section_voting_style');
wp_register_script( 'post_section_voting_script', plugins_url('voting_script.js',__FILE__ ),array('jquery'));
wp_enqueue_script('post_section_voting_script');
wp_localize_script( 'post_section_voting_script', 'PsvAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php')));
}
@ideag
ideag / functions.php
Last active August 29, 2015 13:56
Hide recent posts in wordpress
<?php
add_filter( 'pre_get_posts', 'skaitykit_oldie');
function skaitykit_oldie($query) {
if (! is_admin() && $query->is_main_query()) {
if (!current_user_can('read_premium'))
$query->set('date_query',array(array('before'=>'-24 hour')));
}
return $query;
}
@ideag
ideag / functions.php
Created April 4, 2014 10:07
require visitors to login on WordPress site
<?php
if (!is_user_logged_in()) {
wp_redirect(wp_login_url());
exit;
}
@ideag
ideag / template.php
Last active August 29, 2015 13:59
Display WordPress attachments (images) with img tags only
<?php
$images =& get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
if ( empty($images) ) {
// no attachments here
} else {
@ideag
ideag / gist:11168061
Created April 22, 2014 07:07
CPT archive links in WP menu
<?php
add_action( 'admin_head-nav-menus.php', 'inject_cpt_archives_menu_meta_box');
function inject_cpt_archives_menu_meta_box( $object ) {
add_meta_box( 'add-cpt', __( 'CPT Archives' ), 'wp_nav_menu_cpt_archives_meta_box', 'nav-menus', 'side', 'default' );
return $object; /* pass */
}
/* render custom post type archives meta box */
function wp_nav_menu_cpt_archives_meta_box() {
@ideag
ideag / gist:4eb400ab9803c0bd0766
Created June 24, 2014 15:31
Extract color scheme
var c = [];
jQuery('.colors span').each(function(){
c[c.length] = jQuery(this).attr('title');
});
console.log(c);
add_filter('the_title','arunas_switch_title');
function arunas_switch_title($title) {
if (!is_admin() && $title == '[Dynamic title]') {
if (is_user_logged_in()) {
$title = __('My Account','themename');
} else {
$title = __('Login','themename');
}
}
return $title;
if (is_user_logged_in()) {
wp_nav_menu( array( 'theme_location' => 'primary-loggedin' ) );
} else {
wp_nav_menu( array( 'theme_location' => 'primary' ) );
}