Exemplo n.º 1
0
 function axiom_ini_get_value($file, $name, $defa = '')
 {
     if (!is_array($file)) {
         if (file_exists($file)) {
             $file = axiom_fga($file);
         } else {
             return $defa;
         }
     }
     $name = axiom_strtolower($name);
     $rez = $defa;
     for ($i = 0; $i < count($file); $i++) {
         $file[$i] = trim($file[$i]);
         if (($pos = axiom_strpos($file[$i], ';')) !== false) {
             $file[$i] = trim(axiom_substr($file[$i], 0, $pos));
         }
         $parts = explode('=', $file[$i]);
         if (count($parts) != 2) {
             continue;
         }
         if (axiom_strtolower(trim(chop($parts[0]))) == $name) {
             $rez = trim(chop($parts[1]));
             if (axiom_substr($rez, 0, 1) == '"') {
                 $rez = axiom_substr($rez, 1, axiom_strlen($rez) - 2);
             } else {
                 $rez *= 1;
             }
             break;
         }
     }
     return $rez;
 }
Exemplo n.º 2
0
 function axiom_strtoproper($text)
 {
     $rez = '';
     $last = ' ';
     for ($i = 0; $i < axiom_strlen($text); $i++) {
         $ch = axiom_substr($text, $i, 1);
         $rez .= axiom_strpos(' .,:;?!()[]{}+=', $last) !== false ? axiom_strtoupper($ch) : axiom_strtolower($ch);
         $last = $ch;
     }
     return $rez;
 }
Exemplo n.º 3
0
 function axiom_options_reset($clear = true)
 {
     $theme_data = wp_get_theme();
     $slug = str_replace(' ', '_', trim(axiom_strtolower((string) $theme_data->get('Name'))));
     $option_name = 'axiom_' . strip_tags($slug) . '_options_reset';
     if (get_option($option_name, false) === false) {
         // && (string) $theme_data->get('Version') == '1.0'
         if ($clear) {
             global $wpdb;
             $wpdb->query('delete from ' . esc_sql($wpdb->options) . ' where option_name like "axiom_options%"');
         }
         add_option($option_name, 1, '', 'yes');
     }
 }
Exemplo n.º 4
0
 function axiom_get_thumb_slug($title)
 {
     return axiom_strtolower(str_replace(' ', '_', $title));
 }
Exemplo n.º 5
0
 function axiom_is_inherit_option($value)
 {
     while (is_array($value)) {
         foreach ($value as $val) {
             $value = $val;
             break;
         }
     }
     return axiom_strtolower($value) == 'inherit';
     //in_array(axiom_strtolower($value), array('default', 'inherit'));
 }
Exemplo n.º 6
0
 function axiom_sc_param_is_inherit($prm)
 {
     return in_array(axiom_strtolower($prm), array('inherit', 'default'));
 }
