This file contains hidden or 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 | |
/* by ID */ | |
$args = array( | |
'p' => 42, // id of a page, post, or custom type | |
'post_type' => 'any' | |
); | |
$the_query = new WP_Query($args); | |
/* by post slug */ |
This file contains hidden or 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
<!-- Source: https://css-tricks.com/centering-in-the-unknown --> | |
<html> | |
<head> | |
<style> | |
.block { | |
text-align: center; | |
background: #c0c0c0; | |
border: #a0a0a0 solid 1px; | |
margin: 20px; | |
} |
This file contains hidden or 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 | |
// redirect with meta | |
$location = 'http://harislab.com'; | |
echo "<meta http-equiv='refresh' content='0;url=$location' />"; | |
echo "<h3>Redirecting...</h3>"; | |
exit(); |
This file contains hidden or 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
.absolute-centering { | |
width: 200px; | |
height: 150px; | |
position: absolute; /* or fixed */ | |
left: 50%; | |
margin-left: -100px; /* half of width */ | |
top: 50%; | |
margin-top: -75px; /* half of height */ | |
} |
This file contains hidden or 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 | |
class Hello | |
{ | |
private static $greeting = 'Hello, direct static call'; | |
function __construct($string = 'Hello, construct call') | |
{ | |
self::$greeting = $string; | |
} |
This file contains hidden or 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
// WordPress absolute path to url | |
function path_to_url($path) | |
{ | |
$url = str_replace($_SERVER['DOCUMENT_ROOT'], '', $path); | |
$http_proto = is_ssl() ? "https://" : "http://"; | |
return $http_proto . $_SERVER['SERVER_NAME'] . $url; | |
} |
This file contains hidden or 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_action('wp_ajax_ajax_coba', 'ajax_coba' ); | |
function ajax_coba() | |
{ | |
$id = $_POST['id']; | |
// json return | |
$return = array( | |
'success' => true, |
This file contains hidden or 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
/** | |
* Convert youtube and vimeo link to embed iframe | |
*/ | |
function convertEmbedMedia(html) | |
{ | |
var origin = html; | |
var pattern1 = /(?:http?s?:\/\/)?(?:www\.)?(?:vimeo\.com)\/(?:.*\/)?(.+)/g; | |
var pattern2 = /(?:http?s?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g; | |
var pattern3 = /([-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?(?:jpg|jpeg|gif|png))/gi; | |
This file contains hidden or 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
<!-- | |
Google Map Script | |
https://developers.google.com/maps/documentation/javascript/reference#MapOptions | |
--> | |
<script src="https://maps.googleapis.com/maps/api/js?callback=initMap" async defer></script> | |
<script type="text/javascript"> | |
function initMap() { | |
var mapDiv = document.getElementById('google-map'); | |
var map = new google.maps.Map(mapDiv, { | |
center: {lat: 44.540, lng: -78.546}, |
This file contains hidden or 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
deny from all |