static function get_sidebars() { //global $shortname; $sidebars = array_merge((array) get_theme_var('sidebars'), (array) get_theme_var('sidebar-tabs')); $sidebar_list = array(); foreach ((array) $sidebars as $item) { if (!isset($item['key'])) { continue; } // if it's not set... skip this one $key = isset($item['key']) ? $item['key'] : ''; $name = isset($item['label']) ? $item['label'] : ''; $alias = isset($item['alias']) ? $item['alias'] : ''; // only tabs have the 'bg_color' attribute if (array_key_exists('bg_color', (array) $item)) { $name .= ' (tab)'; } $sidebar_list[$key] = array('name' => $name, 'alias' => $alias); } return $sidebar_list; }
function theme_sidebar($atts, $content = null) { extract(shortcode_atts(array('alias' => false), $atts)); if ($alias) { // find the sidebar ID by the alias $sidebars = get_theme_var('sidebars'); foreach ($sidebars as $key => $value) { if (isset($value['alias']) && $value['alias'] == $alias) { $id = $key; break; } } if ($id) { // turn on output buffering to capture output ob_start(); // generate sidebar dynamic_sidebar('generated_sidebar-' . $id); // get output content $content = ob_get_clean(); // return the content return $content; } } }
<?php // BP action do_action('bp_footer'); // WordPress Footer Includes wp_footer(); ?> <script src="<?php echo $jsPath; ?> onLoad.js"></script><?php // Functions to call after page load ?> <?php // Google analytics (asynchronous method from http://mathiasbynens.be/notes/async-analytics-snippet) if (get_theme_var('options,google_analytics')) { ?> <script type="text/javascript"> var _gaq = [['_setAccount', '<?php theme_var('options,google_analytics'); ?> '], ['_trackPageview']]; (function(d, t) { var g = d.createElement(t), s = d.getElementsByTagName(t)[0]; g.async = true; g.src = ('https:' == location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; s.parentNode.insertBefore(g, s); })(document, 'script'); </script> <?php
<?php /* Error Page Content ------------------ The error page content can be created using a page. To set the page as the source of your 404 error page go to the "Settings > Theme Setting > Miscellaneous > Error Page (404)" option and choose the page from the select box. If no page is selected the default content below will be displayed. Error Page Layout ----------------- The error page layout can be set in the "Appearance > Design Settings > Default Design Settings" area. */ // Get page ID of error content $errorPageID = get_theme_var('options,404_page'); if ($errorPageID) { // query the page selected as 404 error query_posts(array('page_id' => $errorPageID)); // load the template to display content get_template_part('page'); } else { // A generic 404 error. Used if no page has been set as the content source ?> <!-- Title / Page Headline --> <header class="entry-header"> <h1 class="entry-title" title="<?php _e('Error 404', THEME_NAME); ?> "><?php _e('Error 404', THEME_NAME); ?> </h1>
function the_content_filter($content) { global $post, $tempPost, $wp_filter, $save_wp_filter; // check the temporary $post reassignment for context specific $post data $the_post = isset($tempPost) ? $tempPost : $post; if (isset($save_wp_filter)) { $wp_filter['the_content'] = $save_wp_filter; } else { $save_wp_filter = $wp_filter['the_content']; } // active filters $the_content_filters = $wp_filter['the_content']; // get block options $disable = unserialize(get_theme_var('options,disable_wp_content')); if (isset($disable[$the_post->post_type])) { $disable = $disable[$the_post->post_type]; if (count($disable)) { foreach ($disable as $filter) { // check filter type (function or object) if (preg_match("/->/", $filter)) { // get class to block then generate current block id // and unset filter from apply list $filter = explode("->", $filter); $class = $filter[0]; $method = $filter[1]; foreach ($the_content_filters as $level => $_filters) { foreach ($_filters as $_filter_name => $_filter) { if (is_object($_filter['function'][0])) { if ($class == get_class($_filter['function'][0]) && $method == $_filter['function'][1]) { $object_filter = _wp_filter_build_unique_id('', array(&$_filter["function"][0], $method), 10); foreach ($wp_filter['the_content'] as $key => $val) { unset($wp_filter['the_content'][$key][$object_filter]); } } } } } } else { // unset function filter remove_filter('the_content', $filter); } } } } return $content; }
function verify_bp_groups_context($context, $template, $values) { global $bp; // If current BP group ID matches a registered $context (format "bp-group-[ID]), return the $context value if (bp_is_groups_component() && isset($bp->groups->current_group->id) && $values['context'] == "bp-group-" . $bp->groups->current_group->id) { // Make sure the value is set for this context, otherwise we'll let the default assignment occur $layout = get_theme_var('design_setting,layout,' . $values['context']); if ($layout) { $context = $values['context']; } } return $context; }
function build_box_gut($box) { global $content_fields, $content_fields_settings; do_action('mf_box_head', $box); foreach ((array) $box['fields'] as $field) { if (!($field = apply_filters('mf_field', $field))) { continue; } $field_defaults = array('key' => '', 'label' => '', 'type' => '', 'title' => '', 'field_type' => '', 'values' => '', 'val_keys' => '', 'vals' => ''); $field = array_merge($field_defaults, $field); $title = '<label class="mf_label" for="' . $field['key'] . '">' . $field['label'] . ':</label>'; echo '<div class="mf_field_wrapper mf_field_' . $field['key'] . ' ' . $field['type'] . '">'; if ($field['title'] && $field['type'] != 'checkbox') { echo $title; } $type = $content_fields->field_types[$field['field_type']]; if (!$type) { return false; } $type_defaults = array('html_before' => '', 'html_item' => '', 'html_selected' => '', 'actions' => '', 'html_after' => ''); $type = array_merge($type_defaults, $type); // Parse out the values, including ascending and descending ranges $values = array(); $parts = explode(',', $field['values']); // Add empty option at top for select lists if ($field['field_type'] == 'select') { $values[] = '- Select -'; } // custom fields for theme specific settings preg_match('/\\[\\[(.*?)\\]\\]/', $field['values'], $matches); if (isset($matches[1]) && $matches[1]) { // this is one of our special cases... store the data from saved theme options to the values array //$design_data = $design_settings->get_objects(array('_plugin_saved', '_plugin')); $value_keys = array(); // this is for setting the option "value" instead of just using the name // determine where to get the data... if ($matches[1] == 'skins') { // look up the skins $skins = $content_fields_settings->get_skin_css(); asort($skins); $themeOptions = $skins; foreach ($themeOptions as $key => $value) { $values[] = $value; // the option name $value_keys[$value] = $key; // the option value } } else { // this is a theme option, just return array $themeOptions = get_theme_var($matches[1]); //$design_data[$matches[1]]; foreach ($themeOptions as $item) { if (!is_array($item)) { continue; } $values[] = $item['label']; // the option name $value_keys[$item['label']] = $item['key']; // the option value } } $field['val_keys'] = $value_keys; // the standard fields (not theme specific) } else { // Not theme specific, do default parsing of values foreach ((array) $parts as $part) { $range = explode(':', $part); if (count($range) == 2) { if ($range[0] < $range[1]) { for ($j = $range[0]; $j <= $range[1]; $j++) { $values[] = $j; } } else { for ($j = $range[0]; $j >= $range[1]; $j--) { $values[] = $j; } } } else { $values[] = $part; } } } $field['vals'] = $values; // Get the closed boxes //$post_type = sanitize_title($this->get_type()); //$hidden = (array) get_user_option("meta-box-hidden_${post_type}", 0, false ); //$box_is_hidden = (in_array(sanitize_title($box['name']), $hidden)); // Write the field echo $this->field_type_render($type['html_before'], $field, $box['position']); if (empty($values)) { echo $this->field_type_render($type['html_item'], $field, $box['position']); } else { foreach ($values as $v) { // If there is a range but no item template (e.g. html5 range) if (!$type['html_item']) { continue; } echo $this->field_type_render($type['html_item'], $field, $box['position'], rtrim(ltrim($v)), $type['html_selected']); } } if ($actions = $type['actions']) { foreach ($actions as $action => $args) { // Render the arguments $rendered = array(); foreach ($args as $arg) { $rendered[] = $this->field_type_render($arg, $field, $box['position']); } // Do the action if (!count($args)) { do_action($action); } else { if (count($args) == 1) { do_action($action, $rendered[0]); } else { if (count($args) == 2) { do_action($action, $rendered[0], $rendered[1]); } else { if (count($args) == 3) { do_action($action, $rendered[0], $rendered[1], $rendered[2]); } } } } } } //do_action($action); echo $this->field_type_render($type['html_after'], $field, $box['position']); // Add caption to field // if ($f = html_entity_decode($field['caption'])) echo "<em class='mf_caption'>$f</em>"; echo '</div>'; do_action('mf_box_foot', $box); } }
function send_theme_contact_form() { $mailFormat = 'html'; // values: html or text // formatting $before_line = $mailFormat === 'html' ? '<p>' : ''; $after_line = $mailFormat === 'html' ? '</p>' : '"\\r\\n"'; $before_title = $mailFormat === 'html' ? '<strong>' : ''; $after_title = $mailFormat === 'html' ? '</strong>' : ''; $before_h = $mailFormat === 'html' ? '<h2>' : ''; $after_h = $mailFormat === 'html' ? '</h2>' : ''; $br = $mailFormat === 'html' ? '<br />' : '"\\r\\n"'; // get the main data from the database $contact_form_data = get_theme_var('contact_form'); $contact_fields_data = $contact_form_data['contact_fields']; // set all variables based on defaults $default_to = $contact_form_data['to']; $default_subject = $contact_form_data['subject']; $default_captcha = $contact_form_data['captcha']; $fields = $contact_fields_data; $to = $default_to; $subject = $default_subject; $message = ''; $email_body = ''; $error = ''; // Check common options for the senders name $name = ''; $commonNames = array('name', 'yourname', 'your-name', 'your_name', 'fromname', 'from-name', 'from_name', 'sender', 'firstname', 'first-name', 'first_name'); foreach ($commonNames as $name_field) { if ($_POST[$name_field]) { $name = $_POST[$name_field]; break; // stop as soon as a match is found } } // Check common options for the senders email address $email = ''; $commonEmails = array('email', 'e-mail', 'e_mail', 'emailaddress', 'email-address', 'email_address', 'youremail', 'your-email', 'your_email', 'sender', 'from', 'fromaddress', 'from-address', 'from_address', 'fromemail', 'from-email', 'from_email'); foreach ($commonEmails as $email_field) { if ($_POST[$email_field] && simple_email_validate($_POST[$email_field])) { $email = $_POST[$email_field]; break; // stop as soon as a match is found } } // double check... if (empty($email)) { $email = $default_to; } // Message Heading (title) $email_body .= $before_h . __('Form Submission', THEME_NAME) . $after_h; $email_body .= $mailFormat !== 'html' ? $br : ''; // fields to exclude from the message (these are for internal use) $excludeFields = array('mail_action', 'captcha', '_S', '_R'); // Get the post values for the email foreach ($_POST as $key => $value) { if (!in_array($key, $excludeFields)) { $info = $fields[$key]; // for checkbox values if ($info['field_type'] == 'checkbox' && $value == 'on') { $value = __('Yes', THEME_NAME); } // for radio and select values if ($info['field_type'] == 'radio' || $info['field_type'] == 'select') { // get a more human readable version (radio and select form values are sanatized) $field_values = explode(',', $info['values']); foreach ((array) $field_values as $field_value) { if (sanitize_title($field_value) === $value) { $value = $field_value; // the unsanitized version break; // stop once match is found } } } // for blank values if ($value == '') { $value = '-'; } // blank values // create the entry in the message body $email_body .= $before_line; $email_body .= $before_title . $info['label'] . $after_title . $br; $email_body .= $value . $br; $email_body .= $after_line; } else { // Special Fields // The "to" and "subject" fields may need to be included as hidden fields if their values were // specified in the shortcode and differ from the database defaults. if (isset($_POST['_R']) && $_POST['_R']) { // override the "to" address $to = strDec(trim($_POST['_R'])); // double check... if (empty($to)) { $to = $default_to; } } if (isset($_POST['_S']) && $_POST['_S']) { // override the "subject: $subject = strDec(trim($_POST['_S'])); // double check... if (empty($subject)) { $subject = $default_subject; } } } } // Validate captcha if (array_key_exists('captcha', $_REQUEST)) { // if (!empty($_REQUEST['captcha'])) { if (empty($_SESSION['captcha']) || trim(strtolower($_REQUEST['captcha'])) != $_SESSION['captcha']) { $error .= __('Invalid image verification code', THEME_NAME) . '<br />'; } else { // nothing here because the captcha matches } } // Let's send the email. if (!$error) { //$headers = 'From: '.$name.' <'.$email.'>' . \\"\r\n\\"; $headers = 'From: ' . $name . ' <' . $email . '>' . "\r\n\\"; $message = $email_body; if ($mailFormat === 'html') { // set mail to send in HTML format add_filter('wp_mail_content_type', create_function('', 'return "text/html"; ')); } // send $mail = wp_mail($to, $subject, $message, $headers); if ($mail) { // sent successfully $status = 'success'; // clear CAPTCHA value if (isset($_SESSION['captcha'])) { unset($_SESSION['captcha']); } } } else { // return error messages $status = '<div class="error">' . $error . '</div>'; } // to avoid loading a full page we end the process here exit($status); }
function bg_style($type = null, $return = 'style') { if (!$type) { return ""; } global $cache; if (!isset($cache['bg_style'][$type])) { // Default header background from Design Settings $bg = get_theme_var("design_setting,{$type}"); $bgStyle = ''; $overwrite = null; if ($type != "body") { global $theHeader, $theFooter; } if (!$overwrite && $type == "header") { $overwrite = $theHeader; } if (!$overwrite && $type == "footer") { $overwrite = $theFooter; } // Overwrite array to include header specific settings (depending on the header, page, etc.) foreach ((array) $bg as $key => $value) { if (isset($overwrite[$key]) && $overwrite[$key] !== '') { $bg[$key] = $overwrite[$key]; } } // Background color & image (create style) $theBg = $bg['bg_color'] ? '#' . str_replace('#', '', $bg['bg_color']) : ''; // 'transparent'; //$theBg = ($bg['bg_color'] && $type != 'header') ? '#'.str_replace('#','',$bg['bg_color']) : 'transparent'; if ($bg['background']) { $theBg .= ' url(\'' . $bg['background'] . '\') ' . $bg['bg_repeat'] . ' ' . $bg['bg_pos_x'] . ' ' . $bg['bg_pos_y']; // $ie_fix = true; } if ($theBg) { $bgStyle = 'background: ' . $theBg . ';'; // if($ie_fix) $bgStyle .= "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( src='{$bg['background']}', sizingMethod = 'scale' );"; } $cache['bg_style'][$type] = $bgStyle; } else { $bgStyle = $cache['bg_style'][$type]; } if ($return == 'image') { return $bg['background']; } elseif ($return == 'array') { return $bg; } else { return $bgStyle; } }
function verify_wp_category_context($context, $template, $values) { // If current BP group ID matches a registered $context (format "bp-group-[ID]), return the $context value if (is_category() && $values['context'] == 'category-' . get_query_var('cat')) { // Make sure the value is set for this context, otherwise we'll let the default assignment occur $layout = get_theme_var('design_setting,layout,' . $values['context']); if ($layout) { $context = $values['context']; } } return $context; }
function vt_resize($attach_id = null, $img_url = null, $width = 0, $height = 0, $crop = false, $high_res = false) { global $blog_id, $wp_version; $cache = 'cache/'; // Cache folder name (set to '' for none) // create high DPI images? $hi_dpi = $high_res ? $high_res : get_theme_var('options,hi_dpi', 'active'); // if local is set, use it, else use global $hi_dpi = $hi_dpi !== 'inactive' ? 'active' : 'inactive'; // default or unset: active // placeholder images $use_placeholders = get_theme_var('options,placeholder_images'); $custom_placeholder = get_theme_var('options,custom_placeholder'); if (!$img_url && $use_placeholders) { $img_url = $custom_placeholder ? $custom_placeholder : THEME_URL . 'assets/images/placeholder.jpg'; } $tmp_file_path = ""; if ($attach_id) { $image_src = wp_get_attachment_image_src($attach_id, 'full'); $tmp_file_path = get_attached_file($attach_id); } // this is an attachment, so we have the ID if ($attach_id && $tmp_file_path != "") { $image_src = wp_get_attachment_image_src($attach_id, 'full'); $file_path = get_attached_file($attach_id); // this is not an attachment, let's use the image url } else { if ($img_url) { $file_path = parse_url($img_url); $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path']; if (!file_exists($file_path)) { // simple fix for direct links to images on multi-site installs if (isset($blog_id) && $blog_id > 0) { // uploaded images to media folders $imageParts = explode('/files/', $img_url, 2); if (isset($imageParts[1])) { $img_url = get_site_url(1) . '/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; $file_path = parse_url($img_url); $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path']; } // if not found in media folders check theme folders if (!file_exists($file_path)) { // files in the theme folder $imageParts = explode(THEME_URL, $img_url, 2); if (isset($imageParts[1])) { $file_path = THEME_DIR . $imageParts[1]; } } } } if (file_exists($file_path)) { $orig_size = getimagesize($file_path); $image_src[0] = $img_url; $image_src[1] = $orig_size[0]; $image_src[2] = $orig_size[1]; } else { // couldn't find the image so set the values back to what was provided and return $vt_image = array('url' => $img_url, 'width' => $width, 'height' => $height, 'hidpi' => $hi_dpi); return $vt_image; } } } // if no image size was sent... use the original if (!$width) { $width = $image_src[1]; } if (!$height) { $height = $image_src[2]; } // checking if the original image is at least as big the requested output size // if it is smaller or the same size, stop right here and return if ($image_src[1] > $width || $image_src[2] > $height) { $file_info = pathinfo($file_path); $extension = '.' . $file_info['extension']; // the image path without the extension $no_ext_path = $file_info['dirname'] . '/' . $cache . $file_info['filename']; // $no_ext_path = $file_info['dirname'].'/'.$file_info['filename']; // high DPI? Prepend filename with @2x $at2X = $hi_dpi == 'active' ? '@2x' : ''; $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . $at2X . $extension; // check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match) if (file_exists($cropped_img_path)) { $cropped_img_url = str_replace(basename($image_src[0]), $cache . basename($cropped_img_path), $image_src[0]); // echo 'str_replace( '. basename( $image_src[0] ) .', '. basename( $cropped_img_path ) .', '. $image_src[0] .');'; $vt_image = array('url' => $cropped_img_url, 'width' => $width, 'height' => $height, 'hidpi' => $hi_dpi); return $vt_image; } // $crop = false if ($crop == false) { // calculate the size proportionaly $proportional_size = wp_constrain_dimensions($image_src[1], $image_src[2], $width, $height); $resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . $at2X . $extension; // checking if the file already exists if (file_exists($resized_img_path)) { $resized_img_url = str_replace(basename($image_src[0]), $cache . basename($resized_img_path), $image_src[0]); $vt_image = array('url' => $resized_img_url, 'width' => $proportional_size[0], 'height' => $proportional_size[1], 'hidpi' => $hi_dpi); return $vt_image; } } // no cache files - let's finally resize it // ............................................................. // first, make sure the directory is writable. if (is_writable($file_info['dirname'])) { // Yea! It's writable! $new_suffix = $width . 'x' . $height . $at2X; // this is appended to the saved file name // double sizes for high DPI $w = $hi_dpi == 'active' ? $width * 2 : $width; $h = $hi_dpi == 'active' ? $height * 2 : $height; // make sure the image is big enough if ($hi_dpi == 'active' && ($w > $image_src[1] || $h > $image_src[2])) { /* High DPI image sizes are sometimes bigger than the original, although the original is still * larger than the requested size. For cases like this we want to resize to the maximum possible * width or hight in the cropping proportions requested. */ // Get the max size of the requested image ratio $max_size = wp_constrain_dimensions($w, $h, $image_src[1], $image_src[2]); // Updated size $w = $max_size[0]; $h = $max_size[1]; // Update the suffix width/height values $width = floor($w / 2); $height = floor($h / 2); $new_suffix = $width . 'x' . $height . $at2X; // this is appended to the saved file name } $resized_img_path = $no_ext_path . '-' . $new_suffix . $extension; // What the final path would look like (mostly for testing if it already exists) // Double check the image doesn't already exist if (!file_exists($resized_img_path)) { // Check if the cache folder exists if ($cache && !file_exists($file_info['dirname'] . '/' . $cache)) { mkdir($file_info['dirname'] . '/' . $cache, 0755); } // let's do some resizing! if (version_compare($wp_version, '3.5', '>=')) { $image = wp_get_image_editor($file_path); if (!is_wp_error($image)) { $image->resize($w, $h, $crop); $image->set_quality(100); $new_img_path = $image->generate_filename($new_suffix, $file_info['dirname'] . '/' . $cache, $extension = null); $image->save($new_img_path); } } else { $new_img_path = image_resize($file_path, $w, $h, $crop, $new_suffix, $file_info['dirname'] . '/' . $cache, 100); } // check the new image size $new_img_size = getimagesize($new_img_path); $width = $hi_dpi == 'active' ? floor($new_img_size[0] / 2) : $new_img_size[0]; $height = $hi_dpi == 'active' ? floor($new_img_size[1] / 2) : $new_img_size[1]; // get the new image URL $resized_img_url = str_replace(basename($image_src[0]), $cache . basename($new_img_path), $image_src[0]); } else { // Looks like we already have the image created $resized_img_url = str_replace(basename($image_src[0]), $cache . basename($resized_img_path), $image_src[0]); } } else { // nope, directory isn't writable. return the original file info $new_img_size[0] = $width; $new_img_size[1] = $height; $new_img = $img_url; } // set image data for output $vt_image = array('url' => $resized_img_url, 'width' => $width, 'height' => $height, 'hidpi' => $hi_dpi); return $vt_image; } // default output - without resizing $vt_image = array('url' => $image_src[0], 'width' => $image_src[1], 'height' => $image_src[2], 'hidpi' => $hi_dpi); return $vt_image; }
?> ); -ms-filter: progid:DXImageTransform.Microsoft.gradient( gradientType=0, startColorstr=<?php echo $body_color; ?> , endColorstr=<?php echo $ie_filter_transparent; ?> ); } <?php } ?> </style> <?php // Custom JavaScript entered in design settings if ($customJS = get_theme_var('design_setting,js_custom')) { ?> <script type="text/javascript"> <?php echo prep_content($customJS); ?> </script> <?php } ?>