示例#1
0
 function liveeditor_element($atts, $content = '')
 {
     $content = op_clean_shortcode_content(op_process_content_filter($content, true));
     return $content;
 }
示例#2
0
 function _add_element_field($atts, $content, $tag = '', $prepend = '', $append = '')
 {
     global $shortcode_tags;
     //If the Live Editor is disabled, return the content with no changes, exiting the function
     if ($GLOBALS['OP_LIVEEDITOR_DISABLE_NEW']) {
         return $content;
     }
     $GLOBALS['OP_PARSED_SHORTCODE'] = $add = '';
     if (defined('OP_PAGEBUILDER')) {
         $popup_present = false;
         if (strpos($content, '[op_popup_button]') !== false) {
             $popup_present = true;
             $popup_button_class = '';
             $popup_content_class = '';
             $popup_content = $content;
             $new_popup_elements = '';
             preg_match_all('/\\[op_popup_content_element[ d|\\]].*?\\[\\/op_popup_content_element\\]/is', $content, $popup_elements);
             foreach ($popup_elements[0] as $popup_element) {
                 // $popup_element = str_replace('[op_popup_content_element]', '[op_liveeditor_element]', $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);
                 $new_popup_elements .= $popup_element;
             }
             $new_popup_elements = '[op_popup_content][op_liveeditor_elements]' . $new_popup_elements . '[/op_liveeditor_elements][/op_popup_content]';
             $new_popup_elements = str_replace('$', '\\$', $new_popup_elements);
             $content = preg_replace('/\\[op_popup_content[ d|\\]].*?\\[\\/op_popup_content\\]/is', $new_popup_elements, $content);
             $content = str_replace('[op_popup_button]', '<div class="op-popup-button ' . $popup_button_class . '">', $content);
             $content = str_replace('[/op_popup_button]', '</div>', $content);
             if (defined('OP_LIVEEDITOR')) {
                 $add_new_element_popup = '<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>';
             } else {
                 $add_new_element_popup = '';
             }
             // $content = str_replace('[op_popup_content_element]', '', $content);
             $content = preg_replace('/\\[op_popup_content_element.*?\\]/is', '', $content);
             $content = str_replace('[/op_popup_content_element]', '', $content);
             $content = str_replace('[op_popup_content]', '<div class="op-popup-content">', $content);
             $content = str_replace('[/op_popup_content]', '</div>' . $add_new_element_popup, $content);
         }
         if ($GLOBALS['OP_LIVEEDITOR_DEPTH'] == 0) {
             $tag = $tag == '' ? self::$temp_tag : $tag;
             $new_content = $content;
             if (!preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $content, $matches) && $popup_present === false) {
                 $content = trim($content);
                 if ($content == '<br />') {
                     $content = '';
                 }
                 $content = empty($content) ? ' ' : ' [op_liveeditor_element][text_block]' . $content . '[/text_block][/op_liveeditor_element] ';
                 $new_content = '[op_liveeditor_elements]' . $content . '[/op_liveeditor_elements] ';
                 $content = $new_content;
             }
             if ($popup_present) {
                 $new_content = $popup_content;
             }
             if (defined('OP_LIVEEDITOR')) {
                 $new_tag = '[' . $tag;
                 if (is_array($atts)) {
                     foreach ($atts as $name => $val) {
                         $new_tag .= ' ' . $name . '="' . $val . '"';
                     }
                 }
                 $new_tag .= ']' . $prepend . '#OP_CHILD_ELEMENTS#' . $append . '[/' . $tag . ']';
                 $GLOBALS['OP_PARSED_SHORTCODE'] = $new_tag;
                 $add = '<form class="op_child_shortcode_form" name="child_shortcode_form_' . self::$child_shortcode_form_nr . '"><div class="op-hidden"><textarea name="shortcode[]" class="op-le-child-shortcode">' . op_attr($new_content) . '</textarea></div></form>';
                 self::$child_shortcode_form_nr += 1;
             }
         }
     }
     // return apply_filters('the_content',$content).$add;
     if ($popup_present && !defined('OP_LIVEEDITOR')) {
         return $content . $add;
     } else {
         return op_process_content_filter($content, true) . $add;
     }
 }
示例#3
0
 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);
     }
 }
示例#4
0
 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;
                     $popup_element = str_replace('[op_popup_content_element]', '[op_liveeditor_element][op_popup_content_element]', $popup_element);
                     $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 = str_replace('[op_popup_content_element]', '', $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;
             preg_match_all('/(<div class="row.*>)(.*)\\[\\/op_liveeditor_element\\]/isU', $child_data['liveeditorElements'], $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, true) . '</div>';
                 $child_element_nr += 1;
             }
             // preg_match_all('/(<div class="row.*>)(.*)<\/div>/isU', $child_data['liveeditorElements'], $child_rows_result);
             // foreach($child_rows_result[2] as $result_row) {
             //     $child_html .= $child_rows_result[1][$child_element_nr] . op_process_content_filter($result_row) . '</div>';
             //     $child_element_nr += 1;
             // }
             /**
              * 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 = 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 = '<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;
 }
示例#5
0
 /**
  * Parses the child row and returns the html
  * @param $liveeditor_elements_shortcode
  * @return string elements html
  * @internal param string $matches - op_liveeditor_elements shortcode
  */
 function parse_child_row($liveeditor_elements_shortcode)
 {
     $child_html = '';
     $child_element_nr = 0;
     preg_match_all('/(<div class="row.*>)(.*)\\[\\/op_liveeditor_element\\]/isU', $liveeditor_elements_shortcode, $child_rows_result);
     foreach ($child_rows_result[2] as $result_row) {
         // Clean up the current $result_row, because a before element can be present alognside the [op_liveeditor_element]
         preg_match_all('/\\[op_liveeditor_element.+$/is', $result_row, $result_row);
         $result_row = $result_row[0][0];
         // Get the elemen data style and parse it (it's later used in html output)
         preg_match_all('/data-style="(.*?)"/is', $result_row, $currentElDataStyle);
         $currentElDataStyle = op_page_parse_advanced_element_options(@$currentElDataStyle[1][0]);
         // Regex extracts only opening op_liveeditor_element shortcode tag, so we need to ad a closing one
         $result_row = $result_row . '[/op_liveeditor_element]';
         $child_html .= $child_rows_result[1][$child_element_nr] . $currentElDataStyle['elemBefore'] . op_process_content_filter($result_row) . $currentElDataStyle['elemAfter'] . '</div>';
         $child_element_nr += 1;
     }
     return $child_html;
 }