Giantpaper.org

Blog

  • Hello Gutenberg

    Hello Gutenberg

    Peppa won’t be told how to use two beds!

    And here, testing out Gutenberg for the first time in case this is something I might want to use in the future when it gets released to the wild!

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ultricies turpis eget iaculis molestie. In eget purus ut arcu eleifend iaculis. Maecenas ante risus, molestie quis viverra non, vehicula tempor augue.

    Sed faucibus sed nunc at blandit. Suspendisse commodo odio in urna vulputate hendrerit. Integer blandit aliquet neque, ac viverra tellus. Vivamus in nisl porttitor metus ultrices lacinia.

    And another paragraph of text riiiight here.

    Vivamus eget viverra augue, iaculis blandit magna. In hac habitasse platea dictumst. Nullam eu dui nunc. Vestibulum at est pretium, dapibus nunc eget, maximus massa. In luctus felis sed semper pharetra. Nam efficitur at arcu id dapibus. In hac habitasse platea dictumst. Duis vitae augue massa. Vestibulum commodo velit a auctor varius. Morbi pharetra eu arcu ac mattis. Nam nec risus a lacus ultricies efficitur eget sit amet risus. Nullam sollicitudin dui quis risus mollis, eget mollis enim blandit.

    The Lipsum
    <h1>Whoa! This is some highlighted code!</h1>
    <!-- comment--yes -->
  • Animated Hamburger Menu Icon

    Animated Hamburger Menu Icon

    This icon animates into an x (for a close button) when clicked on, using only CSS (errr…well, SCSS compiled into CSS).

  • Dear everyone, please stop asking me to link to your content

    Dear everyone, please stop asking me to link to your content

    I’m not sure how common this is, and I don’t get this myself too often. But I got at least two emails from other sites and companies if I would link to their content.

    Giantpaper.org is just a personal blog, which exists for my own pleasure and to sharpen my skillz0r. I don’t do it for internet popularity or to make money. I post whatever I want, even if no one cares about it. Half of the time, the site experiences slows (due to me experimenting on it) and errors (ditto), so I most certainly don’t expect people to stick around. I don’t really have a loyal readership or anything like that. I don’t have an entire team helping me manage this site. It’s just me, some nerd with a computer who decided to run a personal blog.

    If I link to something somewhere on this site, it’ll be because I tried it out either on my own or through work and liked it enough to link to it on there. I’m not to put something on that page and tell people I like it if I never even tried it!!!! Simple. C:

    (Second of all, I have no idea how these people are getting my email address. I used to have a contact page with a form and link to my email, but not anymore.)

    About Plugin Credit…

    Edited to add: Some WP plugins (not mentioning any names), if you express interest in linking to their site on your WP blog, they’ll choose how you get to link to them. NO NO NO, my site, I choose how I get to link to you. It was fairly good plugin, I wouldn’t link to them with negative feedback. (I ended up switching it out for another plugin that seems to do a better job, based on my web server.)

  • Demonstrating GeSHi using GeSHi

    Demonstrating GeSHi using GeSHi

    How I added GeSHi to GPORG. Here I will demonstrate using GeSHi (for prettification purposes).

    <?php
    
    function sexy_code ($a, $content) {
    	$attr = shortcode_atts(array(				// sets the defaults for each attribute so we don't run into errors if we're missing any
    		'lang' => 'html',						// default language is HTML
    		'start' => '1'							// which line num to start on
    	), $a);
    	
    	$content = strip_tags($content);			// remove wpautop() formatting from the snippet
    	
    	$array = explode("\n", $content);
    	$tab = null;
    	$t = 0;
    	$pos = null;
    	
    	foreach ($array as $i => $line) {
    		$code = $line;
    		if (strpos($line, '//') !== false) {
    			list($code, $comment) = explode('//', $line);
    		}
    			if (preg_match("#\{|\($#", $code)) {
    			$pos = 'after';
    			$t++;
    		}
    		elseif (preg_match("#\}|\)$#", $code)) {
    			$pos = 'before';
    			$t--;
    		}
    		$tab = ($t > 0 ? implode("", array_fill(0, $t, "    ")) : null);
    		$line = ($pos == 'before' ? $tab : null).$line.( $pos == 'after' ? $tab : null);
    		$array[$i] = $line;
    	}
    	$content = implode("\n", $array);
    	$content = preg_replace("#(    +)(\n)#", "\\2\\1", $content);
    	$content = str_replace("    }", "}", $content);
    	
    	$content = preg_replace("#\&amp;([a-z0-9]+);#", "&\\1;", $content);
    	$content = str_replace('&lt;', '<', $content);
    	$content = str_replace('&gt;', '>', $content);
    	
    	//echo secret_output ('test HTML',$content);
    	
    	$lang = $attr['lang'];
    	$geshi = new GeSHi($content, $lang);
    	$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);	// type of line numbers
    	$geshi->enable_classes();					// turns on classes so we can prettify thru CSS
    		if ($attr['start'] != 1)				// if you specifically mentioned which line number you want the snippet to start on
    	$geshi->start_line_numbers_at($attr['start']);		// ...set it here
    	
    	$r = $geshi->parse_code();
    	
    	$r = str_replace('<ol>', '<ol class="no-custom">', $r);
    	$r = preg_replace("#^<pre>#", '<pre class="wp-block-code">', $r);
    	
    	return $r;
    }
    add_shortcode( 'code', 'sexy_code' );			// shortcodify!
    
    ?>

    (See the doc on WordPress’s shortcode API if you haven’t already.)

    To use in a post…

    [code lang="php" start="2"]<?php echo $fun; ?>[/code]

    …will get you…

    <?php echo $fun; ?>