static function testimonials($atts, $content = '') { // Decode encoded chars $atts = op_urldecode($atts); //Extract the shortcodes into variables extract(shortcode_atts(array('style' => 1, 'margin_top' => '', 'margin_bottom' => ''), $atts)); //Initialize style arrays $cont_styles = array(1, 5, 9, 11, 14); $tblock_styles = array(5); //Initialize the return string $str = ''; //Make sure there is a testimonial in the shortcode $mc = preg_match_all('/' . op_shortcode_regex('testimonial') . '/s', $content, $matches); //Continue if there are matches if ($mc > 0) { //Loop through the testimonial elements for ($i = 0; $i < $mc; $i++) { //Extract the data from the child shortcode $data = shortcode_atts(array('name' => '', 'company' => '', 'href' => '', 'image' => ''), shortcode_parse_atts($matches[3][$i])); // Decode encoded chars if (is_array($data)) { foreach ($data as $key => $att) { $data[$key] = urldecode($att); } } //Get this testimonials content $data['content'] = urldecode($matches[5][$i]); //Generate a font style out of the font attribute $data['font_str'] = op_asset_font_style($atts); //Get the current font settings $original_font_str = $GLOBALS['OP_LIVEEDITOR_FONT_STR']; //If font settings are present then set the style string and set the font string if (!empty($data['font_string'])) { $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = array('elements' => array('p', 'a'), 'style_str' => $font); } //Return the font string back to normal $GLOBALS['OP_LIVEEDITOR_FONT_STR'] = $original_font_str; //Add margin to the data array $data['margin_top'] = $margin_top; $data['margin_bottom'] = $margin_bottom; //Decode encoded characters (needed for correct parsing of shortcodes) // $data['name'] = urldecode($data['name']); // $data['company'] = urldecode($data['company']); // $data['href'] = urldecode($data['href']); // $data['image'] = urldecode($data['image']); //Generate the element ID $data['id'] = 'testimonial-' . op_generate_id(); //Clear out the template and reload it with the style of this testimonial, putting the //returned HTML into the display string _op_tpl('clear'); $str .= _op_tpl('_load_file', OP_ASSETS . 'tpls/testimonials/style_' . $style . '.php', $data, true); } //If there is a container div in this style, add it to the HTML if (in_array($style, $cont_styles)) { $str = '<div class="' . (in_array($style, $tblock_styles) ? 'testimonial-block-three cf' : 'testimonial-block cf') . '">' . $str . '</div>'; } } return $str; }
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>'; }
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>'; }