__( 'Top Menu', 'cactus' ), 'home' => __( 'Front Page Top Menu', 'cactus' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'gallery', 'caption', ) ); // Add theme support for Custom Logo. add_theme_support( 'custom-logo', array( 'width' => 152, 'height' => 50, 'flex-width' => true, ) ); // Setup the WordPress core custom header feature. add_theme_support( 'custom-header', array( 'default-image' => '', 'random-default' => false, 'width' => '1920', 'height' => '70', 'flex-height' => true, 'flex-width' => true, 'default-text-color' => '#333333', 'header-text' => true, 'uploads' => true, 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '' )); // Setup the WordPress core custom background feature. add_theme_support( 'custom-background', array( 'default-color' => 'ffffff', 'default-image' => '', ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); // Woocommerce Support add_theme_support( 'woocommerce' ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); /* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, and column width. */ add_editor_style( array( 'assets/css/editor-style.css' ) ); } add_action( 'after_setup_theme', 'cactus_setup' ); /** * Enqueue scripts and styles. */ function cactus_scripts() { global $cactus_options, $cactus_sections; $cactus_options = get_option(CACTUS_TEXTDOMAIN); $headings_font_family = esc_attr(cactus_option( 'headings_font_family')); $body_font_family = esc_attr(cactus_option( 'body_font_family')); $fonts[] = $headings_font_family; $fonts[] = $body_font_family; wp_enqueue_style( 'cactus-google-fonts', customizer_library_get_google_font_uri($fonts), false, '', false ); wp_enqueue_style( 'bootstrap', get_template_directory_uri() .'/assets/plugins/bootstrap/css/bootstrap.css', false, '', false ); wp_enqueue_style( 'font-awesome', get_template_directory_uri() .'/assets/plugins/font-awesome/css/font-awesome.min.css', false, '', false ); wp_enqueue_style( 'owl-carousel', get_template_directory_uri() .'/assets/plugins/owl-carousel/css/owl.carousel.css', false, '', false ); // Theme stylesheet. wp_enqueue_style( 'cactus-style', get_stylesheet_uri() ); if(is_page_template( 'template-sections.php' )){ wp_enqueue_style( 'cactus-frontpage', get_template_directory_uri() .'/assets/css/frontpage.css' ); wp_enqueue_style( 'animate', get_template_directory_uri() .'/assets/plugins/animate.css' ); } wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/plugins/bootstrap/js/bootstrap.js' , array( 'jquery' ), null, true); wp_enqueue_script( 'cactus-main', get_template_directory_uri() . '/assets/js/cactus.js' , array( 'jquery' ), null, true); wp_enqueue_script( 'respond', get_template_directory_uri() . '/assets/plugins/respond.min.js' , array( 'jquery' ), null, true); wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/assets/plugins/owl-carousel/js/owl.carousel.min.js' , array( 'jquery' ), null, true); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } $custom_css = ''; $header_text_color = get_header_textcolor(); if ( 'blank' != $header_text_color ) : $custom_css .= ".site-name, .site-tagline { color: #".esc_attr( $header_text_color )." !important; }\r\n"; else: $custom_css .= ".site-name, .site-tagline { display: none; }\r\n"; endif; // Font $custom_css .= "h1,h2,h3,h4,h5,h6{font-family:".$headings_font_family.";}"; $custom_css .= "html, body, div, span, applet, object, iframe, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {font-family:".$body_font_family.";}"; $body_font_size = absint(cactus_option('body_font_size')); $custom_css .= "html, body, div{font-size:".$body_font_size."px;}"; for($i=1;$i<=6;$i++){ $heading_font_size = absint(cactus_option('h'.$i.'_font_size')); $custom_css .= "h".$i."{font-size:".$heading_font_size."px;}"; } foreach($cactus_sections as $key=>$name ){ $font_color = cactus_option('font_color_'.$key); $background_color = cactus_option('background_color_'.$key); $background_image = cactus_option('background_image_'.$key); if (is_numeric($background_image)) { $image_attributes = wp_get_attachment_image_src($background_image, 'full'); $background_image = $image_attributes[0]; } $custom_css .= ".cactus-section-".$key." { background-color:".esc_attr( $background_color )."; background-image:url(".esc_attr( $background_image )."); }\r\n"; $custom_css .= ".cactus-section-".$key." div, .cactus-section-".$key." span, .cactus-section-".$key." h1,.cactus-section-".$key." h2,.cactus-section-".$key." h3,.cactus-section-".$key." h4,.cactus-section-".$key." h5,.cactus-section-".$key." h6,.cactus-section-".$key." p, .cactus-section-".$key." li {color:".esc_attr($font_color).";}"; } wp_add_inline_style( 'cactus-style', wp_filter_nohtml_kses($custom_css) ); } add_action( 'wp_enqueue_scripts', 'cactus_scripts' ); /** * Prints HTML with meta information for the current post-date/time and author. */ function cactus_posted_on() { // Get the author name; wrap it in a link. $byline = sprintf( /* translators: %s: post author */ __( 'by %s', 'cactus' ), ' ' . get_the_author() . '' ); // Finally, let's write all of this to the page. echo '' . cactus_time_link() . ' | ' . $byline . ''; } /** * Gets a nicely formatted string for the published date. */ function cactus_time_link() { $time_string = ''; $time_string = sprintf( $time_string, get_the_date( DATE_W3C ), get_the_date(), get_the_modified_date( DATE_W3C ), get_the_modified_date() ); // Wrap the time string in a link, and preface it with 'Posted on'. return sprintf( /* translators: %s: post date */ __( 'Posted on %s ', 'cactus' ), '' . $time_string . '' ); } /** * Returns an accessibility-friendly link to edit a post or page. */ function cactus_edit_link() { $link = edit_post_link( sprintf( /* translators: %s: Name of current post */ __( 'Edit "%s"', 'cactus' ), get_the_title() ), '', '' ); return $link; } /** * Register widget area. * */ function cactus_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'cactus' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'cactus' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Footer 1', 'cactus' ), 'id' => 'footer-1', 'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Footer 2', 'cactus' ), 'id' => 'footer-2', 'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Footer 3', 'cactus' ), 'id' => 'footer-3', 'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Footer 4', 'cactus' ), 'id' => 'footer-4', 'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'cactus_widgets_init' ); /** * Custom comments list */ function cactus_comment($comment, $args, $depth) { ?>
  • id="comment-">

    - $depth, 'max_depth' => $args['max_depth']))) ;?>

    comment_approved == '0') : ?>
  • '; $after = ''; if ( !is_home() && !is_front_page() || is_paged() ) { echo '
    '; global $post; $homeLink = esc_url(home_url()); echo ' ' . __( 'Home' , 'cactus' ) . ' ' . $delimiter . ' '; if ( is_category() ) { global $wp_query; $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){ $cat_code = get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '); echo $cat_code = str_replace ('' . get_the_time('Y') . ' ' . $delimiter . ' '; echo '' . get_the_time('F') . ' ' . $delimiter . ' '; echo $before . get_the_time('d') . $after; } elseif ( is_month() ) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo $before . get_the_time('F') . $after; } elseif ( is_year() ) { echo $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { if ( get_post_type() != 'post' ) { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '' . $post_type->labels->singular_name . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } else { $cat = get_the_category(); $cat = $cat[0]; $cat_code = get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo $cat_code = str_replace ('labels->singular_name . $after; } elseif ( is_attachment() ) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo '' . $parent->post_title . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif ( is_page() && !$post->post_parent ) { echo $before . get_the_title() . $after; } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '' . get_the_title($page->ID) . ''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif ( is_search() ) { echo $before ; printf( __( 'Search Results for: %s', 'cactus' ), get_search_query() ); echo $after; } elseif ( is_tag() ) { echo $before ; printf( __( 'Tag Archives: %s', 'cactus' ), single_tag_title( '', false ) ); echo $after; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); echo $before ; printf( __( 'Author Archives: %s', 'cactus' ), $userdata->display_name ); echo $after; } elseif ( is_404() ) { echo $before; _e( 'Not Found', 'cactus' ); echo $after; } if ( get_query_var('paged') ) { if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo sprintf( __( '( Page %s )', 'cactus' ), get_query_var('paged') ); } echo '
    '; } } /** * Get option */ function cactus_option($name){ global $cactus_options,$cactus_default_sections; if( isset($cactus_options[$name]) ) return $cactus_options[$name]; elseif(isset($cactus_default_sections[$name])) return $cactus_default_sections[$name]; else return ''; } /** * Do sections */ function cactus_do_sections(){ global $cactus_sections, $cactus_section_key; if( $cactus_sections ){ foreach( $cactus_sections as $key=>$value){ $section_id = cactus_option('section_id_'.$key); $section_hide = cactus_option('section_hide_'.$key); $cactus_section_key = $key; if( $section_hide != '1' ): echo '
    '; do_action('cactus_before_section_'.$key); get_template_part('sections/template',$key); do_action('cactus_after_section_'.$key); echo '
    '; endif; } } } add_action('cactus_sections','cactus_do_sections'); /** * Include the TGM_Plugin_Activation class. */ load_template( trailingslashit( get_template_directory() ) . 'inc/class-tgm-plugin-activation.php' ); add_action( 'tgmpa_register', 'cactus_theme_register_required_plugins' ); /** * Register the required plugins for this theme. * */ function cactus_theme_register_required_plugins() { $plugins = array( array( 'name' => __('Cactus Companion','cactus'), // The plugin name 'slug' => 'cactus-companion', // The plugin slug (typically the folder name) 'source' => esc_url('https://downloads.wordpress.org/plugin/cactus-companion.zip'), // The plugin source 'required' => false, // If false, the plugin is only 'recommended' instead of required 'version' => '1.0.0', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins 'external_url' => '', // If set, overrides default API URL and points to an external URL ), ); /** * Array of configuration settings. Amend each line as needed. */ $config = array( 'id' => 'cactus-companion', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to pre-packaged plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. ); tgmpa( $plugins, $config ); }