/** * Remove cache folder * * @return type */ static function remove_cache_folder() { $cache_dir = WP_CONTENT_DIR . '/uploads' . '/wrcache/megamenu'; WR_Megamenu_Helpers_Common::recursive_delete($cache_dir); // if directory still exits, false if (is_dir($dir)) { return false; } return true; }
/** * * @param type $content : inner shortcode elements of this column * @param string $shortcode_data * @return string */ public function element_in_megamenu($content = '', $shortcode_data = '') { $column_html = empty($content) ? '' : WR_Megamenu_Helpers_Shortcode::do_shortcode_admin($content, true); $span = !empty($this->params['span']) ? $this->params['span'] : 'span12'; $shortcode_data = '[' . $this->config['shortcode'] . ' span="' . $span . '"]'; // Remove empty value attributes of shortcode tag. $shortcode_data = preg_replace('/\\[*([a-z_]*[\\n\\s\\t]*=[\\n\\s\\t]*"")/', '', $shortcode_data); $rnd_id = WR_Megamenu_Helpers_Common::random_string(); $column[] = '<div class="jsn-column-container clearafter shortcode-container "> <div class="jsn-column ' . $span . '"> <div class="thumbnail clearafter"> <textarea class="hidden" name="shortcode_content[]" >' . $shortcode_data . '</textarea> <div class="jsn-column-content item-container" data-column-class="' . $span . '" > <div class="jsn-handle-drag jsn-horizontal jsn-iconbar-trigger"><div class="jsn-iconbar layout"><a class="item-delete column" onclick="return false;" title="' . __('Delete column', WR_MEGAMENU_TEXTDOMAIN) . '" href="#"><i class="icon-trash"></i></a></div></div> <div class="jsn-element-container item-container-content">' . $column_html . '</div> <a class="jsn-add-more wr-more-element" href="javascript:void(0);"><i class="icon-plus"></i>' . __('Add Element', WR_MEGAMENU_TEXTDOMAIN) . '</a> </div> <textarea class="hidden" name="shortcode_content[]" >[/' . $this->config['shortcode'] . ']</textarea> </div> </div> </div>'; return $column; }
/** * Return html structure of shortcode in MegaMenu area * @param type $shortcode_name * @param type $attr * @param type $content */ public static function shortcode_to_megamenu($shortcode_name, $content = '', $shortcode_data = '', $shortcode_params = '') { $class = WR_Megamenu_Helpers_Shortcode::get_shortcode_class($shortcode_name); if (class_exists($class)) { global $wr_megamenu_element; $elements = $wr_megamenu_element->get_elements(); $instance = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null; if (!is_object($instance)) { $instance = new $class(); } $el_title = ''; if ($class != 'WR_Megamenu_Widget') { // extract param of shortcode ( now for column ) if (isset($instance->config['extract_param'])) { parse_str(trim($shortcode_params), $output); foreach ($instance->config['extract_param'] as $param) { if (isset($output[$param])) { $instance->params[$param] = WR_Megamenu_Helpers_Common::remove_quotes($output[$param]); } } } // get content in megamenu of shortcode: Element Title must always first option of Content tab if (isset($instance->items['content']) && isset($instance->items['content'][0])) { $title = $instance->items['content'][0]; if (@$title['role'] == 'title') { $params = shortcode_parse_atts($shortcode_params); $el_title = !empty($params[$title['id']]) ? $params[$title['id']] : __('(Untitled)', WR_MEGAMENU_TEXTDOMAIN); } } } else { $widget_info = WR_Megamenu_Helpers_Shortcode::extract_widget_params($shortcode_data); $el_title = !empty($widget_info['title']) ? $widget_info['title'] : ''; $params = WR_Megamenu_Helpers_Shortcode::extract_params($shortcode_data); $instance->config['shortcode'] = $params['widget_id']; $instance->config['el_type'] = 'widget'; } $shortcode_view = $instance->element_in_megamenu($content, $shortcode_data, $el_title); return $shortcode_view[0]; } }
/** * Dummy content * * @return array */ static function lorem_text($word_count = 50) { return ucfirst(WR_Megamenu_Helpers_Common::lorem_text($word_count, true)); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $random_id = WR_Megamenu_Helpers_Common::random_string(); $script = $html_element = ''; if (!empty($content)) { $content = WR_Megamenu_Helpers_Shortcode::remove_autop($content, true); } $html_element_style = '<style type="text/css">'; if (isset($enable_dropcap) && $enable_dropcap == 'yes') { if ($content) { $styles = array(); if ($dropcap_font_face_type == 'google fonts' and $dropcap_font_face_value != '') { $script .= WR_Megamenu_Helpers_Functions::add_google_font_link_tag($dropcap_font_face_value); $styles[] = 'font-family:' . $dropcap_font_face_value; } elseif ($dropcap_font_face_type == 'standard fonts' and $dropcap_font_face_value) { $styles[] = 'font-family:' . $dropcap_font_face_value; } if (intval($dropcap_font_size) > 0) { $styles[] = 'font-size:' . intval($dropcap_font_size) . 'px'; $styles[] = 'line-height:' . intval($dropcap_font_size) . 'px'; } switch ($dropcap_font_style) { case 'bold': $styles[] = 'font-weight:700'; break; case 'italic': $styles[] = 'font-style:italic'; break; case 'normal': $styles[] = 'font-weight:normal'; break; } if (strpos($dropcap_font_color, '#') !== false) { $styles[] = 'color:' . $dropcap_font_color; } if (count($styles)) { $html_element_style .= sprintf('%s .dropcap:first-letter { float:left;', "#{$random_id}"); $html_element_style .= implode(';', $styles); $html_element_style .= '}'; } $html_element .= "<div class='dropcap'>{$content}</div>"; } } else { $html_element .= $content; } $html_element_style .= '.preview-text {line-height: ' . $line_height . 'px;}'; $html_element_style .= '</style>'; $preview = $html_element_style; $preview .= "<div class='preview-text'>" . $html_element . '</div>'; $html = sprintf('<div class="wr_text" id="%s">', $random_id); $html .= $script; $html .= $preview; $html .= '</div>'; // Process margins if (isset($arr_params['text_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['text_margin_top']; } if (isset($arr_params['text_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['text_margin_bottom']; } if (isset($arr_params['text_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['text_margin_right']; } if (isset($arr_params['text_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['text_margin_left']; } return $this->element_wrapper($html, $arr_params); }