This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function shortcoder_domain_parts($url) { | |
$parsedUrl = parse_url($url); | |
$host = $parsedUrl['host']; | |
$hostParts = explode('.', $host); | |
$numParts = count($hostParts); | |
if ($numParts >= 3) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds "id" attribute to heading tags in WordPress post content using the "the_content" filter and regex. | |
*/ | |
function anchor_headings( $content ) { | |
$content = preg_replace_callback( '/(\<h[2-3](.*?))\>(.*)(<\/h[2-3]>)/i', function( $matches ) { | |
if ( ! stripos( $matches[0], 'id=' ) ){ | |
$slug = sanitize_title( $matches[3] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Create a shortcode which will conditional print shortcoder shortcode */ | |
function sc_condition_function($args){ | |
$category = get_the_category(); | |
$firstCategory = $category[0]->cat_name; | |
if( $firstCategory = 'my_category' ){ | |
echo do_shortcode( '[sc name="sc1"]' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function srr_youtube_video( $html, $feed_url, $feed_item ){ | |
$content = $feed_item->get_content(); | |
$html[ 'description' ] = $content; | |
return $html; | |
} | |
add_filter( 'srr_mod_item_html', 'srr_youtube_video', 10, 3 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Shortcodes handler | |
* | |
**/ | |
class WPSR_Shortcodes{ | |
public static function init(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function shortcoder_woocommerce_params( $params ){ | |
$params['wc_info'] = array( | |
'name' => __( 'WooCommerce information', 'shortcoder' ), | |
'icon' => 'cart', | |
'params' => array( | |
'sku' => __( 'Product SKU', 'shortcoder' ), | |
'price' => __( 'Product price', 'shortcoder' ), |