function liveeditor_elements($atts, $content = '') { $newcontent = $content; if (defined('OP_AJAX_SHORTCODE') && isset($GLOBALS['OP_LIVEEDITOR_DEPTH']) && $GLOBALS['OP_LIVEEDITOR_DEPTH'] === 1 && $GLOBALS['OP_ADD_ELEMENT_ROWS'] === true) { $mc = preg_match_all('/' . op_shortcode_regex('op_liveeditor_element') . '/s', $content, $matches); $new_content = ''; if ($mc > 0) { for ($i = 0; $i < $mc; $i++) { $sc = op_clean_shortcode_content($matches[5][$i]); $new_content .= '<div class="row element-container cf"><div class="op-element-links"><a class="element-settings" href="#settings"><img alt="' . __('Edit Element', OP_SN) . '" title="' . __('Edit Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-advanced" href="#op-le-advanced"><img alt="' . __('Advanced Element Options', OP_SN) . '" title="' . __('Advanced Element Options', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-move" href="#move"><img alt="' . __('Move', OP_SN) . '" src="' . OP_IMG . 'move-icon.png" /></a><a class="element-delete" href="#delete"><img alt="' . __('Remove Element', OP_SN) . '" src="' . OP_IMG . 'remove-row.png" /></a></div><div class="op-hidden op-waiting"><img class="op-bsw-waiting op-show-waiting" alt="" src="images/wpspin_light.gif" /></div><div class="element">' . do_shortcode(shortcode_unautop(wpautop($sc))) . '</div><div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(trim(shortcode_unautop($sc))) . '</textarea></div></div>'; } } return $new_content; } $newcontent = do_shortcode(op_clean_shortcode_content($content)) . (defined('OP_LIVEEDITOR') ? '<a href="#add_element" class="add-new-element"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '"><span>' . __('Add Element', OP_SN) . '</span></a>' : ''); return $newcontent; }
function generate_layout($layout, $type, $one_col = false) { $this->remove_disabled_filters(); $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())))); } $row_start = $one_col ? '' : '<div class="op-row-links"><a href="#options" class="edit-row" id="row_options"></a><a href="#move" class="move-row"></a><a href="#add-new-row" class="add-new-row"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add New Row', OP_SN) . '" /><span>' . __('Add New Row', OP_SN) . '</span></a><a href="#delete-row" class="delete-row"></a></div>'; $row_end = ''; $col_start = $subcol_start = ''; //<div class="op-col-links"><a class="move-col" href="#move"><img alt="'.__('Move',OP_SN).'" 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"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '" /><span>' . __('Add Element', OP_SN) . '</span></a></div>'; $element_start = '<div class="op-element-links"><a class="element-settings" href="#settings"><img alt="' . __('Edit Element', OP_SN) . '" title="' . __('Edit Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /><a class="element-advanced" href="#op-le-advanced"><img alt="' . __('Advanced Element Options', OP_SN) . '" title="' . __('Advanced Element Options', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-move" href="#move"><img alt="' . __('Move', OP_SN) . '" src="' . OP_IMG . 'move-icon.png" /></a><a class="element-delete" href="#delete"><img alt="' . __('Remove Element', OP_SN) . '" src="' . OP_IMG . 'remove-row.png" /></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"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '" /><span>' . __('Add Element', OP_SN) . '</span></a></div>'; } $html = ''; $pref = 'le_' . $type . '_row_'; $rcounter = 1; $le = defined('OP_LIVEEDITOR'); foreach ($layout as $row) { /*if (!empty($row['row_style'])) { $row_style = "style='" . stripslashes($row['row_style']) . "' "; } else { $row_style = ''; }*/ // 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 = ''; } if (!isset($row['row_data_style'])) { $row['row_data_style'] = ''; } $html .= ' <div ' . $row_style . ' class="' . $row['row_class'] . '" id="' . $pref . $rcounter . '" data-style="' . $row['row_data_style'] . '"><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"><img src="' . OP_IMG . 'live_editor/split_column.png" alt="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"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '" /><span>' . __('Add Element', OP_SN) . '</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'])); // 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 . '" '; } else { $data_fade = ' '; } $elementDataStyle = $child['element_data_style']; } else { $elemBefore = ' '; $elemAfter = ' '; $data_fade = ' '; $elementDataStyle = ''; } $html .= '<div class="' . $elClass . '"' . $data_fade . 'data-style="' . $elementDataStyle . '" id="' . $pref . $rcounter . '_col_' . $ccounter . '_el_' . $elNumber . '">' . $element_start; if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches)) { $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = true; $sc = str_replace($matches[0], '#OP_CHILD_ELEMENTS#', $sc); $processed = apply_filters('the_content', $sc); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 1; $child_html = op_process_asset_content(apply_filters('the_content', $matches[0])) . ($le ? '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop($matches[0])) . '</textarea></div>' : ''); $processed = preg_replace(array('{<p[^>]*>\\s*#OP_CHILD_ELEMENTS#\\s*<\\/p>}i', '{#OP_CHILD_ELEMENTS#}i'), $child_html, $processed); } else { $processed = apply_filters('the_content', $sc); } //$html .= $elemBefore .'<div class="element">' . $processed . '</div>' . $elemAfter; $content = $elemBefore . $processed . $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>'; 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'])); // getting and processing before and after elements $elemBefore = ''; $elemAfter = ''; if (empty($kid['element_class'])) { $elClass = 'element-container cf'; } else { $elClass = $kid['element_class']; } if (!empty($kid['element_data_style'])) { $elementStyle = base64_decode($kid['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 . '" '; } else { $data_fade = ''; } $elementDataStyle = $kid['element_data_style']; } else { $elemBefore = ' '; $elemAfter = ' '; $data_fade = ' '; $elementDataStyle = ''; } $html .= '<div class="' . $elClass . '"' . $data_fade . 'data-style="' . $elementDataStyle . '" id="' . $pref . $rcounter . '_col_' . $subcolNumber . '_el_' . $elNumber . '">' . $element_start; if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches)) { $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = true; $sc = str_replace($matches[0], '#OP_CHILD_ELEMENTS#', $sc); $processed = apply_filters('the_content', $sc); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 1; $child_html = op_process_asset_content(apply_filters('the_content', $matches[0])) . ($le ? '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop($matches[0])) . '</textarea></div>' : ''); $processed = preg_replace(array('{<p[^>]*>\\s*#OP_CHILD_ELEMENTS#\\s*<\\/p>}i', '{#OP_CHILD_ELEMENTS#}i'), $child_html, $processed); } else { $processed = apply_filters('the_content', $sc); } //$html .= $elemBefore .'<div class="element">' . $processed . '</div>' . $elemAfter; $content = $elemBefore . $processed . $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>'; $rcounter++; } $this->revert_disabled_filters(); return $html; }
function liveeditor_elements($atts, $content = '') { $popup_child_element = false; if (strpos($content, 'op_popup_content_element') !== false) { $popup_child_element = true; $content = str_replace('[op_popup_content_element]', '', $content); $content = str_replace('[/op_popup_content_element]', '', $content); } $newcontent = $content; if (defined('OP_AJAX_SHORTCODE') && isset($GLOBALS['OP_LIVEEDITOR_DEPTH']) && $GLOBALS['OP_LIVEEDITOR_DEPTH'] === 1 && $GLOBALS['OP_ADD_ELEMENT_ROWS'] === true) { $mc = preg_match_all('/' . op_shortcode_regex('op_liveeditor_element') . '/s', $content, $matches); $new_content = ''; if ($mc > 0) { for ($i = 0; $i < $mc; $i++) { $sc = op_clean_shortcode_content($matches[5][$i]); /* * If it is one of the elements that can have children we'll show "parent settings" button */ if (strpos($sc, 'feature_box') === 1 || strpos($sc, 'feature_box_creator') === 1 || strpos($sc, 'order_box') === 1 || strpos($sc, 'content_toggle') === 1 || strpos($sc, 'delayed_content') === 1 || strpos($sc, 'terms_conditions') === 1 || strpos($sc, 'op_popup')) { $new_content .= '<div class="row element-container cf"><div class="op-element-links"><a class="element-parent-settings" href="#parent-settings"><img alt="' . esc_attr__('Edit Parent Element', OP_SN) . '" title="' . esc_attr__('Edit Parent Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-settings" href="#settings"><img alt="' . esc_attr__('Edit Element', OP_SN) . '" title="' . __('Edit Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-clone" href="#clone-element"><img alt="' . esc_attr__('Clone Element', OP_SN) . '" title="' . esc_attr__('Clone Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-advanced" href="#op-le-advanced"><img alt="' . __('Advanced Element Options', OP_SN) . '" title="' . __('Advanced Element Options', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-move" href="#move"><img alt="' . __('Move', OP_SN) . '" src="' . OP_IMG . 'move-icon.png" /></a><a class="element-delete" href="#delete"><img alt="' . __('Remove Element', OP_SN) . '" src="' . OP_IMG . 'remove-row.png" /></a></div><div class="op-hidden op-waiting"><img class="op-bsw-waiting op-show-waiting" alt="" src="images/wpspin_light.gif" /></div><div class="element">' . op_do_shortcode($sc) . '</div><div class="op-hidden"><textarea class="op-le-child-shortcode" kz="des" name="shortcode[]">' . op_attr(trim(shortcode_unautop($sc))) . '</textarea></div></div>'; } else { $m_child_data_style = ''; preg_match('/data-style="(.*?)"{1}/i', $matches[0][$i], $m_child_data_style); $childDataStyle = ''; $childElemBefore = ''; $childElemAfter = ''; if ($m_child_data_style[1]) { $childDataStyle = $m_child_data_style[1]; $childElementStyle = base64_decode($m_child_data_style[1]); $childElementStyle = json_decode($childElementStyle); if (!empty($childElementStyle->codeBefore)) { $childElemBefore = $childElementStyle->codeBefore; } else { $childElemBefore = ''; } if (!empty($childElementStyle->codeAfter)) { $childElemAfter = $childElementStyle->codeAfter; } else { $childElemAfter = ''; } if (!empty($childElementStyle->fadeIn)) { $child_data_fade = ' data-fade="' . $childElementStyle->fadeIn . '"'; $child_data_fade .= defined('OP_LIVEEDITOR') ? '' : ' style="display:none;" '; } else { $child_data_fade = ' '; } if (!empty($childElementStyle->advancedClass)) { $childAdvancedClass = $childElementStyle->advancedClass; } else { $childAdvancedClass = ''; } $hideClasses = $childElementStyle->hideMobile ? ' hide-mobile' : ''; $hideClasses .= $childElementStyle->hideTablet ? ' hide-tablet' : ''; } $sc_processed = op_do_shortcode($sc); $sc_processed = $childElemBefore . $sc_processed . $childElemAfter; if ($popup_child_element) { $sc = '###OP_POPUP_CONTENT_CHILDREN###'; } $new_content .= '<div class="row element-container cf ' . $childAdvancedClass . $hideClasses . '" data-style="' . $childDataStyle . '"' . $child_data_fade . '><div class="op-element-links"><a class="element-settings" href="#settings"><img alt="' . esc_attr__('Edit Element', OP_SN) . '" title="' . esc_attr__('Edit Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-clone" href="#clone-element"><img alt="' . esc_attr__('Clone Element', OP_SN) . '" title="' . esc_attr__('Clone Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-advanced" href="#op-le-advanced"><img alt="' . __('Advanced Element Options', OP_SN) . '" title="' . __('Advanced Element Options', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-move" href="#move"><img alt="' . __('Move', OP_SN) . '" src="' . OP_IMG . 'move-icon.png" /></a><a class="element-delete" href="#delete"><img alt="' . __('Remove Element', OP_SN) . '" src="' . OP_IMG . 'remove-row.png" /></a></div><div class="op-hidden op-waiting"><img class="op-bsw-waiting op-show-waiting" alt="" src="images/wpspin_light.gif" /></div><div class="element">' . $sc_processed . '</div><div class="op-hidden"><textarea class="op-le-child-shortcode" dww="nm" name="shortcode[]">' . op_attr(trim(shortcode_unautop($sc))) . '</textarea></div></div>'; } } } return $new_content; } $newcontent = op_do_shortcode(op_clean_shortcode_content($content)) . (defined('OP_LIVEEDITOR') ? '<a href="#add_element" class="add-new-element"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '"><span>' . __('Add Element', OP_SN) . '</span></a>' : ''); return $newcontent; }
static function two_column_block($atts, $content = '') { $chks = array('content1', 'content2'); foreach ($chks as $chk) { ${$chk} = ''; if (preg_match('/' . op_shortcode_regex($chk) . '/s', $content, $matches)) { ${$chk} = apply_filters('the_content', $matches[5]); } } return ' <div class="double-column cf"> <div class="col-left">' . wpautop($content1) . '</div> <div class="col-right">' . wpautop($content2) . '</div> </div>'; }
function export_layout() { global $wpdb; $error = null; if (!class_exists('ZipArchive')) { exit(json_encode(array('error' => __('You must have ZipArchive enabled on your server to complete the operation.', OP_SN)))); } if (!($layout_name = op_post('layout_name'))) { exit(json_encode(array('error' => __('Please supply a name for your layout', OP_SN)))); } if (!($layout_description = op_post('layout_description'))) { exit(json_encode(array('error' => __('Please supply a description for your layout', OP_SN)))); } if (!($image = op_post('image')) || !file_exists($image)) { exit(json_encode(array('error' => __('Please supply an image for your layout', OP_SN)))); } if (!($layout_category = op_post('layout_category'))) { exit(json_encode(array('error' => __('Please supply a category for your layout', OP_SN)))); } else { $layout_category = $wpdb->get_var($wpdb->prepare("SELECT name FROM `{$wpdb->prefix}optimizepress_layout_categories` WHERE `id` = %d", $layout_category)); } $this->save_page(); $settings = apply_filters('op_export_settings_array', array('membership', 'theme', 'header_layout', 'feature_area', 'feature_title', 'footer_area', 'color_scheme_template', 'typography', 'color_scheme_advanced', 'mobile_redirect', 'seo', 'scripts', 'fb_share', 'lightbox', 'exit_redirect', 'launch_gateway', 'launch_funnel', 'size_color', 'landing_bg')); $layouts = op_post('layouts'); if (!is_array($layouts)) { $layouts = array(); } $layouts = array_keys($layouts); $config_str = '<?php'; $image_filename = basename($image); $vars = array('name', 'description', 'category'); foreach ($vars as $var) { $value = 'layout_' . $var; $value = ${$value}; $value = str_replace(array('�', '’', '”', '“', "'"), array("'", "'", '"', '"', "\\'"), stripslashes($value)); $config_str .= ' $config[\'' . $var . '\'] = \'' . $value . '\';'; } $config_str .= ' $config[\'image\'] = \'' . str_replace("'", "\\'", $image_filename) . '\'; $config[\'settings\'] = array(); $config[\'layouts\'] = array(); '; $url = site_url('/'); if (preg_match('{(http|https)://(www.)?(.*?)$}i', $url, $matches)) { $url = $matches[3]; } $imgregex = '{(["\']*)(http|https)://(www.)?' . $url . '(.*?)(\\.[gif|png|jpg|jpeg]+)[*\\1]*\\1}i'; foreach ($settings as $setting) { $conf = op_page_option($setting); if (is_array($conf)) { $conf = $this->_check_for_images($imgregex, $conf, array($setting)); } $config_str .= "\$config['settings']['" . $setting . "'] = '" . base64_encode(serialize($conf)) . "';\n"; } $tags = op_assets_parse_list(); $regex = op_shortcode_regex(join('|', array_map('preg_quote', array_keys($tags)))); $images = array(); $assets = array(); $new_layouts = array(); foreach ($layouts as $layout_str) { $layout = op_page_layout($layout_str, true); $new_layout = array(); /**/ foreach ($layout as $row) { $row_image_match = preg_match_all($imgregex, $row['row_style'], $matches); if ($row_image_match > 0) { for ($i = 0; $i < $row_image_match; $i++) { $path = $matches[4][$i] . $matches[5][$i]; $row['row_style'] = str_replace(trim($matches[0][$i], $matches[1][$i]), '{op_filename="' . $path . '"}', $row['row_style']); $temp = base64_decode($row['row_data_style']); $temp = str_replace(trim($matches[0][$i], $matches[1][$i]), '{op_filename=\\"' . $path . '\\"}', $temp); $row['row_data_style'] = base64_encode($temp); $this->zip_images[$path] = trim($matches[0][$i], '"'); } } $new_row = array('row_class' => $row['row_class'], 'row_style' => $row['row_style'], 'row_data_style' => $row['row_data_style'], 'children' => array()); if (isset($row['children']) && count($row['children']) > 0) { foreach ($row['children'] as $col) { $new_col = array('col_class' => $col['col_class'], 'children' => array()); if (!empty($col['children']) && count($col['children']) > 0) { foreach ($col['children'] as $child) { switch ($child['type']) { case 'subcolumn': $subcol['type'] = 'subcolumn'; $subcol['subcol_class'] = $child['subcol_class']; $subcol['children'] = array(); if (!empty($child['children']) && count($child['children']) > 0) { $nr = 0; foreach ($child['children'] as $kid) { $subcol['children'][$nr]['type'] = 'element'; $sc = trim(stripslashes($kid['object'])); $mc = preg_match_all($imgregex, $sc, $matches); if ($mc > 0) { for ($i = 0; $i < $mc; $i++) { $path = $matches[4][$i] . $matches[5][$i]; $sc = str_replace(trim($matches[0][$i], $matches[1][$i]), '{op_filename="' . $path . '"}', $sc); $this->zip_images[$path] = trim($matches[0][$i], '"'); } } $child_sc = ''; if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches)) { $child_sc = $matches[0]; $assets = array_merge($assets, $this->_check_tags($child_sc, $regex, $tags)); $sc = str_replace($child_sc, '#OP_CHILD_ELEMENTS#', $sc); } $assets = array_merge($assets, $this->_check_tags($sc, $regex, $tags)); $sc = str_replace(OP_ASSETS_URL, '#OP_ASSETS_URL#', $sc); $sc = str_replace('#OP_CHILD_ELEMENTS#', $child_sc, $sc); //$element['object'] = str_replace('$', '$', addslashes(stripslashes($sc))); $subcol['children'][$nr]['object'] = $sc; $subcol['children'][$nr]['element_class'] = $kid['element_class']; $subcol['children'][$nr]['element_data_style'] = $kid['element_data_style']; $nr++; } } $new_col['children'][] = $subcol; break; case 'element': $element['type'] = 'element'; $sc = trim(stripslashes($child['object'])); $mc = preg_match_all($imgregex, $sc, $matches); if ($mc > 0) { for ($i = 0; $i < $mc; $i++) { $path = $matches[4][$i] . $matches[5][$i]; $sc = str_replace(trim($matches[0][$i], $matches[1][$i]), '{op_filename="' . $path . '"}', $sc); $this->zip_images[$path] = trim($matches[0][$i], '"'); } } $child_sc = ''; if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches)) { $child_sc = $matches[0]; $assets = array_merge($assets, $this->_check_tags($child_sc, $regex, $tags)); $sc = str_replace($child_sc, '#OP_CHILD_ELEMENTS#', $sc); } $assets = array_merge($assets, $this->_check_tags($sc, $regex, $tags)); $sc = str_replace(OP_ASSETS_URL, '#OP_ASSETS_URL#', $sc); $sc = str_replace('#OP_CHILD_ELEMENTS#', $child_sc, $sc); //$element['object'] = str_replace('$', '$', addslashes(stripslashes($sc))); $element['object'] = $sc; $element['element_class'] = $child['element_class']; $element['element_data_style'] = $child['element_data_style']; $new_col['children'][] = $element; break; } } } $new_row['children'][] = $new_col; } } $new_layout[] = $new_row; } /**/ $new_layouts[$layout_str] = $new_layout; } $dirname = md5($layout_name); if (!file_exists(OP_LIB . 'content_layouts/export')) { mkdir(OP_LIB . 'content_layouts/export'); } $dir_base = OP_LIB . 'content_layouts/export'; $full_dir = $dir_base . '/' . $dirname; $tmpdirname = $dirname; $counter = 0; while (file_exists($full_dir)) { $counter++; $tmpdirname = $dirname . ($counter > 0 ? '-' . $counter : ''); $full_dir = $dir_base . '/' . $tmpdirname; } mkdir($full_dir); $filename = preg_replace(array('/\\s+/', '/[^a-zA-Z0-9\\_]/', '/_{2,}/'), array('_', '', '_'), $layout_name); $zip = new ZipArchive(); $zip->open($full_dir . '/' . $filename . '.zip', ZIPARCHIVE::CREATE); $zip->addFile(dirname($image) . DIRECTORY_SEPARATOR . $image_filename, $image_filename); $zip->addEmptyDir('images'); $added_images = array(); $new_images = array(); foreach ($this->zip_images as $path => $url) { $file = basename($path); $new_filename = $file; if (isset($added_images[$file])) { $f = explode('.', $file); $ext = array_pop($f); $f = implode('.', $f); $counter = 1; while (isset($added_images[$new_filename])) { $new_filename = $f . $counter . '.' . $ext; $counter++; } } $new_images[$path] = $new_filename; $added_images[$new_filename] = true; if (file_exists(ABSPATH . $path)) { $zip->addFile(ABSPATH . $path, 'images/' . $new_filename); } } $config_str .= "\$config['layouts'] = '" . base64_encode(serialize($new_layouts)) . "';\n"; $config_str .= "\$config['images'] = '" . base64_encode(serialize($new_images)) . "';\n"; $config_str .= "\$config['settings_images'] = '" . base64_encode(serialize($this->used_images)) . "';\n"; $zip->addFromString('config.php', $config_str); if (count($assets) > 0) { $assets = array_keys($assets); $file_list = array(); foreach ($assets as $asset) { $file_list = array_merge($file_list, op_asset_file_list($asset)); } foreach ($file_list as $local => $zipname) { if (file_exists($local)) { $zip->addFile($local, $zipname); } } } $zip->close(); $out = array('output' => '<a style="color: #2e82bc !important; font-sze:15px !important;" href="' . OP_LIB_URL . 'content_layouts/export/' . $tmpdirname . '/' . $filename . '.zip">' . __('Download your layout', OP_SN) . '</a> | <a style="color: #2e82bc !important; font-sze:15px !important;" href="#delete" class="delete-file">' . __('Delete File', OP_SN) . '</a><input type="hidden" name="zip_filename" id="zip_filename" value="' . $full_dir . '/' . $filename . '.zip" />'); exit(json_encode($out)); }
function generate_layout($layout, $type, $one_col = false) { $this->remove_disabled_filters(); $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', OP_SN) . '" href="#copy-row" class="copy-row"></a><a title="' . __('Edit Row Options', OP_SN) . '" href="#options" class="edit-row" id="row_options"></a><a title="' . __('Clone Row', OP_SN) . '" href="#clone-row" class="clone-row"></a><a href="#add-new-row" class="add-new-row"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add New Row', OP_SN) . '" /><span>' . __('Add New Row', OP_SN) . '</span></a><a title="' . __('Move Row', OP_SN) . '" href="#move" class="move-row"></a><a title="' . __('Paste Row', OP_SN) . '" href="#paste-row" class="paste-row"></a><a title="' . __('Delete Row', OP_SN) . '" 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',OP_SN).'" 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"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '" /><span>' . __('Add Element', OP_SN) . '</span></a></div>'; $element_start = '<div class="op-element-links"><a class="element-settings" href="#settings"><img alt="' . __('Edit Element', OP_SN) . '" title="' . __('Edit Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-clone" href="#clone-element"><img alt="' . esc_attr__('Clone Element', OP_SN) . '" title="' . esc_attr__('Clone Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-advanced" href="#op-le-advanced"><img alt="' . __('Advanced Element Options', OP_SN) . '" title="' . __('Advanced Element Options', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a><a class="element-move" href="#move"><img alt="' . __('Move', OP_SN) . '" src="' . OP_IMG . 'move-icon.png" /></a><a class="element-delete" href="#delete"><img alt="' . __('Remove Element', OP_SN) . '" src="' . OP_IMG . 'remove-row.png" /></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"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '" /><span>' . __('Add Element', OP_SN) . '</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 && 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"><img src="' . OP_IMG . 'live_editor/split_column.png" alt="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"><img src="' . OP_IMG . '/live_editor/add_new.png" alt="' . __('Add Element', OP_SN) . '" /><span>' . __('Add Element', OP_SN) . '</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); // } // 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) { $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 = apply_filters('the_content', $sc); $processed = op_process_content_filter($sc, true); $child_html = ''; $child_element_nr = 0; // preg_match_all('/(<div class="row.*>)(.*)<\/div>/isU', $matches[0], $child_rows_result); preg_match_all('/(<div class="row.*>)(.*)\\[\\/op_liveeditor_element\\]/isU', $matches[0], $child_rows_result); foreach ($child_rows_result[2] as $result_row) { $result_row = $result_row . '[/op_liveeditor_element]'; $child_html .= $child_rows_result[1][$child_element_nr] . op_process_content_filter($result_row) . '</div>'; $child_element_nr += 1; } 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); $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 = '[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); $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"><img alt="' . __('Edit Parent Element', OP_SN) . '" title="' . __('Edit Parent Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></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"><img alt="' . __('Edit Parent Element', OP_SN) . '" title="' . __('Edit Parent Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></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); // } $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>'; 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']; } if (!empty($kid['element_data_style'])) { $elementStyle = base64_decode($kid['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 = $kid['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_'.$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 = ''; $child_element_nr = 0; // preg_match_all('/(<div class="row.*>)(.*)<\/div>/isU', $matches[0], $child_rows_result); preg_match_all('/(<div class="row.*>)(.*)\\[\\/op_liveeditor_element\\]/isU', $matches[0], $child_rows_result); foreach ($child_rows_result[2] as $result_row) { $result_row = $result_row . '[/op_liveeditor_element]'; $child_html .= $child_rows_result[1][$child_element_nr] . op_process_content_filter($result_row) . '</div>'; $child_element_nr += 1; } 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); $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 = 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', $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); $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"><img alt="' . __('Edit Parent Element', OP_SN) . '" title="' . __('Edit Parent Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></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"><img alt="' . __('Edit Parent Element', OP_SN) . '" title="' . __('Edit Parent Element', OP_SN) . '" src="' . OP_IMG . 'pencil.png" /></a>' . substr($element_start, 30); } $html .= '<div class="' . $elClass . '"' . $data_fade . 'data-style="' . $elementDataStyle . '" id="' . $pref . $rcounter . '_col_' . $subcolNumber . '_el_' . $elNumber . '">' . $new_element_start; 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()) { // $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); } }