Skip to content

Instantly share code, notes, and snippets.

View Aziz-Rahman's full-sized avatar

Aziz Rahman Aji Aziz-Rahman

View GitHub Profile
// Detect url
if (!function_exists('parse_links')) {
function parse_links($str) {
// The Regular Expression filter
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?|[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
// Check if there is a url in the text
if(preg_match($reg_exUrl, $str, $url)) {
// make the urls hyper links
return preg_replace($reg_exUrl, '<a href="'.$url[0].'" rel="nofollow">'.$url[0].'</a>', $str);
} else {
@Aziz-Rahman
Aziz-Rahman / login_sdfjsdjfs.php
Last active February 10, 2016 19:17
Login register with hash password 5.5 with option salt. (option salt deprecated in php 7)
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" role="form" id="login-customer">
<div class="form-group">
<label for="usr">Username</label>
<input type="text" name="username" class="form-control" id="usr">
</div>
<div class="form-group">
<label for="pwd">Password</label>
<input type="password" name="password" class="form-control" id="pwd">
</div>
<div class="form-group">
@Aziz-Rahman
Aziz-Rahman / csswp.css
Last active December 30, 2015 07:15
Adminbarwpberkedipdgstickymenu/jkljhljhd vfffffffffd
#wpadminbar {
backface-visibility: hidden;
}
@Aziz-Rahman
Aziz-Rahman / submenu-customposttype.php
Last active December 31, 2015 02:52
Sub menu custom posttype and display data based empty photo in page template photo
<?php
/*------------------------------------------------------------*/
/* Register Taxonomy */
/*------------------------------------------------------------*/
if ( ! function_exists( 'my_image_color' ) ) :
// Register Photo Tag Taxonomy
function my_image_color() {
$labels = array(
@Aziz-Rahman
Aziz-Rahman / displaydatawp.php
Last active December 11, 2015 04:20
Display post based without a feature image in wp
global $wpdb;
/* -- Preparing your query -- */
$query = "SELECT wp_posts.* FROM wp_posts
LEFT JOIN wp_postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_thumbnail_id' )
WHERE $wpdb->posts.post_type = 'photo' AND ( $wpdb->posts.post_status = 'publish' ) AND ( $wpdb->postmeta.post_id IS NULL )";
// $wpdb->posts.post_type = 'photo' -------> custom post type
@Aziz-Rahman
Aziz-Rahman / taxonomy-smpl.php
Created December 10, 2015 08:09
Get taxonomy based link in single post
$taxonomy = 'source';
$terms = get_the_terms( $post->ID, $taxonomy );
if ( $terms ) {
foreach($terms as $term) {
$term_link = get_term_link( $term );
}
}
<a href="'. $term_link .'">This is link</a>
@Aziz-Rahman
Aziz-Rahman / select.php
Created December 10, 2015 03:17
selectopt
<select name="txtkd_unit">
<option value='0'> pilih unit </option>
<?php
$tampil=mysql_query("select * from unit");
while ($r=mysql_fetch_array($tampil)){
echo "<option value='{$r['kd_unit']}'".($hsl['kd_unit']==$r['kd_unit']?" selected":"").">{$r['nama_unit']}</option>";
}
?>
</select>
@Aziz-Rahman
Aziz-Rahman / memisahkata.php
Created December 8, 2015 07:13
Memisahkan kata dengan koma
<?php
// 1.
$text = '#ccc#ddd#fff'; // output awal
$data = str_replace ("#", ",#", $text);
$str = trim($data,',');
echo $str;
echo '<br>';
// 2.
@Aziz-Rahman
Aziz-Rahman / upload.php
Created December 4, 2015 02:18
Multiple upload
<?php
if(isset( $_FILES["gambar"] ) ){
//Ulang di setiap file
for( $i=0; $i<count($_FILES["gambar"]["name"] ); $i++ ) {
//Deteksi temporari path $tmpFilePath = $_FILES["gambar"]['tmp_name'][$i];
//Cek apakah file yang diupload lebih dari satu
if ( $tmpFilePath != "" ) {
//Set path/folder baru untuk tempat upload
$newFilePath = "files/" . $_FILES["gambar"]["name"][$i];
//Upload file dari temporari path ke folder baru
@Aziz-Rahman
Aziz-Rahman / functions.php
Created December 2, 2015 09:47
Rewrite url search wp
<?php
/**
* Search rewrite url -> save this in function.php
*
* @package WordPress
* @subpackage Imagefinder
* @since Imagefinder 1.0.0
*/
if ( !function_exists( 'warrior_search_url_rewrite ') ) {
function warrior_search_url_rewrite() {