function msc_contentPrefilter($template) { global $wp_query, $contentPrefilters, $footerOutput, $headerscripts, $phpincludes; if (!empty($contentPrefilters)) { foreach ($contentPrefilters as $postID => $newContent) { //vardump($newContent); foreach ($wp_query->posts as $postKey => $post) { if ($postID == $post->ID) { $wp_query->posts[$postKey]->post_content = trim($newContent); //vardump($wp_query->posts[$postKey]->post_content, false); //vardump($newContent); } } } } // Custom do shortcode - disabled for now :( return $template; $Elements = get_option('CE_ELEMENTS'); foreach ($Elements as $key => $el) { if (empty($el['state'])) { unset($Elements[$key]); } } if (empty($Elements)) { return $template; } foreach ($wp_query->posts as $postKey => $post) { $Used = msc_getUsedShortcodes($post->post_content, array(), true); foreach ($Used[2] as $key => $shortcode) { $options = $Elements[$Used[7][$key]]; if (!empty($Used[3][$key])) { $setAtts = shortcode_parse_atts($Used[3][$key]); } else { $setAtts = array(); } if (!empty($options['variables'])) { $atts = array(); foreach ($options['variables']['names'] as $varkey => $variable) { if ($options['variables']['type'][$varkey] == 'Dropdown') { $options['variables']['defaults'][$varkey] = trim(strtok($options['variables']['defaults'][$varkey], ',')); } if (!empty($options['variables']['multiple'][$varkey])) { $endLoop = true; $loopIndex = 1; while ($endLoop) { if (isset($setAtts[$variable . '_' . $loopIndex])) { $atts[$variable . '_' . $loopIndex] = $setAtts[$variable . '_' . $loopIndex]; $loopIndex++; } else { if ($loopIndex === 1) { $atts[$variable . '_' . $loopIndex] = $options['variables']['defaults'][$varkey]; } $endLoop = false; } } } else { $atts[$variable] = $options['variables']['defaults'][$varkey]; } } } if (!empty($setAtts) && !empty($atts)) { $Atts = shortcode_atts($atts, $setAtts); } else { $Atts = false; } //need to replace the shortcode found with the new code below!! $newContent = trim(msc_doShortcode($Atts, $Used[5][$key], $options['shortcode'])); $post->post_content = str_replace($Used[0][$key], $newContent, $post->post_content); //vardump($Used[5][$key], false); //vardump(msc_doShortcode($Atts, $post->post_content, $options['shortcode'])); } } //die; return $template; }
global $wp_admin_bar, $footerOutput, $headerscripts, $javascript, $phpincludes, $contentPrefilters; $preheaderscripts = ''; /*$preheaderscripts .= "html, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del, dfn, em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label, legend,table, caption, tbody, tfoot, thead, tr, th, td,article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary,time, mark, audio, video {margin: 0;padding: 0;border: 0;font-size: 100%;font: inherit;vertical-align: baseline;} article, aside, details, figcaption, figure,footer, header, hgroup, menu, nav, section {display: block;} body {line-height: 1;padding:20px;} ol, ul {list-style: none;} blockquote, q {quotes: none;} blockquote:before, blockquote:after,q:before, q:after {content: '';content: none;} table{border-collapse: collapse;border-spacing: 0;}"; */ // remove admin bar for preview if (!empty($wp_admin_bar)) { $wp_admin_bar = false; } $shortcode = stripslashes_deep(strtolower($_GET['code'])); $used = msc_getUsedShortcodes('[' . $shortcode . ']', array(), true, true); $elements = get_option('CE_ELEMENTS'); if (!empty($elements)) { foreach ($elements as $element => $options) { if (!empty($options['shortcode'])) { foreach ($used[2] as $currentKey => $currentShortcode) { if ($options['shortcode'] == strtolower($used[2][$currentKey])) { if (!empty($used[3][0])) { $atts[$currentKey] = shortcode_parse_atts($used[3][$currentKey]); } else { $atts[$currentKey] = array(); } $IDs[$currentKey] = $element; $shortcodes[$currentKey] = $options['shortcode']; $cfg = get_option($element); }
<?php //global $wp_admin_bar; global $footerOutput, $headerscripts, $javascript, $phpincludes, $contentPrefilters; $shortcode = stripslashes_deep(strtolower($_GET['code'])); $used = msc_getUsedShortcodes($shortcode, array(), true, true); $elements = get_option('CE_ELEMENTS'); foreach ($elements as $element => $options) { if (!empty($options['shortcode'])) { foreach ($used[2] as $currentKey => $currentShortcode) { if ($options['shortcode'] == strtolower($used[2][$currentKey])) { if (!empty($used[3][0])) { $atts[$currentKey] = shortcode_parse_atts($used[3][$currentKey]); } else { $atts[$currentKey] = array(); } $IDs[$currentKey] = $element; $shortcodes[$currentKey] = $options['shortcode']; } } } } if (!empty($IDs)) { foreach ($IDs as $currentKey => $ID) { $instance[$currentKey] = msc_getDefaultAtts($ID, $atts[$currentKey]); msc_processHeaders($ID, $instance[$currentKey]['atts']); } $outPutCode = msc_doShortcode($instance[0]['atts'], "Yes, if you make it look like an electrical fire. When you do things right, people won't be sure you've done anything at all. And why did 'I' have to take a cab? You've killed me! Oh, you've killed me!", $shortcodes[0]); } wp_enqueue_script('jquery'); wp_enqueue_style('msc-preview', MYSHORTCODES_URL . 'styles/preview.css');