Skip to content

Instantly share code, notes, and snippets.

View ideag's full-sized avatar

Arūnas Liuiza ideag

View GitHub Profile
add_filter('img_caption_shortcode', 'tiny_img_caption_shortcode_filter',10,3);
function tiny_img_caption_shortcode_filter($val, $attr, $content = null) {
extract(shortcode_atts(array(
'id' => '',
'align' => '',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) )
add_filter( 'image_send_to_editor', 'tiny_force_caption', 100 );
function tiny_force_caption( $html ) {
$a = strpos($html, 'caption');
if ($a!=1) {
preg_match('/(alignnone|alignleft|alignright|aligncenter)/', $html,$c);
preg_match('/width="(\d*)"/', $html,$w);
preg_match('/alt="([^"]*)"/', $html,$m);
preg_match('/wp-image-(\d*)"/', $html,$n);
if (!isset($n[1])) $n[1] = '0';
$html = '[caption id="attachment_'.$n[1].'" align="'.($c?$c[1]:'alignnone').'" width="'.$w[1].'"]'.$html." © ".get_bloginfo('title')."[/caption]";
@ideag
ideag / functions.php
Last active February 23, 2022 10:10
A very simple implementation of WordPress front-end login form. Just put this to your theme's functions.php file. Usage: use [tiny_login] shortcode or get_tiny_login_form()/the_tiny_login_form() template tags Arguments: one (optional) argument 'redirect': pass url where to redirect after successful login (default: false); Localization: replace '…
<?php
// a simple WordPress frontend login implementation
// written by Arūnas Liuiza | tinyStudio | wp.tribuna.lt
// Usage: use [tiny_login] shortcode or get_tiny_login_form()/the_tiny_login_form() template tags
// Arguments: one (optional) argument 'redirect': pass url where to redirect after successful login (default: false);
// Localization: replace 'theme' with your text domain string.
// login action hook - catches form submission and acts accordingly
add_action('init','tiny_login');
@ideag
ideag / tiny-change.php
Last active December 15, 2015 00:38 — forked from anonymous/tiny-change
<?php
/*
Plugin Name: tinyChangeAuthor
Plugin URI: https://gist.github.com/ideag/5174195/
Description: Change post author on save
Author: @IdeaG (tinyStudio)
Version: 0.1
Author URI: http://wp.tribuna.lt
*/
@ideag
ideag / proxy.php
Created March 16, 2013 09:07
WordPress mu-plugins proxy file - loads selected plugins from subdirectories.
<?php
require WPMU_PLUGIN_DIR.'/tiny_tribuna/tiny_tribuna.php';
require WPMU_PLUGIN_DIR.'/akismet/akismet.php';
require WPMU_PLUGIN_DIR.'/nginx-compatibility/nginx-compatibility.php';
?>
@ideag
ideag / functions.php
Created March 19, 2013 14:45
Removing default widgets from WordPress
<?php
add_action('widgets_init', 'tiny_unregister_default_widgets', 11);
function tiny_unregister_default_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Search');
unregister_widget('WP_Widget_Text');
<?php
function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) {
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
if ( false !== $plugin_rel_path ) {
$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
} else if ( false !== $abs_rel_path ) {
_deprecated_argument( __FUNCTION__, '2.7' );
$path = ABSPATH . trim( $abs_rel_path, '/' );
} else {
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
@ideag
ideag / functions.php
Last active October 1, 2019 21:17
A very basic framework for creating front-end forms for WordPress.
<?php
// a framework to handle frontend form submission
// written by Arūnas Liuiza | tinyStudio | wp.tribuna.lt
// Usage: use [tiny_form1] shortcode or get_tiny_form1()/the_tiny_form1() template tags
// Arguments: one (optional) argument 'redirect': pass url where to redirect after successful login (default: false);
// Localization: replace 'theme' with your text domain string.
// ======= FORM 1 =====>
@ideag
ideag / functions.php
Last active July 22, 2021 11:43
Wordpress frontend file uploading
<?php
// simple frontend file upload
// written by Arūnas Liuiza | tinyStudio | wp.tribuna.lt
// Usage: use [tiny_upload] shortcode or get_tiny_upload()/the_tiny_upload() template tags
// Localization: replace 'theme' with your text domain string.
// ======= UPLOAD FORM =====>
// return form #1