function parse_shortcode() { $this->check_nonce(); $this->init_page(); // added for some plugins to make LE a page global $wp_query; $wp_query->is_page = true; // end define('OP_AJAX_SHORTCODE', true); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = isset($_POST['depth']) && $_POST['depth'] == 1 ? 1 : 0; $GLOBALS['OP_ADD_ELEMENT_ROWS'] = false; $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array(); $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = false; //$GLOBALS['OP_DONE_TOP_LEVEL'] = false; require_once OP_ASSETS . 'live_editor.php'; $sc = isset($_POST['shortcode']) ? $_POST['shortcode'] : $_GET['shortcode']; $sc = op_fix_embed_url_shortcodes(stripslashes($sc)); // Popup needs to be handled differently $op_popup_present = false; // removing new line before shortcode entered in content $sc = str_replace(array("\n[", "\r[", "\r\n[", "\n\r["), array("[", "[", "[", "["), $sc); if (strpos($sc, '[op_popup ') !== false || strpos($sc, '[op_popup_elements]') !== false) { $op_popup_present = true; } // if ( strpos($sc, '[op_popup_button]') !== false && strpos($sc, '[op_popup ') === false) { // if ( strpos($sc, '[op_popup_elements]') === false ) { // $op_popup_present = true; // } else { // $sc = str_replace('[op_popup_elements]', '', $sc); // $sc = str_replace('[/op_popup_elements]', '', $sc); // } // } else { // $sc = str_replace('[op_popup_elements]', '', $sc); // $sc = str_replace('[/op_popup_elements]', '', $sc); // } if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches) || $op_popup_present) { if ($GLOBALS['OP_LIVEEDITOR_DEPTH'] === 1) { // EDIT ELEMENT $GLOBALS['OP_ADD_ELEMENT_ROWS'] = true; if (!$op_popup_present) { $processed = op_process_content_filter($sc, true); } if ($op_popup_present) { // [op_popup_elements] shortcode is present here $new_popup_elements = ''; preg_match_all('/\\[op_popup_content_element[ d|\\]].*?\\[\\/op_popup_content_element\\]/is', $sc, $popup_elements); foreach ($popup_elements[0] as $popup_element) { $popup_element_sc = $popup_element; // Change shortcodes op_popup_content_element with op_liveeditor_element (taking data-style attribute into account) $popup_element = preg_replace('/\\[op_popup_content_element(.*?"?)\\]/is', '[op_liveeditor_element $1][op_popup_content_element]', $popup_element); // Closing shortcode can't have attributes $popup_element = str_replace('[/op_popup_content_element]', '[/op_popup_content_element][/op_liveeditor_element]', $popup_element); $popup_element = op_process_content_filter('[op_liveeditor_elements]' . $popup_element . '[/op_liveeditor_elements]', true); $popup_element = str_replace('###OP_POPUP_CONTENT_CHILDREN###', $popup_element_sc, $popup_element); $popup_element = preg_replace('/\\[op_popup_content_element.*?\\]/is', '', $popup_element); $popup_element = str_replace('[/op_popup_content_element]', '', $popup_element); $new_popup_elements .= $popup_element; } $new_popup_elements = str_replace('$', '\\$', $new_popup_elements); $processed = preg_replace('/\\[op_popup_elements[ d|\\]].*?\\[\\/op_popup_elements\\]/is', $new_popup_elements, $sc); // $processed = str_replace('[op_popup_button]', '<div class="op-popup-button ' . $popup_button_class . '">', $processed); // $processed = str_replace('[/op_popup_button]', '</div>', $processed); $processed .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); } $processed = '<h1>' . __('Content LiveEditor', OP_SN) . '</h1><div class="epicbox-actual-content">' . $processed . '<a href="#add_element" class="add-new-element"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . esc_attr__('Add Element', OP_SN) . '"><span>' . __('Add Element', OP_SN) . '</span></a></div><div class="op-insert-button cf"><button type="submit" class="editor-button"><span>' . __('Update', OP_SN) . '</span></button></div>'; if ($op_popup_present) { $processed .= '<div class="op-hidden op_popup_element_present"><textarea class="op-le-child-shortcode" name="shortcode[]">' . $sc . '</textarea></div>'; } } else { // UPDATE ELEMENT $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = true; $child_data = op_page_parse_child_elements($matches[0]); $processed = do_shortcode(str_replace($matches[0], '#OP_CHILD_ELEMENTS#', $sc)); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 1; $child_html = ''; $child_element_nr = 0; // $child_html = op_page_parse_child_row($child_data['liveeditorElements']); /** * At the end of child elements "add element" button must * be inserted, which is done by parsing [op_liveeditor_elements] shortcode */ $child_html .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); $child_html = op_process_asset_content($child_html) . '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop($matches[0])) . '</textarea></div>'; /* * $ needs to be escaped */ $child_html = str_replace('$', '\\$', $child_html); $processed = preg_replace(array('{<p[^>]*>\\s*#OP_CHILD_ELEMENTS#\\s*<\\/p>}i', '{#OP_CHILD_ELEMENTS#}i'), $child_html, $processed); if ($op_popup_present) { $new_popup_elements = ''; $new_popup_elements_sc = ''; // Parse op_popup_content preg_match_all('/\\[op_popup_content_element[ d|\\]].*?\\[\\/op_popup_content_element\\]/is', $sc, $popup_elements); foreach ($popup_elements[0] as $popup_element) { $new_popup_elements_sc .= $popup_element; $popup_element = preg_replace('/\\[op_popup_content_element(.*?"?)\\]/is', '[op_liveeditor_element$1]', $popup_element); $popup_element = str_replace('[/op_popup_content_element]', '[/op_liveeditor_element]', $popup_element); $popup_element = op_process_content_filter($popup_element, true); $new_popup_elements .= $popup_element; } $new_popup_elements = '<div class="op-popup-content">' . $new_popup_elements . '</div>'; $new_popup_elements .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); $new_popup_elements = str_replace('$', '\\$', $new_popup_elements); $processed = preg_replace('/\\[op_popup_content[ d|\\]].*?\\[\\/op_popup_content\\]/is', $new_popup_elements, $sc); // Parse op_popup_button preg_match_all('/\\[op_popup_button\\].*?\\[\\/op_popup_button\\]/is', str_replace('$', '\\$', $sc), $new_popup_button); $new_popup_button = $new_popup_button[0][0]; $new_popup_button = str_replace('[op_popup_button]', '', $new_popup_button); $new_popup_button = str_replace('[/op_popup_button]', '', $new_popup_button); $new_popup_button = op_process_content_filter($new_popup_button, true); $new_popup_button = '<div class="op-popup-button ' . $popup_button_class . '">' . $new_popup_button . '</div>'; $processed = op_process_content_filter($processed, true); $new_popup_button = str_replace('$', '\\$', $new_popup_button); $processed = preg_replace('/\\[op_popup_button\\].*?\\[\\/op_popup_button\\]/is', $new_popup_button, $processed); // $processed = str_replace('[op_popup_button]', '<div class="op-popup-button ' . $popup_button_class . '">', $processed); // $processed = str_replace('[/op_popup_button]', '</div>', $processed); $processed .= '<div class="op-hidden op_popup_element_present"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop('[op_popup_elements]' . $new_popup_elements_sc . '[/op_popup_elements]')) . '</textarea></div>'; } } } else { // $processed = apply_filters('the_content', $sc); $processed = op_process_content_filter($sc, true); } $output = array('output' => $processed, 'js' => OptimizePress_Default_Assets::_print_front_scripts(true), 'check' => OptimizePress_Default_Assets::_check_function(), 'font' => OptimizePress_Default_Assets::_get_font()); if (isset($GLOBALS['OP_PARSED_SHORTCODE']) && !empty($GLOBALS['OP_PARSED_SHORTCODE'])) { $output['shortcode'] = $GLOBALS['OP_PARSED_SHORTCODE']; } echo json_encode($output); exit; }
function generate_layout($layout, $type, $one_col = false) { if (is_404()) { wp_redirect(home_url() . '/prtctd'); exit; } $this->remove_disabled_filters(); // initializing variables to deal with Undefined variable notices $popup_data_fade = $popup_button_class = ''; // initializing some variables $after_element = ''; $subcol_start = ''; $subcol_end = ''; $row_start = $row_end = $element_start = $element_end = $col_start = $col_end = ''; $measures = array('split-half' => 0.5, 'split-one-third' => 0.33, 'split-two-thirds' => 0.66, 'split-one-fourth' => 0.25, 'split-three-fourths' => 0.75); if (defined('OP_LIVEEDITOR')) { if ($one_col && count($layout) == 0) { $layout = array(array('row_class' => 'row one-col cf ui-sortable', 'columns' => array(array('col_class' => 'one column cols', 'elements' => array())), 'children' => array(array('col_class' => 'one column cols', 'elements' => array())))); } $row_start = $one_col ? '' : '<div class="op-row-links"> <div class="op-row-links-content"> <a title="' . __('Copy Row', 'optimizepress') . '" href="#copy-row" class="copy-row"></a> <a title="' . __('Edit Row Options', 'optimizepress') . '" href="#options" class="edit-row" id="row_options"></a> <a title="' . __('Clone Row', 'optimizepress') . '" href="#clone-row" class="clone-row"></a> <a href="#add-new-row" class="add-new-row"><span>' . __('Add New Row', 'optimizepress') . '</span></a> <a title="' . __('Move Row', 'optimizepress') . '" href="#move" class="move-row"></a> <a title="' . __('Paste Row', 'optimizepress') . '" href="#paste-row" class="paste-row"></a> <a title="' . __('Delete Row', 'optimizepress') . '" href="#delete-row" class="delete-row"></a> </div> </div>'; $row_end = ''; $col_start = $subcol_start = ''; //<div class="op-col-links"><a class="move-col" href="#move"><img alt="'.__('Move', 'optimizepress').'" src="'.OP_IMG.'move-icon.png" /></a></div>'; $col_end = '<div class="element-container sort-disabled"></div> <div class="add-element-container"> <a href="#add_element" class="add-new-element"> <span>' . __('Add Element', 'optimizepress') . '</span> </a> </div>'; $element_start = '<div class="op-element-links">' . '<a class="element-settings" href="#settings">' . __('Edit Element', 'optimizepress') . '</a>' . '<a class="element-clone" href="#clone-element">' . esc_attr__('Clone Element', 'optimizepress') . '</a>' . '<a class="element-advanced" href="#op-le-advanced">' . __('Advanced Element Options', 'optimizepress') . '</a>' . '<a class="element-move" href="#move">' . __('Move', 'optimizepress') . '</a>' . '<a class="element-delete" href="#delete">' . __('Remove Element', 'optimizepress') . '</a>' . '</div> <div class="op-hidden op-waiting"> <img class="op-bsw-waiting op-show-waiting" alt="" src="images/wpspin_light.gif" /> </div>'; $element_end = '<div class="op-hidden"><textarea class="op-le-shortcode" name="shortcode[]">{element_str}</textarea></div>'; $after_element = '<div class="element-container sort-disabled"></div> <div class="add-element-container"> <a href="#add_element" class="add-new-element"> <span>' . __('Add Element', 'optimizepress') . '</span> </a> </div>'; } $html = ''; $pref = 'le_' . $type . '_row_'; $rcounter = 1; $le = defined('OP_LIVEEDITOR'); $clear = ''; //check for default wordpress password protection global $post; if (!$le && isset($post->ID) && post_password_required($post->ID)) { $html .= '<div class="row one-column cf ui-sortable"><div class="fixed-width">'; $html .= get_the_password_form(); } else { foreach ($layout as $row) { // generating new styles from row_data_styles!!! if (!empty($row['row_data_style'])) { $rowStyle = base64_decode($row['row_data_style']); $rowStyle = json_decode($rowStyle); $row_style = $this->generateRowStyle($rowStyle); } else { $row_style = ''; $rowStyle = ''; } if (!isset($row['row_data_style'])) { $row['row_data_style'] = ''; } if (isset($rowStyle->codeBefore) and !empty($rowStyle->codeBefore)) { if ($le) { $html .= '<op-row-before class="op-row-code-before">' . htmlentities($rowStyle->codeBefore) . '</op-row-before>'; } else { $html .= $rowStyle->codeBefore; // $html .= do_shortcode($rowStyle->codeBefore); } } $html .= ' <div ' . $row_style . ' class="' . $row['row_class'] . '" id="' . $pref . $rcounter . '" data-style="' . $row['row_data_style'] . '">'; $html .= apply_filters('op_inside_row', $rowStyle); $html .= ' <div class="fixed-width">' . $row_start; $ccounter = 1; foreach ($row['children'] as $col) { //do we split or not switch ($col['col_class']) { case 'one-half column cols': case 'two-thirds column cols': case 'two-fourths column cols': case 'three-fourths column cols': case 'three-fifths column cols': case 'four-fifths column cols': $td = substr($col['col_class'], 0, -12); $splitColumns = '<a href="#' . $td . '" class="split-column"></a>'; break; default: $splitColumns = ''; break; } if (is_admin()) { $col_end = '<div class="element-container sort-disabled"></div> <div class="add-element-container">' . $splitColumns . '<a href="#add_element" class="add-new-element"><span>' . __('Add Element', 'optimizepress') . '</span></a> </div>'; } $html .= '<div class="' . $col['col_class'] . '" id="' . $pref . $rcounter . '_col_' . $ccounter . '">' . $col_start; if (!empty($col['children']) and count($col['children'])) { $ecounter = 1; $elNumber = 1; $subcolNumber = 100; $subcolumn = false; $nrChildren = count($col['children']); $previous = ''; $subcounter = 0; $fullWidth = 0; foreach ($col['children'] as $child) { $flag = false; if ($child['type'] != $previous && $previous != '') { $flag = true; } if ($ecounter == $nrChildren && $subcolumn === true && $child['type'] != 'element') { $clear .= '<div class="clearcol"></div>'; $subcolumn = false; } else { $clear = ''; } switch ($child['type']) { case 'element': if ($subcolumn === true) { $html .= '<div class="clearcol"></div>'; $subcolumn = false; $flag = false; } $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 0; $GLOBALS['OP_PARSED_SHORTCODE'] = ''; $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array(); $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = false; $sc = op_fix_embed_url_shortcodes(stripslashes($child['object'])); // removing new line before shortcode entered in content // commented out if() was for testing - custom html element is not behaving properly with this on // if (strpos($sc, '[custom_html') === false) { $sc = str_replace(array("\n[", "\r[", "\r\n[", "\n\r["), array("[", "[", "[", "["), $sc); // } $child = apply_filters('op_element_advanced_options', $child); // getting and processing before and after elements $elemBefore = ''; $elemAfter = ''; if (empty($child['element_class'])) { $elClass = 'element-container cf'; } else { $elClass = $child['element_class']; } if (!empty($child['element_data_style'])) { $elementStyle = base64_decode($child['element_data_style']); $elementStyle = json_decode($elementStyle); if (!empty($elementStyle->codeBefore)) { $elemBefore = $elementStyle->codeBefore; } if (!empty($elementStyle->codeAfter)) { $elemAfter = $elementStyle->codeAfter; } if (!empty($elementStyle->fadeIn)) { $data_fade = ' data-fade="' . $elementStyle->fadeIn . '" style="display:none;" '; } else { $data_fade = ' '; } $elementDataStyle = $child['element_data_style']; } else { $elemBefore = ' '; $elemAfter = ' '; $data_fade = ' '; $elementDataStyle = ''; } if (strpos($sc, '[op_popup ') !== false) { $op_popup_present = true; } else { $op_popup_present = false; } // $html .= '<div class="'.$elClass.'"'.$data_fade.'data-style="'.$elementDataStyle.'" id="'.$pref.$rcounter.'_col_'.$ccounter.'_el_'.$elNumber.'">'.$element_start; $new_element_start = $element_start; if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches) || $op_popup_present) { /* Make sure $matches[0] is set to avoid PHP notices */ if (!isset($matches[0])) { $matches[0] = null; } $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = true; $sc = str_replace($matches[0], '#OP_CHILD_ELEMENTS#', $sc); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 1; $child_data = op_page_parse_child_elements($matches[0]); $matches[0] = $child_data['liveeditorElements']; $processed = op_process_content_filter($sc, true); $child_html = op_page_parse_child_row($matches[0]); if ($op_popup_present) { $new_popup_elements = ''; $new_popup_elements_sc = ''; preg_match_all('/\\[op_popup_content_element[ d|\\]].*?\\[\\/op_popup_content_element\\]/is', $sc, $popup_elements); foreach ($popup_elements[0] as $popup_element) { $new_popup_elements_sc .= $popup_element; preg_match('/data-style="(.*?)"/is', $popup_element, $popup_element_data_style); $popup_data_style = op_page_parse_advanced_element_options($popup_element_data_style[1]); $popup_element = preg_replace('/\\[op_popup_content_element(.*?"?)\\]/is', '[op_liveeditor_element$1]', $popup_element); $popup_element = str_replace('[/op_popup_content_element]', '[/op_liveeditor_element]', $popup_element); $popup_element = op_process_content_filter($popup_element, true); $new_popup_elements .= '<div class="element-container op-popup-element-container ' . $popup_data_style['advancedClass'] . $popup_data_style['hideClasses'] . '"' . $popup_data_style['dataFade'] . ' data-popup-child="true">' . $popup_data_style['elemBefore'] . $popup_element . $popup_data_style['elemAfter'] . '</div>'; } //$new_popup_elements = '[op_liveeditor_elements]' . $new_popup_elements . '[/op_liveeditor_elements]'; $new_popup_elements = '<div class="op-popup-content">' . $new_popup_elements . '</div>'; $new_popup_elements .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); $new_popup_elements = str_replace('$', '\\$', $new_popup_elements); $processed = preg_replace('/\\[op_popup_content[ d|\\]].*?\\[\\/op_popup_content\\]/is', $new_popup_elements, $sc); // Parse op_popup_button // preg_match_all('/\[op_popup_button\].*?\[\/op_popup_button\]/is', $sc, $new_popup_button); preg_match_all('/\\[op_popup_button\\].*?\\[\\/op_popup_button\\]/is', str_replace('$', '\\$', $sc), $new_popup_button); $new_popup_button = $new_popup_button[0][0]; $new_popup_button = str_replace('[op_popup_button]', '', $new_popup_button); $new_popup_button = str_replace('[/op_popup_button]', '', $new_popup_button); $new_popup_button = op_process_content_filter($new_popup_button, true); $new_popup_button = '<div class="op-popup-button ' . $popup_button_class . '">' . $new_popup_button . '</div>'; $processed = op_process_content_filter($processed, true); $new_popup_button = str_replace('$', '\\$', $new_popup_button); $processed = preg_replace('/\\[op_popup_button\\].*?\\[\\/op_popup_button\\]/is', $new_popup_button, $processed); // $processed = str_replace('[op_popup_button]', '<div class="op-popup-button ' . $popup_button_class . '">', $processed); // $processed = str_replace('[/op_popup_button]', '</div>', $processed); // when textarea is added into custom html element insisde overlay optimizer, it breaks the op-hidden textarea // this below fixes it (blame Zvonko for any problems) // if (false !== strpos($new_popup_elements_sc, 'textarea')) { // $new_popup_elements_sc = htmlentities($new_popup_elements_sc, ENT_QUOTES); // } $processed .= $le ? '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop('[op_popup_elements]' . $new_popup_elements_sc . '[/op_popup_elements]')) . '</textarea></div>' : ''; } if (!$op_popup_present) { /** * At the end of child elements "add element" button must * be inserted, which is done by parsing [op_liveeditor_elements] shortcode */ $child_html .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); $child_html = op_process_asset_content($child_html) . ($le ? '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop($matches[0])) . '</textarea></div>' : ''); /* * $ needs to be escaped */ $child_html = str_replace('$', '\\$', $child_html); $processed = preg_replace(array('{<p[^>]*>\\s*#OP_CHILD_ELEMENTS#\\s*<\\/p>}i', '{#OP_CHILD_ELEMENTS#}i'), $child_html, $processed); } if (defined('OP_LIVEEDITOR')) { $new_element_start = substr($element_start, 0, 30) . '<a class="element-parent-settings" href="#parent-settings">' . __('Edit Parent Element', 'optimizepress') . '</a>' . substr($element_start, 30); } } else { $processed = op_process_content_filter($sc, true); } if (strpos($sc, '[op_popup ') !== false && defined('OP_LIVEEDITOR')) { $new_element_start = substr($element_start, 0, 30) . '<a class="element-parent-settings" href="#parent-settings">' . __('Edit Parent Element', 'optimizepress') . '</a>' . substr($element_start, 30); } $html .= '<div class="' . $elClass . '"' . $data_fade . 'data-style="' . $elementDataStyle . '" id="' . $pref . $rcounter . '_col_' . $ccounter . '_el_' . $elNumber . '">' . $new_element_start; //$html .= $elemBefore .'<div class="element">' . $processed . '</div>' . $elemAfter; if (!is_admin()) { $content = do_shortcode($elemBefore . '###OP_ELEM_PROCESSED###' . $elemAfter); $content = str_replace('###OP_ELEM_PROCESSED###', $processed, $content); } else { $content = $elemBefore . $processed . $elemAfter; } // if (!is_admin() && !$op_popup_present) { // $content = do_shortcode($content); // } $elementNumberClass = strrpos($content, 'page-listing three-col') !== false ? ' element-three-col' : ''; $elementNumberClass .= strrpos($content, 'page-listing four-col') !== false ? ' element-four-col' : ''; $html .= '<div class="element' . $elementNumberClass . '">' . $content . '</div>'; if (isset($GLOBALS['OP_PARSED_SHORTCODE']) && !empty($GLOBALS['OP_PARSED_SHORTCODE'])) { $sc = $GLOBALS['OP_PARSED_SHORTCODE']; } $html .= str_replace('{element_str}', op_attr($sc), $element_end) . '</div>'; if ($flag && $ecounter < $nrChildren) { $html .= $after_element; } $elNumber++; $previous = 'element'; break; case 'subcolumn': if ($previous == '') { $html .= $after_element; } if ($flag == true) { $html .= $after_element; } $temp = explode(' ', $child['subcol_class']); if (!$flag && ($fullWidth == 1 || $fullWidth == 0.99)) { $html .= '<div class="clearcol"></div>' . $after_element; $fullWidth = 0; } $subcolumn = true; $html .= '<div class="' . $child['subcol_class'] . '" id="' . $pref . $rcounter . '_col_' . $subcolNumber . '">' . $subcol_start; if (!empty($child['children']) and count($child['children']) > 0) { //elements $elNumber = 1; foreach ($child['children'] as $kid) { $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 0; $GLOBALS['OP_PARSED_SHORTCODE'] = ''; $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array(); $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = false; $sc = op_fix_embed_url_shortcodes(stripslashes($kid['object'])); // removing new line before shortcode entered in content $sc = str_replace(array("\n[", "\r[", "\r\n[", "\n\r["), array("[", "[", "[", "["), $sc); // getting and processing before and after elements $elemBefore = ''; $elemAfter = ''; if (empty($kid['element_class'])) { $elClass = 'element-container cf'; } else { $elClass = $kid['element_class']; } $kidElementDataStyle = $kid['element_data_style']; $elementDataStyle = op_page_parse_advanced_element_options($kid['element_data_style']); if (strpos($sc, '[op_popup ') !== false) { $op_popup_present = true; } else { $op_popup_present = false; } // $html .= '<div class="'.$elClass.'"'.$data_fade.'data-style="'.$elementDataStyle.'" id="'.$pref.$rcounter.'_col_'.$subcolNumber.'_el_'.$elNumber.'">'.$element_start; $new_element_start = $element_start; if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches) || $op_popup_present) { $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = true; $sc = str_replace($matches[0], '#OP_CHILD_ELEMENTS#', $sc); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 1; $child_data = op_page_parse_child_elements($matches[0]); $matches[0] = $child_data['liveeditorElements']; $processed = op_process_content_filter($sc, true); $child_html = op_page_parse_child_row($matches[0]); if ($op_popup_present) { $new_popup_elements = ''; $new_popup_elements_sc = ''; preg_match_all('/\\[op_popup_content_element[ d|\\]].*?\\[\\/op_popup_content_element\\]/is', $sc, $popup_elements); foreach ($popup_elements[0] as $popup_element) { $new_popup_elements_sc .= $popup_element; // $popup_element = str_replace('[op_popup_content_element]', '[op_liveeditor_element]', $popup_element); preg_match('/data-style="(.*?)"/is', $popup_element, $popup_element_data_style); $popup_data_style = op_page_parse_advanced_element_options($popup_element_data_style[1]); $popup_element = preg_replace('/\\[op_popup_content_element(.*?"?)\\]/is', '[op_liveeditor_element$1]', $popup_element); $popup_element = str_replace('[/op_popup_content_element]', '[/op_liveeditor_element]', $popup_element); $popup_element = op_process_content_filter($popup_element, true); // $new_popup_elements .= $popup_element; $new_popup_elements .= '<div class="element-container op-popup-element-container ' . $popup_data_style['advancedClass'] . $popup_data_style['hideClasses'] . '"' . $popup_data_style['dataFade'] . ' data-popup-child="true">' . $popup_data_style['elemBefore'] . $popup_element . $popup_data_style['elemAfter'] . '</div>'; } $new_popup_elements = str_replace('$', '\\$', $new_popup_elements); $new_popup_elements = '<div class="op-popup-content">' . $new_popup_elements . '</div>'; $new_popup_elements .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); $processed = preg_replace('/\\[op_popup_content[ d|\\]].*?\\[\\/op_popup_content\\]/is', $new_popup_elements, $sc); // Parse op_popup_button preg_match_all('/\\[op_popup_button\\].*?\\[\\/op_popup_button\\]/is', str_replace('$', '\\$', $sc), $new_popup_button); $new_popup_button = $new_popup_button[0][0]; $new_popup_button = str_replace('[op_popup_button]', '', $new_popup_button); $new_popup_button = str_replace('[/op_popup_button]', '', $new_popup_button); $new_popup_button = op_process_content_filter($new_popup_button, true); $new_popup_button = '<div class="op-popup-button ' . $popup_button_class . '">' . $new_popup_button . '</div>'; $processed = op_process_content_filter($processed, true); $new_popup_button = str_replace('$', '\\$', $new_popup_button); $processed = preg_replace('/\\[op_popup_button\\].*?\\[\\/op_popup_button\\]/is', $new_popup_button, $processed); // $processed = str_replace('[op_popup_button]', '<div class="op-popup-button ' . $popup_button_class . '">', $processed); // $processed = str_replace('[/op_popup_button]', '</div>', $processed); $processed .= $le ? '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop('[op_popup_elements]' . $new_popup_elements_sc . '[/op_popup_elements]')) . '</textarea></div>' : ''; } if (!$op_popup_present) { /** * At the end of child elements "add element" button must * be inserted, which is done by parsing [op_liveeditor_elements] shortcode */ $child_html .= op_process_content_filter('[op_liveeditor_elements][/op_liveeditor_elements]', true); $child_html = op_process_asset_content($child_html) . ($le ? '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop($matches[0])) . '</textarea></div>' : ''); /* * $ needs to be escaped */ $child_html = str_replace('$', '\\$', $child_html); $processed = preg_replace(array('{<p[^>]*>\\s*#OP_CHILD_ELEMENTS#\\s*<\\/p>}i', '{#OP_CHILD_ELEMENTS#}i'), $child_html, $processed); } if (defined('OP_LIVEEDITOR')) { $new_element_start = substr($element_start, 0, 30) . '<a class="element-parent-settings" href="#parent-settings">' . __('Edit Parent Element', 'optimizepress') . '</a>' . substr($element_start, 30); } } else { // $processed = apply_filters('the_content',$sc); $processed = op_process_content_filter($sc, true); } if (strpos($sc, '[op_popup ') !== false && defined('OP_LIVEEDITOR')) { $new_element_start = substr($element_start, 0, 30) . '<a class="element-parent-settings" href="#parent-settings">' . __('Edit Parent Element', 'optimizepress') . '</a>' . substr($element_start, 30); } $html .= '<div class="' . $elClass . $elementDataStyle['hideClasses'] . '"' . $elementDataStyle['dataFade'] . 'data-style="' . $kidElementDataStyle . '" id="' . $pref . $rcounter . '_col_' . $subcolNumber . '_el_' . $elNumber . '">' . $new_element_start; if (!is_admin()) { $content = do_shortcode($elementDataStyle['elemBefore'] . '###OP_ELEM_PROCESSED###' . $elementDataStyle['elemAfter']); $content = str_replace('###OP_ELEM_PROCESSED###', $processed, $content); } else { $content = $elementDataStyle['elemBefore'] . $processed . $elementDataStyle['elemAfter']; } // if (!is_admin()) { // $content = do_shortcode($content); // } $html .= '<div class="element">' . $content . '</div>'; if (isset($GLOBALS['OP_PARSED_SHORTCODE']) && !empty($GLOBALS['OP_PARSED_SHORTCODE'])) { $sc = $GLOBALS['OP_PARSED_SHORTCODE']; } $html .= str_replace('{element_str}', op_attr($sc), $element_end) . '</div>'; $previous = 'element'; $elNumber++; } $html .= $after_element; $subcolNumber++; } else { $html .= $after_element; } $html .= $subcol_end . '</div>'; $next = next($child['children']); $html .= $clear; $previous = 'subcolumn'; $subcounter++; $fullWidth += $measures[$temp[0]]; break; } $ecounter++; } } $ccounter++; $html .= $col_end . '</div>'; } $html .= $row_end . '</div></div>'; if (isset($rowStyle->codeAfter) and !empty($rowStyle->codeAfter)) { if ($le) { $html .= '<op-row-after class="op-row-code-after">' . htmlentities($rowStyle->codeAfter) . '</op-row-after>'; } else { $html .= $rowStyle->codeAfter; // $html .= do_shortcode($rowStyle->codeAfter); } } $rcounter++; } // end row foreach } // end else $this->revert_disabled_filters(); // return normal content in LE, but parse shortcodes on frontend to deal with code before and after rows! if ($le) { return $html; } else { return do_shortcode($html); } }