function content_template_fb($fields, $values) { $fonts = array('title' => array(), 'content' => array()); if (isset($values[0])) { $fonts = $values[1]; $values = $values[0]; } //op_font_style_str $html = ''; op_mod('comments')->need_js = true; $button_1 = op_get_var($values, 'button_1_text'); $button_2 = op_get_var($values, 'button_2_text'); $title = op_get_var($values, 'title'); $font_str = op_font_style_str(op_get_var($fonts, 'title', array())); $html .= empty($title) ? '' : '<h2' . (!empty($font_str) ? ' style=\'' . $font_str . '\'' : '') . '>' . nl2br($title) . '</h2> '; $content = wpautop(op_get_var($values, 'content')); $font_str = op_font_style_str(op_get_var($fonts, 'content', array())); $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array('elements' => array('p', 'a'), 'style_str' => $font_str); $content = op_process_asset_content($content); $html .= $content . (empty($button_1) ? '' : ' <a class="button-style-2 button-style-2-orange" href="' . op_get_var($values, 'button_1_url') . '"><span>' . $button_1 . '</span></a>') . (empty($button_2) ? '' : ' <a class="button-style-2 button-style-2-orange" href="' . op_get_var($values, 'button_2_url') . '"><span>' . $button_2 . '</span></a>'); return $html; }
function content_fields($fields, $values) { $fonts = array(); if (isset($values[0])) { $fonts = $values[1]; $values = $values[0]; } $html = ''; $fields = $fields['fields']; foreach ($fields as $name => $settings) { $font_str = op_font_style_str(op_get_var($fonts, $name, array())); if ($font_str != '') { $font_str = ' style=\'' . $font_str . '\''; } $value = op_get_var($values, $name); $type = op_get_var($settings, 'type'); if ($type == 'textarea' || $type == 'wysiwyg') { $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array('elements' => array('p', 'a'), 'style_str' => $font_str); $value = do_shortcode(wpautop($value)); $value = op_process_asset_content($value); } elseif ($type == 'image') { $value = '<img src="' . $value . '" alt="" />'; } $values[$name] = $value; if (empty($value)) { continue; } if ($name == 'title') { $el1 = op_get_var($settings, 'element', 'h2'); $value = '<' . $el1 . $font_str . '>' . $value . '</' . $el1 . '>'; } elseif ($name == 'subtitle') { $el2 = op_get_var($settings, 'element', 'h3'); $value = '<' . $el2 . $font_str . '>' . $value . '</' . $el2 . '>'; } elseif ($name == 'link_url') { $value = ''; } elseif ($name == 'submit_button') { $value = '<a class="button-style-2 button-style-2-orange button-style-2-large" href="' . $values['link_url'] . '"><span>' . $value . '</span></a>'; } elseif ($name == 'image' && $type != 'image') { $value = '<img src="' . $value . '" alt="" />'; } if (isset($settings['wrap'])) { $html .= sprintf($settings['wrap'], $value); } else { $html .= $value; } } return $html; }
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 op_popup($atts, $content = '') { //Extract the attributes into variables extract(shortcode_atts(array('style' => '1', 'title' => '', 'letter_spacing' => '', 'width' => '', 'top_margin' => '', 'bottom_margin' => '', 'top_padding' => '', 'bottom_padding' => '', 'left_padding' => '', 'right_padding' => '', 'alignment' => '', 'popup_width' => '700', 'popup_open_effect' => 'fade', 'popup_close_effect' => 'fade', 'popup_open_speed' => 'normal', 'popup_close_speed' => 'normal', 'popup_border_size' => '0', 'popup_border_color' => '#ffffff', 'popup_padding_top' => '20', 'popup_padding_bottom' => '20', 'popup_padding_left' => '30', 'popup_padding_right' => '30'), $atts)); //Get current style $style = op_get_current_item($styles, $style); //Set up font $font = op_asset_font_style($atts, 'content_font_'); $original_font_str = $GLOBALS['OP_LIVEEDITOR_FONT_STR']; $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = !empty($font) ? array('elements' => array('p', 'a'), 'style_str' => $font) : $GLOBALS['OP_LIVEEDITOR_FONT_STR']; //Set the temporary asset tag to the feature box // self::$temp_tag = 'op_popup'; //Get content $args = func_get_args(); //Get the content for adding an element field $content = call_user_func_array(array('OptimizePress_Default_Assets', '_add_element_field'), $args); //Process content from above $content = op_process_asset_content($content); //Set the font back to the original string $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = $GLOBALS['OP_LIVEEDITOR_DEPTH'] == 1 ? $original_font_str : $GLOBALS['OP_LIVEEDITOR_FONT_STR']; //Init the block style variable $block_style = ''; //Set up attributes for the asset $chks = array('width' => 'width', 'top_margin' => 'margin-top', 'bottom_margin' => 'margin-bottom'); //Loop through each attribute foreach ($chks as $chk => $prob) { //Add attribute to the block style string $block_style .= !empty_allow_zero(${$chk}) ? $prob . ': ' . ${$chk} . 'px;' : ''; } //Add the style HTML attribute if we have styles in the block style string $block_style = !empty($block_style) ? ' style=\'' . $block_style . '\'' : $block_style; //Init the content style string $content_style = ''; //Init the attributes for the content styling $chks = array('top_padding' => 'padding-top', 'bottom_padding' => 'padding-bottom', 'left_padding' => 'padding-left', 'right_padding' => ' padding-right'); //Loop through each attribute foreach ($chks as $chk => $prob) { //Add attribute to the content style string $content_style .= !empty_allow_zero(${$chk}) ? $prob . ': ' . ${$chk} . 'px;' : ''; } //Add font to content style string $content_style .= $font; //Add the style HTML attribute if we have styles in the content style string $content_style = !empty($content_style) ? ' style=\'' . $content_style . '\'' : $content_style; if (!defined('OP_LIVEEDITOR')) { wp_enqueue_script(OP_SN . '-popup', OP_JS . 'popup' . OP_SCRIPT_DEBUG . '.js', array(OP_SN . '-noconflict-js'), OP_VERSION, true); } // fancybox options $popup_data = ' data-width="' . $popup_width . '" '; $popup_data .= ' data-open-effect="' . $popup_open_effect . '" '; $popup_data .= ' data-close-effect="' . $popup_close_effect . '" '; // $popup_data .= ' data-open-method="' . $popup_open_method . '" '; // $popup_data .= ' data-close-method="' . $popup_close_method . '" '; $popup_data .= ' data-open-speed="' . $popup_open_speed . '" '; $popup_data .= ' data-close-speed="' . $popup_close_speed . '" '; $popup_data .= ' data-border-color="' . $popup_border_color . '" '; $popup_data .= ' data-border-size="' . $popup_border_size . '" '; $popup_data .= ' data-padding-top="' . $popup_padding_top . '" '; $popup_data .= ' data-padding-bottom="' . $popup_padding_bottom . '" '; $popup_data .= ' data-padding-left="' . $popup_padding_left . '" '; $popup_data .= ' data-padding-right="' . $popup_padding_right . '" '; return '<div class="op-popup cf"' . $content_style . $popup_data . '>' . $content . '</div>'; }
/** * shortcode parsing of membership file downloads element * @param array $atts * @param string $content * @return String */ static function membership_download($atts, $content) { // Decode encoded chars $atts = op_urldecode($atts); extract(shortcode_atts(array('style' => 1), $atts)); //</editor-fold> // some preliminary checks // creating member dir if it does not exist if (!is_dir($files_dir = $GLOBALS['WS_PLUGIN__']['optimizemember']['c']['files_dir'])) { if (is_writable(dirname(c_ws_plugin__optimizemember_utils_dirs::strip_dir_app_data($files_dir)))) { mkdir($files_dir, 0777, true); } } // creating .htaccess file if it does not exist! if (is_dir($files_dir) && is_writable($files_dir)) { if (!file_exists($htaccess = $files_dir . '/.htaccess') || !apply_filters('ws_plugin__s2member_preserve_files_dir_htaccess', false, get_defined_vars())) { file_put_contents($htaccess, trim(c_ws_plugin__optimizemember_utilities::evl(file_get_contents($GLOBALS['WS_PLUGIN__']['optimizemember']['c']['files_dir_htaccess'])))); } } $content = do_shortcode(op_clean_shortcode_content($content)); $content = op_process_asset_content($content); if (!empty($content)) { $html = '<ul class="downloadlist-' . $style . ' border">' . $content . '</ul>'; } else { $html = ''; } return $html; }
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; }
function parse_shortcode() { $this->check_nonce(); $this->init_page(); 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)); if (preg_match('/' . op_shortcode_regex('op_liveeditor_elements') . '/s', $sc, $matches)) { if ($GLOBALS['OP_LIVEEDITOR_DEPTH'] === 1) { $GLOBALS['OP_ADD_ELEMENT_ROWS'] = true; $processed = apply_filters('the_content', $sc); $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="' . __('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>'; } else { $GLOBALS['OP_LIVEEDITOR_DISABLE_NEW'] = true; $processed = do_shortcode(str_replace($matches[0], '#OP_CHILD_ELEMENTS#', $sc)); $GLOBALS['OP_LIVEEDITOR_DEPTH'] = 1; $child_html = op_process_asset_content(apply_filters('the_content', $matches[0])) . '<div class="op-hidden"><textarea class="op-le-child-shortcode" name="shortcode[]">' . op_attr(shortcode_unautop($matches[0])) . '</textarea></div>'; $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); //die($processed); } } else { $processed = apply_filters('the_content', $sc); } $output = array('output' => $processed, 'js' => OptimizePress_Default_Assets::_print_front_scripts(true), 'check' => OptimizePress_Default_Assets::_check_function()); if (isset($GLOBALS['OP_PARSED_SHORTCODE']) && !empty($GLOBALS['OP_PARSED_SHORTCODE'])) { $output['shortcode'] = $GLOBALS['OP_PARSED_SHORTCODE']; } echo json_encode($output); exit; }
function generate_layout($layout, $type, $one_col = false) { $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); } }
function text_block($atts, $content = '') { extract(shortcode_atts(array('style' => '1', 'align' => 'left', 'top_padding' => '', 'bottom_padding' => '', 'left_padding' => '', 'right_padding' => '', 'top_margin' => '', 'bottom_margin' => '', 'width' => '', 'line_height' => ''), $atts)); $style = 'text-align:' . $align . ';' . ($top_margin == '' ? '' : 'margin-top:' . $top_margin . 'px;') . ($bottom_margin == '' ? '' : 'margin-bottom:' . $bottom_margin . 'px;') . ($width == '' ? '' : 'width:' . $width . 'px;') . ($line_height == '' ? '' : 'line-height:' . $line_height . 'px;'); $style = ($top_margin == '' ? '' : 'margin-top:' . $top_margin . 'px;') . ($bottom_margin == '' ? '' : 'margin-bottom:' . $bottom_margin . 'px;') . ($width == '' ? '' : 'width:' . $width . 'px;') . ($line_height == '' ? '' : 'line-height:' . $line_height . 'px;') . ($align == 'center' ? 'margin: 0 auto;' : 'float: ' . $align . ';'); $chks = array('top', 'bottom', 'left', 'right'); foreach ($chks as $chk) { $var = $chk . '_padding'; $style .= ${$var} == '' ? '' : 'padding-' . $chk . ':' . ${$var} . 'px;'; } $font = op_asset_font_style($atts) . ($line_height == '' ? '' : 'line-height:' . $line_height . 'px;'); $original_font_str = $GLOBALS['OP_LIVEEDITOR_FONT_STR']; if ($font != '') { $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array('elements' => array('p', 'li'), 'style_str' => $font); } $processed = op_process_asset_content(op_clean_shortcode_content(apply_filters('the_content', $content))); $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = $original_font_str; return '<div class="op-text-block" style="' . $style . '">' . $processed . '</div>'; }