dvadf
File manager - Edit - /home/theblueo/www/wp-content/themes/thebos/framework/theme/theme_functions.php
Back
<?php function nimbus_option_data($option,$suboption='',$default='') { global $nimbus_option; $data = $default; if ( isset( $nimbus_option[$option] ) && $nimbus_option[$option] ) { $data = $nimbus_option[$option]; } if ( is_array( $data ) && isset( $data ) && $suboption ) { $data = $data[$suboption]; } return $data; } function nimbus_meta_data($key,$subkey='',$default='') { $content = get_post_meta( get_the_ID(), '_nimbus_'.$key, true ); $content = $content ? $content : $default; return $content; } function nimbus_clean_str($string) { $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. } function nimbus_get_social_domain_name($link) { $out = parse_url($link); $out = explode('.', $out['host']); $out = $out[0]; return $out; } function nimbus_column_convert($col) { $out = ''; switch ($col) { case "1/4": $out = 3; break; case "1/3": $out = 4; break; case "1/2": $out = 6; break; case "2/3": $out = 8; break; case "1/5": $out = 25; break; case "1/6": $out = 2; break; } return $out; } function nimbus_carousel_convert($col) { $out = ''; switch ($col) { case "3": $out = 4; break; case "2": $out = 6; break; case "1": $out = 12; break; case "4": $out = 3; break; case "5": $out = 24; break; } return $out; } function nimbus_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'nimbus_categories' ) ) ) { $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'number' => 2, ) ); $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'nimbus_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { return true; } else { return false; } } function nimbus_entry_date() { if ( is_search() ) return false; global $post; $author_id = $post->post_author; $author = sprintf( '', _x( 'par', 'Used before post author name.', 'nimbus' ), esc_url( get_author_posts_url( $author_id ) ), get_the_author_meta('display_name',$author_id) ); $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), get_the_date(), esc_attr( get_the_modified_date( 'c' ) ), get_the_modified_date() ); $out = sprintf( '<span class="nb-heading-desc posted-on"></span>', _x( 'Posté le', 'Used before publish date.', 'nimbus' ), esc_url( get_permalink() ), $time_string, $author ); return $out; } function nimbus_parse_css($css){ preg_match_all( '/(?ims)([a-z0-9\s\.\:#_\-@,]+)\{([^\}]*)\}/', $css, $arr); $result = array(); foreach ($arr[0] as $i => $x){ $selector = trim($arr[1][$i]); $rules = explode(';', trim($arr[2][$i])); $rules_arr = array(); foreach ($rules as $strRule){ if (!empty($strRule)){ $rule = explode(":", $strRule); $rules_arr[trim($rule[0])] = trim($rule[1]); } } $selectors = explode(',', trim($selector)); foreach ($selectors as $strSel){ $result[$strSel] = $rules_arr; } } return $result; } function nimbus_responsive_spacing_class($css) { $parse_css = nimbus_parse_css($css); $classes = $parse_css_line = ''; foreach ($parse_css as $parse_css_line) { if ( isset($parse_css_line['padding-top']) && $parse_css_line['padding-top'] ) { $spacing = str_replace(array(' !important','px'), '', $parse_css_line['padding-top']); $classes[] = $spacing > 60 ? 'nb-responsive-p-top' : ''; } if ( isset($parse_css_line['padding-bottom']) && $parse_css_line['padding-bottom'] ) { $spacing = str_replace(array(' !important','px'), '', $parse_css_line['padding-bottom']); $classes[] = $spacing > 60 ? 'nb-responsive-p-bottom' : ''; } if ( isset($parse_css_line['margin-top']) && $parse_css_line['margin-top'] ) { $spacing = str_replace(array(' !important','px'), '', $parse_css_line['margin-top']); $classes[] = $spacing > 60 ? 'nb-responsive-m-top' : ''; } if ( isset($parse_css_line['margin-bottom']) && $parse_css_line['margin-bottom'] ) { $spacing = str_replace(array(' !important','px'), '', $parse_css_line['margin-bottom']); $classes[] = $spacing > 60 ? 'nb-responsive-m-bottom' : ''; } } if ( $classes ) $classes = implode(' ',$classes); return $classes; } function nimbus_heading_class($class) { $classes = ''; $classes[] = $class; if ( is_singular() ) { $classes[] = 'singular'; } $classes = implode(' ',$classes); echo "class='".esc_attr( $classes )."'"; } function nimbus_second_product_image(){ global $post, $product, $woocommerce; $attachment_ids = $product->get_gallery_attachment_ids(); if ( $attachment_ids ) { $loop = 1; foreach ( $attachment_ids as $attachment_id ) { if($loop == 1) $img = wp_get_attachment_image_src( $attachment_id, 'shop_catalog'); $image = $img[0]; $loop++; } } else { $image = ''; } return $image; } function nimbus_extract_image($html){ if(preg_match_all('/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i',$html,$matches)){ return $matches[0][0]; } } function nimbus_validate_data($html){ $allowed_html = array( 'a' => array( 'href' => array(), 'title' => array(), 'class' => array(), ), 'br' => array(), 'em' => array(), 'strong' => array(), 'span' => array( 'class' => array(), 'id' => array(), ), 'ul' => array( 'class' => array() ), 'ol' => array( 'class' => array() ), 'li' => array( 'class' => array() ), 'div' => array( 'class' => array(), 'id' => array() ), 'iframe' => array( 'id' => array(), 'class' => array(), 'src' => array(), 'width' => array(), 'height' => array(), 'style' => array(), ), 'object' => array( 'id' => array(), 'class' => array(), 'width' => array(), 'height' => array(), 'data' => array(), 'type' => array(), 'name' => array(), 'style' => array(), ), 'embed' => array( 'id' => array(), 'class' => array(), 'src' => array(), 'width' => array(), 'height' => array(), 'type' => array(), 'style' => array(), ), 'audio' => array( 'id' => array(), 'class' => array(), 'src' => array(), 'type' => array(), 'width' => array(), 'height' => array(), 'style' => array(), ), ); $html = wp_kses( $html, $allowed_html); return $html; } function nimbus_custom_taxonomies_terms_links($taxonomy,$sep =', ' ) { global $post, $post_id; $return = ''; // get post by post id &get_post $post = get_post($post->ID); // get post type by post $post_type = $post->post_type; // get post type taxonomies $terms = get_the_terms( $post->ID, $taxonomy ); if ( !empty( $terms ) ) { $out = array(); foreach ( $terms as $term ) $out[] = '<a title="'.$term->name.'" href="' .get_term_link($term->slug, $taxonomy) .'">'.$term->name.'</a>'; $return = join( $sep, $out ); } else { $return = ''; } return $return; } function nimbus_custom_taxonomies_terms_slugs($taxonomy,$sep =' ' ) { global $post, $post_id; $return = ''; // get post by post id &get_post $post = get_post($post->ID); // get post type by post $post_type = $post->post_type; // get post type taxonomies $terms = get_the_terms( $post->ID, $taxonomy ); if ( !empty( $terms ) ) { $out = array(); foreach ( $terms as $term ) $out[] = $term->slug; $return = join( $sep, $out ); } else { $return = ''; } return $return; } function nimbus_theme_custom_length($length) { global $post; if ($post->post_type == 'post') { return nimbus_option_data('text_excerptlength','',20); } elseif ($post->post_type == 'portfolio') { return nimbus_option_data('text_portfolio_excerptlength','',20); } else { return 20; } } add_filter( 'excerpt_length', 'nimbus_theme_custom_length', 999 ); function nimbus_header_class($class=''){ $classes = ''; $classes[] = $class; if ( is_singular() || is_page() || is_singular() ) { $classes[] = nimbus_meta_data('radio_header_position'); $classes[] = nimbus_meta_data('radio_header_color'); $classes[] = nimbus_meta_data('radio_header_border'); $classes[] = nimbus_meta_data('radio_header_bg_color'); } echo 'class="'.implode(' ',$classes).'"'; } function nimbus_header_container() { $class = nimbus_meta_data('select_header_container') ? nimbus_meta_data('select_header_container') : nimbus_option_data('select_header_container'); echo 'class="'.esc_attr( $class ).'"'; }
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings