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 | |
add_filter('wpforo_get_posts', 'enable_wpforo_oembed'); | |
function enable_wpforo_oembed($content){ | |
global $wp_embed; | |
foreach($content as $single){ | |
$single['body'] = $wp_embed->autoembed( $single['body'] ); | |
$return[] = $single; | |
} |
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 | |
function fix_iis_thai_url(){ | |
global $_SERVER; | |
$_SERVER['REQUEST_URI'] = isset($_GET['requesturi']) ? $_GET['requesturi'] : '/'; | |
} | |
add_action("plugins_loaded", "fix_iis_thai_url"); | |
/* | |
Still need another fix on web.config |
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
/** | |
* Determine the mobile operating system. | |
* This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'. | |
* | |
* @returns {String} | |
* | |
* Source: http://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system | |
*/ | |
function getMobileOperatingSystem() { | |
var userAgent = navigator.userAgent || navigator.vendor || window.opera; |
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 | |
function show_url($url, $text = ''){ | |
$current = $uri = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | |
echo '<a href="'.$url.'" '.($current == $url ? 'class="active"' : '').'>'.(empty($text) ? $url : $text).'</a>'; | |
} | |
?> | |
<div><?php show_url('https://jirayu.in.th', 'Website'); ?></div> |
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 | |
// Original - https://facetwp.com/random-ordering-in-facetwp/ | |
function preserve_random_order( $orderby ) { | |
if(session_id() == ""){ | |
session_start(); | |
} | |
$seed = session_id(); // use session_id as a seed | |
$orderby = str_replace( 'RAND()', "RAND('{$seed}')", $orderby ); | |
return $orderby; | |
} |
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 | |
$db_date = "2018-01-04 14:37:50"; // เวลาจากฐานข้อมูล | |
$timestamp = strtotime( $db_date ); // แปลงเวลาจากฐานข้อมูลเป็น timestamp | |
$date = date( "j F Y", $timestamp ); // แปลง timestamp เป็นวันที่ | |
?> |
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 | |
function transient_example(){ | |
global $wpdb; // WordPress database class | |
if(false === ($data = get_transient( "transient_name" ))) { | |
// transient already expired or no transient | |
// re-cache data to transient | |
$data = query_stuff_here(); // select * from wp_postmeta where `meta_key` = 'field_name' |
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 | |
function wp63_alter_search_weight($args, $query){ | |
global $wpdb; | |
if( $query->query_vars['search_terms'][0] ){ | |
$args['orderby'] = 'CASE WHEN `'.$wpdb->posts.'`.`post_title` LIKE "%'.$query->query_vars['search_terms'][0].'%" THEN 1 ELSE 0 END DESC' ; | |
} | |
return $args; | |
} |
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 | |
function wp63_lock_plugin_version($data){ | |
$lock = apply_filters( "wp63_lock_plugin_version", array() ); | |
if(isset( $data->response )){ | |
foreach( $data->response as $key => $value ){ | |
if( isset($lock[$value->slug]) && $value->new_version != $lock[$value->slug]){ | |
$data->no_update[] = $value; | |
unset($data->response[$key]); | |
} |
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
jQuery(".content-title-box").each(function(index){ | |
var title = jQuery(this).find("a").text(); | |
if(title.substr(title.length - 4) !== "แล้ว"){ | |
jQuery(this).find("a").text(title + "แล้ว"); | |
} | |
}); |
OlderNewer