Skip to content

Instantly share code, notes, and snippets.

View siriokun's full-sized avatar

Rio Purnomo siriokun

View GitHub Profile
@siriokun
siriokun / wp-update_tagline.php
Created June 11, 2012 13:16
Check if WordPress site description is default, show notice to update
<?php
/**
* Checks to see if your tagline is set to the default and shows an admin notice to update it
* Throw this in function.php for your theme
*/
if (get_option('blogdescription') == 'Just another WordPress site') { add_action('admin_notices', create_function( '', "echo '<div class=\"error\"><p>".sprintf(__('Please update your <a href="%s">tagline</a>', 'bb'), admin_url('options-general.php'))."</p></div>';" ) ); };
// Different approach
/**
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
<?php
/**
* Modify the "Enter title here" text when adding new CPT, post or page
*
* @access public
* @since 1.0
* @return void
*/
function rc_change_default_title( $title ){
@siriokun
siriokun / wp-config.php
Created January 7, 2013 10:32 — forked from anonymous/wp-config.php
This in wp-config to be able to run the blog both locally and deployed on AppFog
$services = getenv("VCAP_SERVICES");
if ( $services != null){
$services_json = json_decode($services,true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
define('DB_NAME', $mysql_config["name"]);
define('DB_USER', $mysql_config["user"]);
define('DB_PASSWORD', $mysql_config["password"]);
define('DB_HOST', $mysql_config["hostname"]);
define('DB_PORT', $mysql_config["port"]);
<?php
while ( have_posts() ) : the_post();
if ( have_comments() )
{
echo '<ol class="comment-list">';
wp_list_comments();
echo '</ol>';
}
endwhile;
?>
@siriokun
siriokun / animation.css
Created March 1, 2013 10:47
Better CSS Animation with Translate3D to trigger hardware CPU acceleration
.target {
height: 0;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
@siriokun
siriokun / Responsive Image Viewport.html
Last active December 20, 2015 06:38
Load images when visible in viewport.
<div data-defer="view"
data-img-src="//path/to/image.jpg"
data-img-alt="imgtitle"
data-img-width="150">
Image text placeholder
</div>
@siriokun
siriokun / fixed-nav.js
Created July 26, 2013 08:24
Fixed Navigation on oscon.com/oscon2013
var headerHeight;
// is navigation visible? See #en_header with height 150px, so when scroll down more than 150px, we make the #nav_borders position fixed.
$(function() {
headerHeight = $('#en_header').height() + 1;
$(window).on('scroll', fixNav);
});
// if not visible, then make it fixed
function fixNav() {
if ($(window).scrollTop() >= headerHeight) {
@siriokun
siriokun / spin.css
Created July 31, 2013 10:38
Spin Animation in CSS3
.gear {
position: absolute;
width: 60px;
height: 60px;
background: url("/images/gear.png") no-repeat;
background-size: 100% 100%;
z-index: 2;
-webkit-animation-name: gearSpin;
-moz-animation-name: gearSpin;
-ms-animation-name: gearSpin;
/**
* Toggle
*/
body{
background: #111;
}
.container{
background: #fff;
margin:0 auto;