Skip to content

Instantly share code, notes, and snippets.

View jimmy89Li's full-sized avatar

Li jimmy89Li

View GitHub Profile
@jimmy89Li
jimmy89Li / randomAge.php
Last active September 10, 2015 12:03
Simple PHP code giving random age until you get to 50.
<?php
$age = 0;
$message0 = "At first, ";
$message1 = "you are age ";
$message2 = "After a while: ";
$message3 = "you die!";
echo ($message0);
while($age<50){
@jimmy89Li
jimmy89Li / 3randomlinesx2randomfunctions.php
Created September 11, 2015 11:28
4x Random Lines with 2x Random Functions
<?php
function getClass(){
$class = "Level 1";
$random = rand(0,3);
if($random==0)
{
$class = "Level 2";
}
elseif($random==1)
@jimmy89Li
jimmy89Li / fixed-top-menu.css
Last active September 16, 2015 07:40
CSS code for a menubar displayed always on top of the website page, even after scrolling down.
.menubar{
height:50px;
background-color: teal;
border-bottom: 2px solid black;
position: fixed;
width: inherit;
top: 0;
}
@jimmy89Li
jimmy89Li / get-parent-style-function.php
Last active September 16, 2015 07:36
PHP code inside functions.php to load parent's style.css in a WordPress child theme
<?php
add_action( 'wp_enqueue_scripts', 'parent_style_enqueue' );
function parent_style_enqueue() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
@jimmy89Li
jimmy89Li / favicon-function.php
Last active September 16, 2015 08:13
PHP code inside functions.php to load facivon.ico file as your website favicon
//add a favicon for your WordPress website
function blog_favicon() {
//this will load the favicon from the root directory of your blog
// echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
//this will load the favicon from the root directory of your theme
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/favicon.ico" />' . "\n";
}
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@jimmy89Li
jimmy89Li / footer.php
Created October 4, 2015 21:31
WordPress footer with 3 widget areas
@jimmy89Li
jimmy89Li / PersonalInformationWidget.php
Created October 4, 2015 23:56
Custom Personal Information Widget for Footer
<?php
/*
Plugin Name: Personal Information Widget for Footer
Plugin URI: https://gist.github.com/jimmy89Li
Description: Custom widget for personal information
Author: jimmyLi
Version: 1.0.0
Author URI: https://gist.github.com/jimmy89Li
*/
@jimmy89Li
jimmy89Li / functions.php
Last active December 3, 2015 15:29
WP CSS loaded from frunctions.php
<?php
wp_register_style(
'style',
get_template_directory_uri() . 'style.css',
array( 'theme-style' ),
'1.0',
'screen'
);
@jimmy89Li
jimmy89Li / functions.php
Created December 3, 2015 13:25
Remove WordPress version
<?php
// Remove WordPress version
remove_action('wp_head', 'wp_generator');
?>