Skip to content

Instantly share code, notes, and snippets.

View gagimilicevic's full-sized avatar

Milicevic Dragan gagimilicevic

View GitHub Profile
@gagimilicevic
gagimilicevic / thz_disable_gutenberg.php
Created October 25, 2018 11:40 — forked from danyj/thz_disable_gutenberg.php
Disable Gutenberg globally or for specific post types for WordPress 5.0 and UP
<?php
/*
* Disable Gutenberg globally
* use this if you prefer one-liner
* add_filter('use_block_editor_for_post', '__return_false');
*/
function _thz_filter_disable_block_editor(){
return false;
}
add_filter( 'use_block_editor_for_post', '_thz_filter_disable_block_editor' );
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@gagimilicevic
gagimilicevic / getdates.js
Created September 17, 2018 10:46 — forked from miguelmota/getDates.js
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
var getDates = function(startDate, endDate) {
var dates = [],
currentDate = startDate,
addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
while (currentDate <= endDate) {
@gagimilicevic
gagimilicevic / file-upload-handler.php
Created May 18, 2018 14:02 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@gagimilicevic
gagimilicevic / nationality.html
Created May 16, 2018 10:04 — forked from didats/nationality.html
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
@gagimilicevic
gagimilicevic / functions.php
Created May 8, 2018 14:38
Snippet that will let you return the ID of the parent page if the page has a parent.
<?php
function is_subpage() {
global $post;
if ( is_page() && $post->post_parent ) {
return $post->post_parent;
} else {
return false;
}
}
@gagimilicevic
gagimilicevic / taxonomy-slug-as-custom-post-type.php
Last active April 10, 2018 08:16 — forked from fomigo/taxonomy-slug-as-custom-post-type.php
wp: CUSTOM TAXONOMY WITH SAME SLUG AS CUSTOM POST TYPE
<?php
/*
* Source: http://someweblog.com/wordpress-custom-taxonomy-with-same-slug-as-custom-post-type/
*/
// rewrite urls
function taxonomy_slug_rewrite($wp_rewrite) {
$rules = array();
@gagimilicevic
gagimilicevic / custom.php
Created April 4, 2018 17:06
Permalinks: custom post type -> custom taxonomy -> post
register_taxonomy(
'show_category',
'show',
array(
'rewrite' => array( 'slug' => 'shows', 'with_front' => false ),
// your other args...
)
);
register_post_type(
@gagimilicevic
gagimilicevic / extend_cf7_with_new_feature.php
Created March 27, 2018 15:03
Extending CF7 with new feature or option from backend
<?php
function cf7_active_campaign_add_meta_boxes() {
add_meta_box( 'cf7-active-campaign-settings', 'Active Campaign', 'cf7_active_campaign_metaboxes', '', 'form', 'low');
}
add_action( 'wpcf7_add_meta_boxes', 'cf7_active_campaign_add_meta_boxes' );
function cf7_activecampaign_add_page_panels($panels) {
$panels['redirect-panel'] = array( 'title' => 'Active Campaign Settings', 'callback' => 'cf7_activecampaign_page_panel_meta' );
return $panels;
}
@gagimilicevic
gagimilicevic / functions.php
Created March 22, 2018 11:05
WordPress Social Share links
function social_sharing()
{
extract(shortcode_atts(array(), $atts));
return'
<label class="social-sharing-label" for="social-open-link">Share This Article</label>
<input type="checkbox" id="social-open-link">
<div id="social-sharing-container">
<a class="social-sharing-icon social-sharing-icon-facebook" target="_new" href="http://www.facebook.com/share.php?u=' . urlencode(get_the_permalink()) . '&title=' . urlencode(get_the_title()). '"><i class="fa fa-facebook-square"></i></a>
<a class="social-sharing-icon social-sharing-icon-twitter" target="_new" href="http://twitter.com/home?status='. urlencode(get_the_title()). '+'. urlencode(get_the_permalink()) . '"><i class="fa fa-twitter-square"></i></a>
<a class="social-sharing-icon social-sharing-icon-pinterest" target="_new" href="https://pinterest.com/pin/create/button/?url=' . urlencode(get_the_permalink()) . '&media=' . urlencode(get_template_directory_uri()."/img/logo.png") . '&description=' . urlencode(get_the_title()). '"><i class="fa fa-pinteres