Skip to content

Instantly share code, notes, and snippets.

View qutek's full-sized avatar
💻
Working from home

Lafif Astahdziq qutek

💻
Working from home
View GitHub Profile
@qutek
qutek / post-receive
Last active August 29, 2015 14:09
[Git] Automatic Deployment with git hooks
/**
* Create directory and init as --bare repo
*/
mkdir repo && cd repo
mkdir site.git && cd site.git
git init --bare
/**
@qutek
qutek / functions.php
Last active November 19, 2021 11:21
[Wordpress] Disable wordpress comment
<?php
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
@qutek
qutek / Wordpress virtual page
Created November 8, 2014 16:49
[Wordpress] Virtual Page
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@qutek
qutek / db-error.php
Created November 4, 2014 09:27
[Wordpress] Custom error database connection page
<?php
/**
* Custom wordpress error database connection page
* @put this file on your wp-content/ folder.
* @name file : db-error.php
*
*/
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
@qutek
qutek / funtions.php
Created November 3, 2014 06:21
[Wordpress] Add metabox and custom column
<?php
/**
* Custom metabox to change priority displaying courses
* ====================================================
*/
add_action( 'add_meta_boxes', 'tj_amb_priority_courses' );
function tj_amb_priority_courses() {
add_meta_box( 'tj_mb_priority_courses', 'Display Priority', 'tj_mb_priority_courses_cb', 'sfwd-courses', 'side', 'high' );
}
@qutek
qutek / class.page-template.php
Last active August 29, 2015 14:08
[Wordpress] Create page template from plugin
<?php
/**
* Plugin Name: MHT Domain Search
* Description: Page template domain registration for mega high tech.
* Author: Lafif Astahdziq
* Author URI: http://astahdziq.in/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@qutek
qutek / functions.php
Created October 27, 2014 07:46
[Wordpress] [Buddypress] Batch add user to buddypress group
<?php
/**
* Batch Add user to buddypress group
*/
add_action('load-users.php',function() {
if(isset($_POST['action']) && ($_POST['action'] == 'groupadd') && isset($_POST['bp_gid']) && isset($_POST['allusers'])) {
// print_r($_POST); exit();
$group_id = $_POST['bp_gid'];
@qutek
qutek / file.php
Last active July 11, 2022 18:02
[Wordpress] Display data with native wordpress table
<?php
/*
Plugin Name: Custom table example
Description: example plugin to demonstrate wordpress capatabilities
Plugin URI: http://mac-blog.org.ua/
Author URI: http://mac-blog.org.ua/
Author: Marchenko Alexandr
License: Public Domain
Version: 1.1
*/
@qutek
qutek / functions.php
Created October 6, 2014 09:25
[Wordpress] Replace https
function filter_content_match_protocols( $content ) {
$search = $replace = get_bloginfo( 'home' );
if ( ! preg_match( '|/$|', $search ) )
$search = $replace = "$search/";
if ( is_ssl() ) {
$search = str_replace( 'https://', 'http://', $search );
$replace = str_replace( 'http://', 'https://', $replace );
}
@qutek
qutek / parse_path.php
Last active February 2, 2020 12:09
[PHP][htaccess] Parse path from Clean URL (Prety Permalink)
<?php
/**
* parse path to get from clean URL
* @return [array] [array of requested uri]
*/
function parse_path() {
$path = array();
if (isset($_SERVER['REQUEST_URI'])) {
$request_path = explode('?', $_SERVER['REQUEST_URI']);