This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* -------------------------------------------------------------------------------------------------------------------------------- | |
* CUSTOM META BOXES FOR EASIER CONTENT EDITING | |
* -------------------------------------------------------------------------------------------------------------------------------- | |
*/ | |
add_action( 'add_meta_boxes', 'wp_meta_boxes_add' ); | |
function wp_meta_boxes_add(){ | |
// Custom Meta Boxes for post-type post | |
add_meta_box( 'binus-meta-boxes', 'BINUS Meta Information', 'wp_meta_boxes', 'post', 'normal', 'high' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_touch_device() { | |
return 'ontouchstart' in window // works on most browsers | |
|| 'onmsgesturechange' in window; // works on ie10 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get current URL | |
* | |
* @return string | |
*/ | |
function current_url(){ | |
global $wp; | |
$current_url = trailingslashit( home_url( $wp->request ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Unhook all action with some exception on wp_head and wp_footer | |
*/ | |
function fr_unhook_wp_head_footer(){ | |
global $wp_filter; // Where all the hooks and their actions are stored | |
// Actions that should not be removed from the wp_head hook | |
$wp_head_whitelist = array( 'wp_enqueue_scripts', 'wp_print_styles', 'wp_print_head_scripts' ); | |
// Unhook actions from wp_head |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removing / Dequeueing All Stylesheets And Scripts on Particular Page | |
* | |
* @return void | |
*/ | |
function fr_dequeue_enqueue_styles_scripts(){ | |
global $wp_styles, $wp_scripts; | |
// Note: You may want to add some conditional tag so this will only happen on particular page | |
// Let's say you want to do this on contact page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php echo htmlspecialchars( file_get_contents( $url_to_be_copy_pasted ) ); ?> | |
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Route single page to custom template | |
* | |
* @return string of path | |
*/ | |
function fr_route_template( $single_template ){ | |
// Put any conditional tag here. This one assumes you want to serve custom template for CPT titled "newsletter"'s single page | |
if( is_singular( 'newsletter' ) ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get YouTube Video ID by YouTube URL | |
* | |
* @param string YouTube video URL | |
* | |
* @return string YouTube video ID | |
*/ | |
function get_youtube_id_by_url( $url ){ | |
// Parse URL | |
$parsed_url = parse_url($url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Update the date in given condition | |
if( isset( $GLOBALS['wp_query'] ) && is_sticky() ){ | |
$GLOBALS['wp_query']->has_sticky = true; | |
} | |
if( isset( $GLOBALS['wp_query'] ) && !is_sticky() ){ | |
// Define date index | |
if( !isset( $GLOBALS['wp_query']->opus_date ) ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if current page is signup page or not | |
* | |
* @return boolean | |
*/ | |
function is_signup(){ | |
global $wp; | |
if( 'wp-signup.php' == $wp->request ){ | |
return true; |
OlderNewer