Skip to content

Instantly share code, notes, and snippets.

Avatar

Julian Weiland derweili

  • Germany
View GitHub Profile
@derweili
derweili / template-specific-editor-styles.js
Created Feb 17, 2020
Page Template specific editor styles for the WordPress Block Editor (Gutenberg)
View template-specific-editor-styles.js
const {
subscribe,
select
} = wp.data;
/**
* Add dark-mode class to block-editor based on selected page template
*/
wp.domReady( () => {
const postType = select( 'core/editor' ).getCurrentPostType();
@derweili
derweili / block-string-list-block.js
Created Jul 24, 2019
Example Gutenberg Block with array attribute
View block-string-list-block.js
/**
* BLOCK: string-list-block
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './style.scss';
import './editor.scss';
@derweili
derweili / disable-acf-blocks-on-edit.js
Last active Dec 16, 2019
Disable Links in ACF Block-Edit Method
View disable-acf-blocks-on-edit.js
/*
* Wrap all ACF Blocks in Disabled block to disable all links in edit view
*/
const { createHigherOrderComponent } = wp.compose;
const { Fragment } = wp.element;
import { Disabled } from '@wordpress/components';
const withDisabledCompontent = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
@derweili
derweili / social-share.php
Created Feb 12, 2019
WordPress Social Share Link
View social-share.php
<?php
function get_shared_base_url(){
if( is_single() || is_page() ){
return get_permalink( get_the_id() );
}else{
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
return $current_url;
}
@derweili
derweili / wordpress-plugin-svn-to-git.md
Created Mar 2, 2018 — forked from kasparsd/wordpress-plugin-svn-to-git.md
Using Git with Subversion Mirroring for WordPress Plugin Development
View wordpress-plugin-svn-to-git.md
@derweili
derweili / orbit-wp-gallery.php
Created Sep 5, 2016
WordPress Gallery based on Zurb Foundation Orbit Carousel
View orbit-wp-gallery.php
@derweili
derweili / pregetposts_postnumber_filter.php
Last active May 11, 2016
Modify main query pased on taxonomy - wordpress
View pregetposts_postnumber_filter.php
function derweili_change_postnumber_imagegallerycat( $query ) {
if ( $query->is_main_query() && $query->is_tax('bildergalerien-kategorie') ) {
$query->set('posts_per_page', 50);
return;
}
}
add_action( 'pre_get_posts', 'derweili_change_postnumber_imagegallerycat' );
@derweili
derweili / selena-add-author-child-functions.php
Created Mar 1, 2016
Code to add the author to the meta function of the sela wordpress theme. Answer for forum topic on wordpress.org https://wordpress.org/support/topic/meta_data-add-author-in-frontend?replies=1
View selena-add-author-child-functions.php
if ( ! function_exists( 'sela_entry_meta' ) ) :
function sela_entry_meta() {
// Sticky
if ( is_sticky() && is_home() && ! is_paged() ) {
echo '<span class="featured-post">' . __( 'Featured', 'sela' ) . '</span>';
}
echo '<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) . '">' . get_the_author() . '</a>';
You can’t perform that action at this time.