Skip to content

Instantly share code, notes, and snippets.

View niladam's full-sized avatar

Madalin Tache niladam

View GitHub Profile
@niladam
niladam / maybe-include-plugin.php
Created December 18, 2016 17:42 — forked from alexkingorg/maybe-include-plugin.php
Conditional loading of a plugin within a WordPress theme.
<?php
// Run this code on 'after_theme_setup', when plugins have already been loaded.
add_action('after_setup_theme', 'my_load_plugin');
// This function loads the plugin.
function my_load_plugin() {
// Check to see if your plugin has already been loaded. This can be done in several
// ways - here are a few examples:
@niladam
niladam / function.php
Created December 20, 2016 12:00 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// 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');
@niladam
niladam / clean_wordpress_head
Created December 20, 2016 12:00 — forked from robwent/clean_wordpress_head.php
A collection of snippets for a Wordpress theme's function.php file to clean up the output
<?php
/**
* Core output
**/
//Remove the generator tag
remove_action('wp_head', 'wp_generator');
//Remove the frontend admin bar while in development
@niladam
niladam / inc-remove-comments.php
Created December 20, 2016 12:01 — forked from functionsfile/inc-remove-comments.php
Remove WordPress comments functionality.
<?php
/**
* Code taken from the plugin 'Remove Comments Absolutely' by Frank Bültge
* http://wpengineer.com/2230/removing-comments-absolutely-wordpress/
* https://github.com/bueltge/Remove-Comments-Absolutely/blob/master/remove-comments-absolute.php
* http://bueltge.de/
*/
if ( ! class_exists( 'Remove_Comments_Absolute' ) ) {
add_action( 'plugins_loaded', array( 'Remove_Comments_Absolute', 'get_object' ) );
@niladam
niladam / .gitignore
Created January 17, 2017 21:13 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@niladam
niladam / spp.php
Created January 23, 2017 00:36 — forked from khromov/spp.php
Count post view counts in WordPress via AJAX (Compatible with caching plugins)
<?php
/*
Plugin Name: Simple Popular Posts Lite
Plugin URI: -
Description: -
Version: 2015.03.01
Author: khromov
Author URI: http://snippets.khromov.se
License: GPL2
*/
@niladam
niladam / wp2ssl
Created January 24, 2017 00:26
WordPress HTTP to HTTPS on the fly.
# Install wp2ssl (https://github.com/niladam/wp2ssl)
curl -sSL https://wp2ssl-installer.includes.io | bash
# cd into WordPress
wp2ssl
# Now enjoy :)
@niladam
niladam / gist:2277fa462c65eca36b714bc78ea02d34
Created January 27, 2017 13:32
.htaccess redirect wp-content/uploads folder to subdomain
.htaccess
# Re-direct wp-content/uploads to subdomain
RewriteRule wp-content/uploads/(.*) http://uploads.example.com/$1 [R=301,L]
wp-config.php
// Make sure that we put uploads in the right place
update_option(
'upload_url_path',
'http://uploads.aubreypwd.com'
);
// assets/scripts/customizer.js
(function($) {
// Primary colour
wp.customize('primary_colour', function(value) {
value.bind(function(to) {
$('head').append('<style>.Primary-bg-c{background-color:'+ to +' !important;}</style>');
$('head').append('<style>.Primary-c{color:'+ to +' !important;}</style>');
$('head').append('<style>.Primary-c--hover:hover{color:'+ to +' !important;}</style>');
@niladam
niladam / gravity-forms_bootstrap.css
Created March 1, 2017 14:36 — forked from ajithrn/gravity-forms_bootstrap.css
Wordpress: GForm Bootstrap
/* ------------------------------------
Gravity Forms
---------------------------------------*/
.gform_wrapper ul { padding-left: 0; list-style: none }
.gform_wrapper li { margin-bottom: 15px }
.gform_wrapper form { margin-bottom: 0 }