Skip to content

Instantly share code, notes, and snippets.

@oskosk
Created October 28, 2017 20:34
Show Gist options
  • Save oskosk/9b48dad71c910c59f6feadd479f70b25 to your computer and use it in GitHub Desktop.
Save oskosk/9b48dad71c910c59f6feadd479f70b25 to your computer and use it in GitHub Desktop.
<?php
/**
* @package HTML Shortcodes
* @version 1.0
*/
/*
Plugin Name: Rational SHortcodes
Author: Osk
*/
add_filter( 'the_content', function( $content ) {
echo "titania\n";
$matcher = '/((?:<div|(?<!^)\G)\h*(?:data-shortcode)(?:="([^"]*)")*(.*?\/>))/';
$regexp = '/(?:<div|(?<!^)\G)\h*(data-[\w-]+)(?:="([^"]*)")*(?=.*?\/>)/';
$match = array();
$match2 = array();
$matches = array();
preg_match_all( $regexp , $content, $match );
preg_match( $matcher , $content, $match2 );
var_dump($match2);
if ( ! empty( $match ) ) {
$matches = array_combine( $match[1], $match[2]);
}
if ( ! empty( $matches ) ) {
// var_dump( $match[0] ) ;
var_dump( $matches ) ;
}
return $content;
// Before do_shortcode
}, 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment