' . __('WARNING: error defining Custom Field on Page with Posts.', 'absolute-weaver' /*adm*/) . ''); if (strlen($info) > 0) echo('More info: '.$info.'
'); } // # PAGE WITH POSTS ============================================================== function aweaver_get_page() { /* get the current posts display number needed for when Page with Posts is front page */ $paged = get_query_var('paged'); if (!isset($paged) || empty($paged)) { $paged = 1; } $page = get_query_var( 'page' ); if ( $page > 1) $paged = $page; return $paged; } function aweaver_setup_post_args($args) { /* setup WP_Query arg list */ $cats = aweaver_get_page_categories(); if (!empty($cats)) $args['cat'] = $cats; $tags = aweaver_get_page_tags(); if (!empty($tags)) $args['tag'] = $tags; $onepost = aweaver_get_page_onepost(); if (!empty($onepost)) $args['name'] = $onepost; $orderby = aweaver_get_page_orderby(); if (!empty($orderby)) $args['orderby'] = $orderby; $order = aweaver_get_page_order(); if (!empty($order)) $args['order'] = $order; $author_name = aweaver_get_page_author(); if (!empty($author_name)) { $nosp = str_replace(' ', '', $author_name); $id_list=str_replace(',','',$nosp); if (is_numeric($id_list)) { $args['author'] = $author_name; } else { $args['author_name'] = $author_name; } } $posts_per_page = aweaver_get_page_posts_per(); if (!empty($posts_per_page)) $args['posts_per_page'] = $posts_per_page; $post_type = aweaver_get_per_page_value('_pp_post_type'); if ($post_type) $args['post_type'] = $post_type; if (aweaver_is_checked_page_opt('_pp_hide_sticky')) $args['ignore_sticky_posts'] = true; return $args; } function aweaver_get_page_categories() { $cats = aweaver_get_per_page_value('_pp_category'); if (empty($cats)) return ''; // now convert slugs to ids return aweaver_cat_slugs_to_ids($cats); } function aweaver_cat_slugs_to_ids($cats) { if (empty($cats)) return ''; // now convert slugs to numbers $cats = str_replace(' ','',$cats); $clist = explode(',',$cats); // break into a list $cat_list = ''; foreach ($clist as $slug) { $neg = 1; // not negative if ($slug[0] == '-') { $slug = substr($slug,1); // zap the - $neg = -1; } if (strlen($slug) > 0 && is_numeric($slug)) { // allow both slug and id $cat_id = $neg * (int)$slug; if ($cat_list == '') $cat_list = strval($cat_id); else $cat_list .= ','.strval($cat_id); } else { $cur_cat = get_category_by_slug($slug); if (is_object($cur_cat)) { $cat_id = $neg * (int)$cur_cat->cat_ID; if ($cat_list == '') $cat_list = strval($cat_id); else $cat_list .= ','.strval($cat_id); } } } if (empty($cat_list)) $cat_list='99999999'; return $cat_list; } function aweaver_get_page_tags() { $tags = aweaver_get_per_page_value('_pp_tag'); if (empty($tags)) return ''; return str_replace(' ','',$tags); } function aweaver_get_page_onepost() { $the_post = aweaver_get_per_page_value('_pp_onepost'); if (empty($the_post)) return ''; return $the_post; } function aweaver_get_page_orderby() { $orderby = aweaver_get_per_page_value('_pp_orderby'); if (empty($orderby)) return ''; if ($orderby == 'author' || $orderby == 'date' || $orderby == 'title' || $orderby == 'rand') return $orderby; aweaver_page_posts_error(__('orderby must be author, date, title, or rand. You used: ', 'absolute-weaver' /*adm*/). $orderby); return ''; } function aweaver_get_page_order() { $order = aweaver_get_per_page_value('_pp_sort_order'); if (empty($order)) return ''; if ($order == 'ASC' || $order == 'DESC') return $order; aweaver_page_posts_error(__('order value must be ASC or DESC. You used: ', 'absolute-weaver' /*adm*/). $order); return ''; } function aweaver_get_page_posts_per() { $ppp = aweaver_get_per_page_value('_pp_posts_per_page'); if (empty($ppp)) return ''; // now convert slugs to numbers return $ppp; } function aweaver_get_page_author() { $author = aweaver_get_per_page_value('_pp_author'); if (empty($author)) return ''; return $author; } // # FILTERS ============================================================== // ============ validation filters =============== function aweaver_filter_textarea( $text ) { // virtually all option text input from Absolute Weaver can be code, and thus must not be // content filtered. Treat like code for now.... return aweaver_filter_code($text); } function aweaver_esc_textarea($text, $echo=true) { if ( current_user_can('unfiltered_html') ) $out = esc_textarea($text); else $out = esc_textarea(stripslashes($text)); if ($echo) echo $out; else return $out; } function aweaver_filter_head( $text ) { $allowed_head_tags = array( 'title' => array(), 'style' => array( 'media' => true, 'scoped' => true, 'type' => true ), 'meta' => array( 'charset' => true, 'content' => true, 'http-equiv' => true, 'name' => true, 'scheme' => true, 'property'=> true ), 'link' => array( 'href' => true, 'rel' => true, 'type' => true, 'title' => true, 'media' => true, 'id' => true, 'class' => true, 'sizes' => true, 'crossorigin' => true, 'hreflang' => true ), 'script' => array( 'async' => true, 'charset' => true, 'defer' => true, 'src' => true, 'type' => true ), 'noscript' => array(), 'base' => array( 'href' => true, 'target' => true ) ); // restrict head code to valid stuff for $noslash = trim(stripslashes($text)); if ($noslash == '') return ''; if ( current_user_can('unfiltered_html') ) { if (strpos( $noslash, 's from being broken return wp_kses( $noslash, $allowed_head_tags); } else { return ''; // wp_filter_post_kses() handles slashes } } function aweaver_filter_code( $text ) { // Much option input from Absolute Weaver can be code, and thus must not be // content filtered - at least for admins. The utf8 check is about the extent of it, although even // that is more restrictive than the standard text widget uses. // Note: this check also works OK for simple checkboxes/radio buttons/selections, // so it is ok to blindly pass those options in here, too. //$noslash = trim(stripslashes($text)); $trimmed = trim($text); if ($trimmed == ' ') return ''; if ( current_user_can('unfiltered_html') ) { return wp_check_invalid_utf8( $trimmed ); } else { return wp_filter_post_kses( $trimmed ); // wp_filter_post_kses() handles slashes } } function aweaver_echo_css( $css ) { if ( is_multisite() ) { // non-superadmins have some filtering on CSS - this will fix it. //$css = stripslashes($css); $css = str_replace( array('<','>'), array('<','>'), $css); } echo $css; } // # MISC ============================================================== function aweaver_schema( $who, $aux = '' ) { // added 3.1.13 // apply schema.org info where we can. // NOTE: This filter MUST be defined or else the $who arg will be echoed. //return ''; if ( aweaver_getopt_checked ('_no_schemea') ) // Oops! This is misspelled. Too late now, must stay that way... return $aux; // return $aux if not emitting - i.e., 'image', 'person' switch ( $who ) { case 'archive': case 'author': case 'blog': case 'category': case 'single': case 'tag': return ' itemtype="https://schema.org/Blog" itemscope'; case 'body': if ( is_search() ) { return ' itemtype="https://schema.org/SearchResultsPage" itemscope'; } else return ' itemtype="https://schema.org/WebPage" itemscope'; case 'branding': return ' itemtype="https://schema.org/WPHeader" itemscope'; case 'entry-content': return ''; // doesnt work?? ' itemprop="mainEntityOfPage"'; case 'footer': return ' itemtype="https://schema.org/WPFooter" itemscope'; case 'headline': return ' itemprop="headline name"'; case 'image': $fix = str_replace( 'src=', 'itemprop="url" src=', $aux); // add in url prop return '' . $fix . ''; case 'attachment': return ' itemtype="https://schema.org/ImageObject" itemprop="image" itemscope' ; case 'mainEntityOfPage': return ''; case 'menu': return ' itemtype="https://schema.org/SiteNavigationElement" itemscope'; case 'person': return ''; case 'post': if ( is_search() ) { return ' itemtype="https://schema.org/Article" itemscope'; // searches don't want to be Blogs, just articles } else { return ' itemtype="https://schema.org/BlogPosting" itemscope itemprop="blogPost"'; } case 'image': case 'page': return ' itemtype="https://schema.org/WebPageElement" itemscope itemprop="mainContentOfPage"'; case 'published':// $schema = '' . "\n" . '' . "\n" . '' . '' . get_bloginfo('name') . ""; $logo = aweaver_get_wp_custom_logo_url(); if ( $logo != '' ) { $schema .= ''; } else { $schema .= ''; } $schema .= "\n"; break; case 'show_posts_begin': return '
' . "\n"; case 'show_posts_end': return '
'; case 'sidebar': return ' itemtype="https://schema.org/WPSideBar" itemscope'; default: return ''; } return $schema; } function aweaver_get_the_author() { // to allow person schema return aweaver_schema( 'person', esc_html(get_the_author()) ); } function aweaver_header_widget_area( $where_now ) { // header.php support // 'top' => 'Top of Header' // 'after_header' => 'After Header Image' // 'after_html' => 'After HTML Block' // 'after_menu' => 'After Main Menu' $sb_position = aweaver_getopt_default('header_sb_position', 'top'); if ( $sb_position == $where_now ) { do_action('aweaver_alt_header_image'); // support plugins to add alternate header image if ( aweaver_has_widgetarea('header-widget-area') ) { $p_class = aweaver_area_class('header_sb', 'notpad', '-none', 'margin-none'); if ( aweaver_getopt('expand_header-widget-area') && !aweaver_getopt('expand_header') ) $p_class .= ' wvrx-expand-full'; if ( aweaver_getopt('header_sb_fixedtop') ) $p_class .= ' wvrx-fixedtop'; //aweaver_clear_both('header_sb'); aweaver_put_widgetarea('header-widget-area', $p_class, 'header'); if (aweaver_getopt('header_sb_align') == 'float-right') aweaver_clear_both('header-widget-area'); } } } function aweaver_add_ie_scripts() { // Now we need to polyfill IE8. We need 2 scripts loaded AFTER the .css stylesheets. wp_enqueue_script // does not work because it can't add the test for < IE9. And you can't just include the code directly // right here because it ends up before the .css enqueues. So we use a little trick as an action for // wp_head which lets us put the code here, but have it emitted after the .css files. echo ''; } function aweaver_media_lib_button($fillin = '') { ?>  ←  '; if ($echo) echo $link; else return $link; } function aweaver_post_count_clear() { global $aweaver_cur_post_count; $aweaver_cur_post_count = 0; } function aweaver_post_count_bump() { global $aweaver_cur_post_count; $aweaver_cur_post_count++; } function aweaver_post_count() { global $aweaver_cur_post_count; return $aweaver_cur_post_count; } if (!function_exists('aweaver_archive_loop')) : function aweaver_archive_loop( $type ) { // output loop for archive-like pages. $num_cols = aweaver_getopt('blog_cols'); $archive_cols = aweaver_getopt('archive_cols'); if (!$num_cols || $num_cols > 3) $num_cols = 1; if (!$archive_cols) $num_cols = 1; $col = 0; aweaver_post_count_clear(); echo ("
\n"); // needed here, and all post loops to make content-n-col work with :nth-of-type while ( have_posts() ) { the_post(); aweaver_post_count_bump(); switch ($num_cols) { case 1: get_template_part( 'templates/content', get_post_format() ); break; case 2: $col++; echo ('
' . "\n"); get_template_part( 'templates/content', get_post_format() ); echo ("
\n"); break; case 3: $col++; echo ('
' . "\n"); get_template_part( 'templates/content', get_post_format() ); echo ("
\n"); break; default: get_template_part( 'templates/content', get_post_format() ); } // end switch num cols } // end while have posts echo ("
\n"); } endif; function aweaver_post_class($hidecount = false) { global $aweaver_cur_post_count; global $aweaver_sticky; if ($aweaver_sticky) // For page with posts - re-ordering sticky posts $postclass = 'post-area sticky '; else $postclass = 'post-area '; if (has_post_thumbnail()) { $fi = aweaver_get_per_post_value( '_pp_post_fi_location'); if ( !$fi ) $fi = aweaver_getopt_default( 'post_fi_location','content-top' ); if (strpos($fi, 'parallax-full') !== false ) { $postclass .= 'wvrx-fullwidth wvrx-parallax '; } elseif (strpos($fi, 'parallax') !== false ) { $postclass .= 'wvrx-parallax '; } $postclass.= "post-fi-{$fi} "; } if ($aweaver_cur_post_count != 0 && !$hidecount) $postclass .= 'post-' . (($aweaver_cur_post_count % 2) ? 'odd' : 'even') . ' post-order-' . $aweaver_cur_post_count . ' '; $author_id = get_the_author_meta('ID'); if ($author_id) $postclass .= "post-author-id-{$author_id} "; return $postclass . aweaver_area_class('post', 'pad', '-tb', 'margin-bottom' ); } function aweaver_use_inline_css($css_file = '') { return aweaver_getopt_checked('_inline_style') || !aweaver_f_exists($css_file) || is_customize_preview(); // also force inline when customizer is active (even in another tab!) } function aweaver_allow_multisite() { // return true if it is allowed to use on MultiSite $restrict = (defined('ABSOLUTE_WVR_MULTISITE_RESTRICT_OPTIONS')) ? ABSOLUTE_WVR_MULTISITE_RESTRICT_OPTIONS : false; return ((!is_multisite() && current_user_can('install_themes')) || (is_multisite() && current_user_can('manage_network_themes')) || !$restrict); } function aweaver_help_link($link, $info, $alt_label = '', $echo = true) { /*. 'Click for help */ $t_dir = aweaver_relative_url('') . 'help/' . $link; $alt_trans = $link; $hash = strpos($alt_trans, '#'); if ( $hash !== false ) { $alt_trans = substr( $alt_trans, 0, $hash ); // kill off any # anchor } $locale = apply_filters('theme_locale', get_locale(), 'absolute-weaver'); if ( aweaver_f_exists(WP_LANG_DIR . '/weaver-xtreme/' . $locale . '_' . $alt_trans ) ) { // works for default installation $t_dir = content_url() . '/languages/weaver-xtreme/' . $locale . '_' . $link; } if ( !$alt_label ) $alt_label = ''; $out = '' . $alt_label . ''; if ($echo) echo $out; else return $out; } function aweaver_html_br($count = 1) { for ($i = 0; $i < $count ; $i++) { echo '
'; } } function aweaver_compact_post() { return false; // no support for Absolute Weaver } function aweaver_get_first_post_image($content='') { if (has_post_thumbnail()) { $img = wp_get_attachment_image_src( get_post_thumbnail_id( ), 'medium' ); return ''; } if ($content == '') $content = do_shortcode(apply_filters( 'the_content', get_the_content(''))); // pick up wp 3.6 post format meta image if (preg_match('/]+>/i',$content, $images)) { // grab s $src = ''; if (preg_match('/src="([^"]*)"/', $images[0], $srcs)) { $src = $srcs[0]; } else if (preg_match("/src='([^']*)'/", $images[0], $srcs)) { $src = $srcs[0]; } return ''; } else { return ''; } } if (!function_exists('aweaver_breadcrumb')) { function aweaver_breadcrumb($echo = true, $pwp = '' ) { /* Breadcrumbs * Credit: Dimox * http://dimox.net/wordpress-breadcrumbs-without-a-plugin/ */ $wrap = 'breadcrumbs'; $bc = ''; $containerBefore = ''; $containerAfter = ''; $containerCrumb = ''; $containerCrumbEnd = ''; $delimiter = apply_filters('aweaver_breadcrumb_delimiter', '→'); //' » '; $baseLink = ''; $hierarchy = ''; $currentLocation = ''; $currentBefore = ''; $currentAfter = ''; $currentLocationLink = ''; $crumbPagination = ''; if ( aweaver_getopt('menu_nohome')) { $name = aweaver_getopt('info_home_label') ? aweaver_getopt('info_home_label') : esc_attr( get_bloginfo( 'name', 'display' ) ); } else { $name = aweaver_getopt('info_home_label') ? aweaver_getopt('info_home_label') : __('Home','absolute-weaver'); //text for the 'Home' link } global $post; if ( $pwp ) { $name = $pwp; } $bc = ''; // Output the Base Link if ( is_front_page() ) { $bc .= $currentBefore . $name . $currentAfter; } else { $home = home_url('/'); $baseLink = '' . $name . ''; $bc .= $baseLink; } // Define Category Hierarchy Crumbs for Category Archive if ( is_category() ) { global $wp_query; if (is_object($wp_query->get_queried_object())) { $cat_obj = $wp_query->get_queried_object(); $thisCat = $cat_obj->term_id; $thisCat = get_category($thisCat); $parentCat = get_category($thisCat->parent); if ($thisCat->parent != 0) { $hierarchy = ( $delimiter . __( 'Categories','absolute-weaver') . ' ' . get_category_parents( $parentCat, TRUE, $delimiter ) ); } else { $hierarchy = $delimiter . __( 'Categories','absolute-weaver') . ' '; } } else { $hierarchy = ''; } // Set $currentLocation to the current category $currentLocation = single_cat_title( '' , FALSE ); } // Define Crumbs for Day/Year/Month Date-based Archives elseif ( is_date() ) { // Define Year/Month Hierarchy Crumbs for Day Archive if ( is_day() ) { $date_string = '' . get_the_time('Y') . ' ' . $delimiter . ' ' . '' . get_the_time('F') . ' '; $date_string .= $delimiter . ' '; $currentLocation = get_the_time('d'); } // Define Year Hierarchy Crumb for Month Archive elseif ( is_month() ) { $date_string = '' . get_the_time('Y') . ' '; $date_string .= $delimiter . ' '; $currentLocation = get_the_time('F'); } // Set CurrentLocation for Year Archive elseif ( is_year() ) { $date_string = ''; $currentLocation = get_the_time('Y'); } $hierarchy = $delimiter . __( 'Published','absolute-weaver') . ' ' . $date_string ; } // Define Category Hierarchy Crumbs for Single Posts elseif ( is_single() && !is_attachment() ) { $cats = get_the_category(); if ($cats) $cur_cat = $cats[0]; else $cur_cat = ''; if ($cats) { foreach ($cats as $cat) { $children = get_categories( array ('parent' => $cat->term_id )); if (count($children) == 0) { $cur_cat = $cat; break; } } } if ($cur_cat) { $hierarchy = $delimiter . get_category_parents( $cur_cat, TRUE, $delimiter ); } else { $hierarchy = $delimiter . ''; } // Note: get_the_title() is filtered to output a // default title if none is specified $currentLocation = get_the_title(); } // Define Category and Parent Post Crumbs for Post Attachments elseif ( is_attachment() ) { $parent = get_post($post->post_parent); $cat_parents = ''; if ( get_the_category($parent->ID) ) { $cat = get_the_category($parent->ID); $cat = $cat ? $cat[0] : ''; $cat_parents = get_category_parents( $cat, TRUE, $delimiter ); } $hierarchy = $delimiter . $cat_parents . '' . $parent->post_title . ' ' . $delimiter; // Note: Titles are forced for attachments; the // filename will be used if none is specified $currentLocation = get_the_title(); } // Define Current Location for Parent Pages elseif ( ! is_front_page() && is_page() && ! $post->post_parent ) { $hierarchy = $delimiter; // Note: get_the_title() is filtered to output a // default title if none is specified $currentLocation = get_the_title(); } // Define Parent Page Hierarchy Crumbs for Child Pages elseif ( ! is_front_page() && is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { //$page = get_page($parent_id); $page = get_post($parent_id); $breadcrumbs[] = '' . get_the_title($page->ID) . ''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) { $hierarchy = $hierarchy . $delimiter . $crumb; } $hierarchy = $hierarchy . $delimiter; // Note: get_the_title() is filtered to output a // default title if none is specified $currentLocation = get_the_title(); } // Define current location for Search Results page elseif ( is_search() ) { $hierarchy = $delimiter . __('Search Results','absolute-weaver') . ' '; $currentLocation = get_search_query(); } // Define current location for Tag Archives elseif ( is_tag() ) { $hierarchy = $delimiter . __( 'Tags','absolute-weaver') . ' '; $currentLocation = single_tag_title( '' , FALSE ); } // Define current location for Author Archives elseif ( is_author() ) { $hierarchy = $delimiter . __( 'Author','absolute-weaver') . ' '; $currentLocation = get_the_author_meta( 'display_name', get_query_var( 'author' ) ); } // Define current location for 404 Error page elseif ( is_404() ) { $hierarchy = $delimiter . __( '404','absolute-weaver') . ' '; $currentLocation = __( 'Page not found','absolute-weaver'); } // Define current location for Post Format Archives elseif ( get_post_format() && ! is_home() ) { $hierarchy = $delimiter . __( 'Post Formats','absolute-weaver') . ' '; $currentLocation = get_post_format_string( get_post_format() ) . 's'; } else { global $weavrex_pwp_title; if ( isset( $GLOBALS['aweaver_pwp_title'] ) ) { $currentLocation = $delimiter . $GLOBALS['aweaver_pwp_title']; } } // Build the Current Location Link markup $currentLocationLink = $currentBefore . $currentLocation . $currentAfter; // Define breadcrumb pagination // Define pagination for paged Archive pages if ( get_query_var('paged') && ! function_exists( 'wp_paginate' ) ) { $crumbPagination = ' - ' . __('Page','absolute-weaver') . ' ' . get_query_var('paged'); } // Define pagination for Paged Posts and Pages if ( get_query_var('page') ) { $crumbPagination = ' - ' . __('Page','absolute-weaver') . ' ' . get_query_var('page') . ' '; } // Output the resulting Breadcrumbs $bc .= $hierarchy; // Output Hierarchy $bc .= $currentLocationLink; // Output Current Location $bc .= $crumbPagination; // Output page number, if Post or Page is paginated if (is_rtl()) { $list = explode($delimiter,$bc); // split on the arrow $list = array_reverse($list); $larrow = apply_filters('aweaver_breadcrumb_delimiter_rtl','←'); $bc = implode($larrow,$list); } // Wrap crumbs $bc = apply_filters('aweaver_breadcrumbs', $containerBefore . $containerCrumb . $bc . $containerCrumbEnd . $containerAfter, $bc); if ($echo) echo $bc; else return $bc; return ''; } } if (!function_exists('aweaver_get_paginate_archive_page_links')) { function aweaver_get_paginate_archive_page_links( $type = 'plain', $endsize = 1, $midsize = 1 ) { /** * Paginate Archive Index Page Links * * Code based on codex examples */ global $wp_query, $wp_rewrite; if ( isset( $wp_query->query_vars['paged'] )) { $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; } else { $current = 1; } // Sanitize input argument values if ( ! in_array( $type, array( 'plain', 'list', 'array' ) ) ) $type = 'plain'; $endsize = (int) $endsize; $midsize = (int) $midsize; $big = 999999999; // from codex - an unlikely number, then str_replace. Makes archive no permalinks work if (is_search()) { // works for search on non-permalinks... $base = '%_%'; } else { $base = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); } // Setup argument array for paginate_links() $pagination = array( 'base' => $base, 'format' => '?paged=%#%', 'total' => $wp_query->max_num_pages, 'current' => $current, 'show_all' => false, 'end_size' => $endsize, 'mid_size' => $midsize, 'type' => $type, 'prev_text' => '<<', 'next_text' => '>>' ); if ( !empty($wp_query->query_vars['s']) ) $pagination['add_args'] = array( 's' => get_query_var( 's' ) ); return paginate_links( $pagination ); } } // # MENU ============================================================== class aweaver_Walker_Nav_Menu extends Walker { public $tree_type = array( 'post_type', 'taxonomy', 'custom' ); public $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' ); /** * Starts the list before the elements are added. */ public function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "\n$indent\n"; } /** * Start the element output. */ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; /** * Filter the CSS class(es) applied to a menu item's list item element. */ $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; /** * Filter the ID applied to a menu item's list item element. */ $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $atts = array(); $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; $atts['target'] = ! empty( $item->target ) ? $item->target : ''; $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; $atts['href'] = ! empty( $item->url ) ? $item->url : ''; /** * Filter the HTML attributes applied to a menu item's anchor element. */ $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); $attributes = ''; $aclass = ''; foreach ( $atts as $attr => $value ) { if ( ! empty( $value ) ) { $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); if ( $attr === 'href' && $value === '#' && aweaver_getopt('placeholder_cursor')) { $aclass = ' style="cursor:' . aweaver_getopt('placeholder_cursor') .';"'; } $attributes .= ' ' . $attr . '="' . $value . '"'; } } $item_output = $args->before; $item_output .= ""; /** This filter is documented in wp-includes/post-template.php */ $item_output .= $args->link_before . do_shortcode(apply_filters( 'the_title', $item->title, $item->ID )) . $args->link_after; $item_output .= ""; $item_output .= $args->after; /** * Filter a menu item's starting output. */ $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } /** * Ends the element output, if needed. */ public function end_el( &$output, $item, $depth = 0, $args = array() ) { $output .= "\n"; } } // Walker_Nav_Menu // # FILE BLOCK I/O UTILS ============================================================== /** * Save a big string to a file in the uploads/absolute-wvr-css directory * * @param string $filename, string $output * * @since Version 4 * */ function aweaver_write_to_upload( $filename, $output ) { global $wp_filesystem; if ( empty( $wp_filesystem ) ) { /* load if not already present */ require_once( ABSPATH . '/wp-admin/includes/file.php' ); WP_Filesystem(); } $upload_dir = wp_upload_dir(); // Grab uploads folder array $dir = trailingslashit( $upload_dir['basedir'] ) . 'absolute-wvr-css' . DIRECTORY_SEPARATOR; // Set storage directory path WP_Filesystem(); // Initial WP file system $wp_filesystem->mkdir( $dir ); // Make a new folder 'weavrx-subthemes' for storing our file if not created already. if (!@is_writable($dir)) { // direct php access aweaver_f_file_access_fail(__('Directory not writable to save editor style file. Directory: ', 'absolute-weaver' /*adm*/) . $dir); return; } $wp_filesystem->put_contents( $dir . $filename, $output, 0744 ); // Store in the file. } /* ================== File handling ================== */ function aweaver_f_file_access_fail($who = '') { static $aweaver_f_file_access_fail_sent = false; if ($aweaver_f_file_access_fail_sent) return; // only show once... $aweaver_f_file_access_fail_sent = true; ?>
(But don\'t panic!)

Absolute Weaver is unable to process a file access request. Your WP host seems to have archaic file system access configured. You may need proper FTP credentials set in WordPress, or in your wp-config.php file. It is unusual to see this error. It may be displayed after you move to a new host.

You may have to change the directory permissions on your web hosting server.

', 'absolute-weaver' /*adm*/); ?> ' . __('Diagnostics:', 'absolute-weaver' /*adm*/) . "{$who}

\n"; ?>
alert('" . esc_html($msg) . "'); "; } function aweaver_f_content_dir() { return trailingslashit(WP_CONTENT_DIR); } function aweaver_f_uploads_base_url() { $wpdir = wp_upload_dir(); // get the upload directory return trailingslashit(trim($wpdir['baseurl'])); } /** * Return a big string from a file in the uploads/absolute-wvr-css directory * * @param string $filename * * @since Version 4 * */ function aweaver_read_from_upload( $filename ) { global $wp_filesystem; if ( empty( $wp_filesystem ) ) { /* load if not already present */ require_once( ABSPATH . '/wp-admin/includes/file.php' ); WP_Filesystem(); } $upload_dir = wp_upload_dir(); // Grab uploads folder array $dir = trailingslashit( $upload_dir['basedir'] ) . 'absolute-wvr-css'. DIRECTORY_SEPARATOR; // Set storage directory path if (! file_exists ($dir . $filename) ) return ''; WP_Filesystem(); // Initial WP file system $contents = $wp_filesystem->get_contents( $dir . $filename ); // Store in the file. if ( is_string($contents) ) return $contents; return ''; } // # OTHER UTILS ============================================================== if ( ! function_exists( '_wp_render_title_tag' ) ) { function aweaver_render_title() { ?> <?php wp_title(); ?> \n"; } function aweaver_get_css_filename() { $updir = wp_upload_dir(); return trailingslashit($updir['basedir']) . 'absolute-wvr-css/' . ABSOLUTE_WVR_GENERATED_STYLE_FILE; } function aweaver_get_css_url() { $updir = wp_upload_dir(); // make relative for https: - doesn't work right... $path = trailingslashit($updir['baseurl']) . 'absolute-wvr-css/'. ABSOLUTE_WVR_GENERATED_STYLE_FILE; if (is_ssl()) $path = str_replace('http:','https:',$path); return $path; } function aweaver_get_footer($who) { get_footer( $who ); } //-- function aweaver_generate_id() { if ( !isset($GLOBALS['wvrx_gen_id']) ) $GLOBALS['wvrx_gen_id'] = 1; else $GLOBALS['wvrx_gen_id']++; return $GLOBALS['wvrx_gen_id']; } //-- function aweaver_clear_both( $class = '' ) { if ( $class ) echo '
'; else echo '
'; } function aweaver_relative_url($subpath){ // generate a relative URL from the site's root return parse_url(trailingslashit(get_template_directory_uri()) . $subpath,PHP_URL_PATH); } function aweaver_filter_css($css) { // filter user added CSS for root relative file paths if (strpos($css, '%template_directory%') !== false) $css = str_replace('%template_directory%', parse_url(trailingslashit(get_template_directory_uri()),PHP_URL_PATH) , $css); if (strpos($css, '%stylesheet_directory%') !== false) $css = str_replace('%stylesheet_directory%', parse_url(trailingslashit(get_stylesheet_directory_uri()),PHP_URL_PATH) , $css); if (strpos($css, '%addon_directory%') !== false) $css = str_replace('%addon_directory%' , parse_url(trailingslashit(aweaver_f_uploads_base_url()) . 'absolute-wvr-css/addon-subthemes/',PHP_URL_PATH), $css); return $css; } add_filter('aweaver_css','aweaver_filter_css'); // =============================== transient options ============================= if (!function_exists('aweaver_t_get')) { // interface to [show_posts] function aweaver_t_get( $opt ) { return isset($GLOBALS['aspen_temp_opts'][$opt]) ? $GLOBALS['aspen_temp_opts'][$opt] : ''; } } function aweaver_check_editor_style() { // see if we need an update... if ( !( current_user_can('edit_theme_options') && current_user_can('activate_plugins')) || is_customize_preview()) return; $updir = wp_upload_dir(); $dir = trailingslashit($updir['basedir']) . 'absolute-wvr-css/editor-style-awvr.css'; if (!@file_exists( $dir ) || aweaver_getopt('settings_version') != ABSOLUTE_WVR_SETTINGS_VERSION ){ // save latest version) { if ( aweaver_getopt('settings_version') != ABSOLUTE_WVR_SETTINGS_VERSION ) { aweaver_setopt('settings_version', ABSOLUTE_WVR_SETTINGS_VERSION); // save latest version } aweaver_save_opts('customizer', true); // using customizer helps force for all situations global $wp_settings_errors; $wp_settings_errors = array(); // clear messages for this update setting } } ?>