Skip to content

Instantly share code, notes, and snippets.

Christian Roth Christian-Roth

Block or report user

Report or block Christian-Roth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Christian-Roth
Christian-Roth / WP-cookies-not-accepted-shortcode.php
Last active Jul 8, 2018
A shortcode to show content if cookies are not accepted
View WP-cookies-not-accepted-shortcode.php
<?php /* Shortcode Cookie Not Accepted */
function custom_cn_cookies_not_accepted( $atts, $content = null ) {
if (function_exists('cn_cookies_accepted') && !cn_cookies_accepted()) {
return '<div class="box cookie-box">' . do_shortcode($content) . '</div>';
} else {
return '';
}
}
add_shortcode('cookies_not_accepted', 'custom_cn_cookies_not_accepted');
?>
@Christian-Roth
Christian-Roth / WP-cookie-status-shortcode.php
Last active Jul 8, 2018
A shortcode to show the cookie status
View WP-cookie-status-shortcode.php
@Christian-Roth
Christian-Roth / stars-block.js
Created Jan 30, 2018 — forked from pento/stars-block.js
Gutenberg Stars Block
View stars-block.js
( function( blocks, element ) {
var el = element.createElement;
function Stars( { stars } ) {
return el( 'div', { key: 'stars' },
''.repeat( stars ),
( ( stars * 2 ) % 2 ) ? '½' : '' );
}
blocks.registerBlockType( 'stars/stars-block', {
@Christian-Roth
Christian-Roth / tribe_remove_archive_ical_links.php
Last active Oct 13, 2017
The Events Calendar – Remove the iCal and Google cal links from the archive views
View tribe_remove_archive_ical_links.php
@Christian-Roth
Christian-Roth / tribe_remove_single_calendar_links.php
Created Oct 13, 2017 — forked from elimn/tribe_remove_single_calendar_links.php
MT | TEC | Remove the iCal and Google cal links from the single event page
View tribe_remove_single_calendar_links.php
@Christian-Roth
Christian-Roth / WP-custom_rest_api.php
Last active Nov 15, 2016
Functions to add a custom route to the WP REST API
View WP-custom_rest_api.php
// Init REST Route
function register_custom_api_hooks() {
$namespace = 'custom-name/v1';
register_rest_route( $namespace, '/posts/', array(
'methods' => 'GET',
'callback' => 'custom_api_get_posts',
) );
}
add_action( 'rest_api_init', 'register_custom_api_hooks' );
@Christian-Roth
Christian-Roth / WP-custom_cron.php
Last active Aug 26, 2016
Functions to add a custom WP cron
View WP-custom_cron.php
function your_function(){
// **** Add your function here ****
}
add_action( 'your_cron_action', 'your_function' );
// Init Cron Job
function init_custom_cron() {
if( !wp_next_scheduled( 'your_cron_action' ) ){
wp_schedule_event( time(), '20min', 'your_cron_action' );
}
@Christian-Roth
Christian-Roth / WP-custom_embed_header.php
Last active Jan 11, 2019
Function to change the header of WP embeds / Example CSS file
View WP-custom_embed_header.php
function goyippi_embed_header() {
wp_deregister_style('open-sans');
wp_enqueue_style( 'goyippi-embed-font', 'http://fonts.googleapis.com/css?family=Droid+Sans:400,700','','', 'all' );
wp_enqueue_style( 'goyippi-embed-styles', get_bloginfo('stylesheet_directory').'/wp-style_embed.css','','', 'all' );
}
add_action( 'embed_head', 'goyippi_embed_header' );
@Christian-Roth
Christian-Roth / WP-reverse_srcset_order.php
Last active Feb 18, 2017
Function to reverse the order in the WP srcset array
View WP-reverse_srcset_order.php
function reverse_srcset_order($atts) {
if (isset($atts['srcset'])) {
$srcset = explode(', ', $atts['srcset']);
$srcset_reversed = array_reverse($srcset);
$atts['srcset'] = join(', ', $srcset_reversed);
}
return $atts;
}
add_filter('wp_get_attachment_image_attributes','reverse_srcset_order',1,1);
You can’t perform that action at this time.