Skip to content

Instantly share code, notes, and snippets.

View jimi008's full-sized avatar
:octocat:
Working as DevOps Engineer

Jamil Ahmed jimi008

:octocat:
Working as DevOps Engineer
View GitHub Profile
@jimi008
jimi008 / git-deployment.md
Created December 14, 2018 16:17 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@jimi008
jimi008 / 404.php
Created December 14, 2018 08:44 — forked from matthiaspabst/404.php
Twenty Fifteen - Custom 404 page for a custom post type
<?php
/**
* The template for displaying 404 pages (not found)
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
get_header(); ?>
@jimi008
jimi008 / gist:04e0f9f32e9c80da0ff78ff15e2a53bb
Created December 11, 2018 12:13 — forked from wpexplorer/gist:6574282
Simple WordPress login/logout shortcode
if ( ! function_exists('wpex_loginout_shortcode') ) {
function wpex_loginout_shortcode( $atts ) {
extract( shortcode_atts( array(
'login_url' => wp_login_url(),
'log_in_text' => __( 'log in', 'wpex' ),
'log_out_text' => __( 'log out', 'wpex' ),
), $atts ) );
if ( is_user_logged_in() ) {
$url = wp_logout_url( home_url() );
return '<a href="'. $url .'" title="'. $log_out_text .'">'. $log_out_text .'</a>';
@jimi008
jimi008 / functions.php
Last active November 13, 2018 21:22
Remove comment author url from comments
Each theme is different, though something like this would generally not include the comment author’s URL in the comment, by adding this to the end of your theme’s functions.php:
<?php
//Remove comment author URL
add_filter( 'get_comment_author_url', '__return_null' );
@jimi008
jimi008 / wp-admin-select2.php
Created May 3, 2018 16:20 — forked from yanknudtskov/wp-admin-select2.php
Add select2 to all select fields in WordPress Admin
<?php
function enqueue_select2_jquery() {
wp_register_style( 'select2css', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all' );
wp_register_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array( 'jquery' ), '1.0', true );
wp_enqueue_style( 'select2css' );
wp_enqueue_script( 'select2' );
}
add_action( 'admin_enqueue_scripts', 'enqueue_select2_jquery' );
@jimi008
jimi008 / functions.php
Created March 31, 2018 01:51 — forked from LukaHarambasic/functions.php
Wordpress: ACF-Field as CPT Title
// inspired by: https://gist.github.com/rveitch/9018669face1686e74aaa68026856f36
// add iitle to CPTs which doesn't provide a title (useful for the relationship field (https://www.advancedcustomfields.com/resources/relationship/))
function sync_acf_post_title($post_id, $post, $update) {
$post_type = get_post_type($post_id);
// check for the current CPT
if($post_type === "cpt_name_1") {
@jimi008
jimi008 / sync_acf_post_title.php
Created March 31, 2018 01:51 — forked from rveitch/sync_acf_post_title.php
Update WordPress post title from an ACF field value on save. (Advanced Custom Fields)
<?php
/**
* Update Post Title from an ACF field value on post save.
*
* Triggers on save, edit or update of published posts.
* Works in "Quick Edit", but not bulk edit.
*/
function sync_acf_post_title($post_id, $post, $update) {
$acf_title = get_field('my_acf_field_name', $post_id); // NOTE: enter the name of the ACF field here
<?php
/*=========================================
Custom Submit Box
==========================================*/
/**
* Loop throught custom post types and
* replace default submit box
*
* @since 1.0
*
@jimi008
jimi008 / wp-get_id_by_slug
Created December 19, 2017 08:22 — forked from eddt/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug','any-post-type');
function get_id_by_slug($page_slug, $slug_page_type = 'page') {
$find_page = get_page_by_path($page_slug, OBJECT, $slug_page_type);
if ($find_page) {
return $find_page->ID;
} else {
return null;
}
@jimi008
jimi008 / custom-registration.php
Created November 9, 2017 07:17 — forked from trslater/custom-registration.php
Custom Registration Plugin
<?php
/*
Plugin Name: Custom Registration
Description: Updates user rating based on number of posts.
Version: 1.1
Author: Tristan Slater w/ Agbonghama Collins
Author URI: http://kanso.ca
*/