/** * Parses the attributes of the [jwplayer] tag. * @param array $matches The match array * @return string The code that should replace the tag. */ public static function tag_parser($matches) { if ($matches[1] == "[" && $matches[6] == "]") { return substr($matches[0], 1, -1); } $param_regex = '/([\\w.]+)\\s*=\\s*"([^"]*)"(?:\\s|$)|([\\w.]+)\\s*=\\s*\'([^\']*)\'(?:\\s|$)|([\\w.]+)\\s*=\\s*([^\\s\'"]+)(?:\\s|$)|"([^"]*)"(?:\\s|$)|(\\S+)(?:\\s|$)/'; $text = preg_replace("/[\\x{00a0}\\x{200b}]+/u", " ", $matches[3]); $text = preg_replace("/”|″/", "\"", preg_replace("/’|′/", "'", $text)); $atts = array(); if (preg_match_all($param_regex, $text, $match, PREG_SET_ORDER)) { foreach ($match as $p_match) { if (!empty($p_match[1])) { $atts[$p_match[1]] = stripcslashes($p_match[2]); } elseif (!empty($p_match[3])) { $atts[$p_match[3]] = stripcslashes($p_match[4]); } elseif (!empty($p_match[5])) { $atts[$p_match[5]] = stripcslashes($p_match[6]); } elseif (isset($p_match[7]) and strlen($p_match[7])) { $atts[] = stripcslashes($p_match[7]); } elseif (isset($p_match[8])) { $atts[] = stripcslashes($p_match[8]); } } } else { $atts = ltrim($text); } $shortcode = new JWP6_Shortcode($atts); return $matches[1] . $shortcode->embedcode() . $matches[6]; }
public static function shortcode($shortcode, $content, $tag) { $sc = new JWP6_Shortcode($shortcode); return $sc->embedcode(); }
<?php // Include the necessary admin stuff. require_once '../../../../wp-load.php'; require_once '../../../../wp-admin/includes/admin.php'; // Only for logged in users. if (!current_user_can('administrator') && !current_user_can('editor') && !current_user_can('contributor')) { exit; } // Call parameter is compulsory if (!($call = $_GET['call'])) { exit; } require_once JWP6_PLUGIN_DIR . '/jwp6-class-plugin.php'; require_once JWP6_PLUGIN_DIR . '/jwp6-class-media.php'; require_once JWP6_PLUGIN_DIR . '/jwp6-class-shortcode.php'; if ('embedcode' == $call) { $sc = new JWP6_Shortcode(); echo $sc->embedcode(); exit; }