Exemplo n.º 7
0
 function axiom_show_breadcrumbs($args = array())
 {
     global $wp_query, $post;
     axiom_set_global('in_breadcrumbs', true);
     $args = array_merge(array('home' => __('Home', 'axiom'), 'home_url' => '', 'show_all_filters' => true, 'show_all_posts' => true, 'truncate_title' => 50, 'truncate_add' => '...', 'delimiter' => '<span class="breadcrumbs_delimiter"></span>', 'max_levels' => axiom_get_theme_option('breadcrumbs_max_level'), 'echo' => true), is_array($args) ? $args : array('home' => $args));
     $type = axiom_get_blog_type();
     $title = axiom_strshort(axiom_get_blog_title(), $args['truncate_title'], $args['truncate_add']);
     if (in_array($type, array('home', 'frontpage'))) {
         return '';
     }
     if ($args['max_levels'] <= 0) {
         $args['max_levels'] = 999;
     }
     $need_reset = true;
     $rez = $rez_parent = $rez_all = $rez_level = $rez_period = '';
     $cat = $parentTax = '';
     $level = $parent = $post_id = 0;
     // Get current post ID and path to current post/page/attachment ( if it have parent posts/pages )
     if ($type == 'page' || $type == 'attachment' || is_single()) {
         $pageParentID = isset($wp_query->post->post_parent) ? $wp_query->post->post_parent : 0;
         $post_id = $type == 'attachment' ? $pageParentID : (isset($wp_query->post->ID) ? $wp_query->post->ID : 0);
         while ($pageParentID > 0) {
             $pageParent = get_post($pageParentID);
             $level++;
             if ($level > $args['max_levels']) {
                 $rez_level = '...';
             } else {
                 $rez_parent = '<a class="breadcrumbs_item cat_post" href="' . get_permalink($pageParent->ID) . '">' . trim(axiom_strshort($pageParent->post_title, $args['truncate_title'], $args['truncate_add'])) . '</a>' . (!empty($rez_parent) ? $args['delimiter'] : '') . $rez_parent;
             }
             if (($pageParentID = $pageParent->post_parent) > 0) {
                 $post_id = $pageParentID;
             }
         }
     }
     $depth = 0;
     $taxonomy = apply_filters('axiom_filter_get_current_taxonomy', '', $type);
     $ex_cats = $taxonomy == 'category' ? explode(',', axiom_get_theme_option('exclude_cats')) : array();
     do {
         if ($depth++ == 0) {
             if (is_single() || is_attachment()) {
                 if ($args['show_all_filters']) {
                     $post_format = get_post_format($post_id);
                     if (($tpl_id = axiom_get_template_page_id('only-' . $post_format)) > 0) {
                         $level++;
                         if ($level > $args['max_levels']) {
                             $rez_level = '...';
                         } else {
                             $rez_all .= (!empty($rez_all) ? $args['delimiter'] : '') . '<a class="breadcrumbs_item all" href="' . get_permalink($tpl_id) . '">' . sprintf(__('All %s', 'axiom'), axiom_get_post_format_name($post_format, false)) . '</a>';
                         }
                     }
                 }
                 $cats = axiom_get_terms_by_post_id(array('post_id' => $post_id, 'taxonomy' => $taxonomy, 'exclude' => $ex_cats));
                 $cat = !empty($cats) && !empty($cats[$taxonomy]->terms) ? $cats[$taxonomy]->terms[0] : false;
                 if ($cat) {
                     $level++;
                     if ($level > $args['max_levels']) {
                         $rez_level = '...';
                     } else {
                         $rez_parent = '<a class="breadcrumbs_item cat_post" href="' . esc_url($cat->link) . '">' . trim(axiom_strshort($cat->name, $args['truncate_title'], $args['truncate_add'])) . '</a>' . (!empty($rez_parent) ? $args['delimiter'] : '') . $rez_parent;
                     }
                 }
             } else {
                 if ($type == 'category') {
                     $cat_id = (int) get_query_var('cat');
                     if (empty($cat_id)) {
                         $cat_id = get_query_var('category_name');
                     }
                     $cat = get_term_by((int) $cat_id > 0 ? 'id' : 'slug', $cat_id, 'category', OBJECT);
                 } else {
                     if (($tax = axiom_is_taxonomy()) != '') {
                         $cat = get_term_by('slug', get_query_var($tax), $tax, OBJECT);
                     }
                 }
             }
             if ($cat) {
                 $parent = $cat->parent;
                 $parentTax = $cat->taxonomy;
             }
         }
         if ($parent) {
             $cat = get_term_by('id', $parent, $parentTax, OBJECT);
             if ($cat) {
                 if (!in_array($cat->term_id, $ex_cats)) {
                     $cat_link = get_term_link($cat->slug, $cat->taxonomy);
                     $level++;
                     if ($level > $args['max_levels']) {
                         $rez_level = '...';
                     } else {
                         $rez_parent = '<a class="breadcrumbs_item cat_parent" href="' . esc_url($cat_link) . '">' . trim(axiom_strshort($cat->name, $args['truncate_title'], $args['truncate_add'])) . '</a>' . (!empty($rez_parent) ? $args['delimiter'] : '') . $rez_parent;
                     }
                 }
                 $parent = $cat->parent;
             }
         }
     } while ($parent);
     if ($args['show_all_posts']) {
         $all_title = axiom_get_stream_page_title($type);
         $all_parts = explode(':', $all_title);
         if (count($all_parts) > 1) {
             $all_title = trim($all_parts[1]);
         }
         if ($all_title && axiom_strtolower($title) != axiom_strtolower($all_title)) {
             $all_link = axiom_get_stream_page_link($type);
             $rez_all = '<a class="breadcrumbs_item all" href="' . esc_url($all_link) . '">' . $all_title . '</a>' . (!empty($rez_all) ? $args['delimiter'] : '') . $rez_all;
         }
     }
     $rez_period = apply_filters('axiom_filter_get_period_links', '', $type, $args['delimiter']);
     if (!is_front_page()) {
         // && !is_home()
         $rez .= (isset($args['home']) && $args['home'] != '' ? '<a class="breadcrumbs_item home" href="' . ($args['home_url'] ? $args['home_url'] : home_url()) . '">' . $args['home'] . '</a>' . $args['delimiter'] : '') . (!empty($rez_all) ? $rez_all . $args['delimiter'] : '') . (!empty($rez_level) ? $rez_level . $args['delimiter'] : '') . (!empty($rez_parent) ? $rez_parent . $args['delimiter'] : '') . (!empty($rez_period) ? $rez_period . $args['delimiter'] : '') . ($title ? '<span class="breadcrumbs_item current">' . $title . '</span>' : '');
     }
     if ($args['echo'] && !empty($rez)) {
         echo $rez;
     }
     axiom_set_global('in_breadcrumbs', false);
     return $rez;
 }