Skip to content

Instantly share code, notes, and snippets.

@isuke01
isuke01 / taxonomy-terms-order.php
Last active Jun 17, 2021
Fix issue with Wordpres Multisite for Category Order and Taxonomy Terms Order.
View taxonomy-terms-order.php
<?php
/*
Plugin Name: Category Order and Taxonomy Terms Order
Plugin URI: http://www.nsp-code.com
Description: Order Categories and all custom taxonomies terms (hierarchically) and child terms using a Drag and Drop Sortable javascript capability.
Version: 1.5.7.6
Author: Nsp-Code
Author URI: https://www.nsp-code.com
Author Email: electronice_delphi@yahoo.com
Text Domain: taxonomy-terms-order
@isuke01
isuke01 / wp-rewrite.php
Last active Apr 14, 2021
Change wordpress blog poss rewrite rules
View wp-rewrite.php
<?php
/*
|--------------------------------------------------------------------------
| Fix for blog links
|--------------------------------------------------------------------------
| Add post type before single post name (fix post link on backend)
*/
function fix_blog_links($post_link, $post, $leavename) {
if($post->post_status === 'draft') return $post_link;
@isuke01
isuke01 / gutenberg_validation_acf_fix.php
Created Mar 7, 2020
Fix Gutenberg and ACF validation issue
View gutenberg_validation_acf_fix.php
function enhancement_gutenberg_isu(){
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
wp.domReady(function(){
//acf Custom Validation for Gutenberg
var postSaveButtonClasses = '.editor-post-publish-button';
$(document).on('click', postSaveButtonClasses , function(e){
e.stopPropagation();
@isuke01
isuke01 / gutenberg_validation_acf_fix.php
Created Mar 7, 2020
Fix Gutenberg and ACF validation issue
View gutenberg_validation_acf_fix.php
function enhancement_gutenberg_isu(){
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
wp.domReady(function(){
//acf Custom Validation for Gutenberg
var postSaveButtonClasses = '.editor-post-publish-button';
$(document).on('click', postSaveButtonClasses , function(e){
e.stopPropagation();
@isuke01
isuke01 / tempalte_override.php
Created Sep 7, 2018
Template override, simple override template file of page, based on page ID
View tempalte_override.php
<?php
add_filter( 'template_include', 'archives_overrides', 99 );
function archives_overrides( $template ) {
global $post;
if(!$post){ return $template; }
if ( $post->ID == get_archive_for_projects() ) {
$new_template = locate_template( array( 'template-projects.php' ) );
if ( '' != $new_template ) { return $new_template ; }
}
@isuke01
isuke01 / fileUpload.vue
Created Aug 23, 2018 — forked from raisiqueira/fileUpload.vue
Simple file upload with Vue and Axios
View fileUpload.vue
<style>
input[type="file"]{
position: absolute;
top: -500px;
}
div.file-listing{
width: 200px;
}
@isuke01
isuke01 / acf.php
Last active Sep 7, 2018
ACF custom rules and match based on options (for custom page Archive in this case)
View acf.php
<?php
//More: https://www.advancedcustomfields.com/resources/custom-location-rules/
// fis to work on keys instead of IDS
// Filter for ACF create field panel
add_filter('acf/location/rule_values/page_type', 'acf_location_rules_values_page', 10); // filter location
function acf_location_rules_values_page( $choices ) {
$choices['archive_for_projects'] = __('Projects archive page', 'ustekveikja'); // value and select box text
$choices['archive_for_neighborhood'] = __('Neighborhood archive page', 'ustekveikja'); // value and select box text
return $choices;
@isuke01
isuke01 / wp_navi_siblings.php
Created Jul 23, 2018
Wordpress navigation for siblings
View wp_navi_siblings.php
<?php
/*
* Based on https://gist.github.com/LL782/3551634
*/
function wp_links_siblings($postID = null){
if(!$postID){
global $post;
$postID = $post->ID;
}
$ancestors = get_post_ancestors( $postID );
@isuke01
isuke01 / support_for_svg_in_wp.php
Created Jul 23, 2018
Add SVG support to Wordpress Media library view + upload SVG
View support_for_svg_in_wp.php
<?php
/**
* Add support to SVG in WP media viewer
*/
function svg_meta_data_support($data, $id){
$attachment = get_post($id); // Filter makes sure that the post is an attachment
$mime_type = $attachment->post_mime_type; // The attachment mime_type
@isuke01
isuke01 / Functions.php
Last active May 28, 2018
Wordpress + GravityForm + VUE + React etc
View Functions.php
<?php
// Hook up the AJAX actions
add_action( 'wp_ajax_nopriv_gf_button_get_form', 'gf_button_ajax_get_form' );
add_action( 'wp_ajax_gf_button_get_form', 'gf_button_ajax_get_form' );
function gf_button_ajax_get_form(){
$form_id = isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
/*
used in case if you need additional dynamic fields