/** * Do not edit anything in this file unless you know what you're doing */ use Roots\Sage\Config; use Roots\Sage\Container; /** * Helper function for prettying up errors * @param string $message * @param string $subtitle * @param string $title */ $sage_error = function ($message, $subtitle = '', $title = '') { $title = $title ?: __('Sage › Error', 'sage'); $footer = 'roots.io/sage/docs/'; $message = "

{$title}
{$subtitle}

{$message}

{$footer}

"; wp_die($message, $title); }; /** * Ensure compatible version of PHP is used */ if (version_compare('7.1', phpversion(), '>=')) { $sage_error(__('You must be using PHP 7.1 or greater.', 'sage'), __('Invalid PHP version', 'sage')); } /** * Ensure compatible version of WordPress is used */ if (version_compare('4.7.0', get_bloginfo('version'), '>=')) { $sage_error(__('You must be using WordPress 4.7.0 or greater.', 'sage'), __('Invalid WordPress version', 'sage')); } /** * Ensure dependencies are loaded */ if (!class_exists('Roots\\Sage\\Container')) { if (!file_exists($composer = __DIR__.'/../vendor/autoload.php')) { $sage_error( __('You must run composer install from the Sage directory.', 'sage'), __('Autoloader not found.', 'sage') ); } require_once $composer; } /** * Sage required files * * The mapped array determines the code library included in your theme. * Add or remove files to the array as needed. Supports child theme overrides. */ array_map(function ($file) use ($sage_error) { $file = "../app/{$file}.php"; if (!locate_template($file, true, true)) { $sage_error(sprintf(__('Error locating %s for inclusion.', 'sage'), $file), 'File not found'); } }, ['helpers', 'setup', 'filters', 'admin']); /** * Here's what's happening with these hooks: * 1. WordPress initially detects theme in themes/sage/resources * 2. Upon activation, we tell WordPress that the theme is actually in themes/sage/resources/views * 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage/resources * * We do this so that the Template Hierarchy will look in themes/sage/resources/views for core WordPress themes * But functions.php, style.css, and index.php are all still located in themes/sage/resources * * This is not compatible with the WordPress Customizer theme preview prior to theme activation * * get_template_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources * get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources * locate_template() * ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views * └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources */ array_map( 'add_filter', ['theme_file_path', 'theme_file_uri', 'parent_theme_file_path', 'parent_theme_file_uri'], array_fill(0, 4, 'dirname') ); Container::getInstance() ->bindIf('config', function () { return new Config([ 'assets' => require dirname(__DIR__).'/config/assets.php', 'theme' => require dirname(__DIR__).'/config/theme.php', 'view' => require dirname(__DIR__).'/config/view.php', ]); }, true); function themeslug_theme_customizer($wp_customize) { $wp_customize->add_section('theme_logo_section', array( 'title' => __('Theme Logo', 'theme'), 'priority' => 35, 'description' => 'Upload a logo to replace the default site name and description in the header', )); $wp_customize->add_setting('theme_logo'); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'theme_logo', array( 'label' => __('Logo', 'theme'), 'section' => 'theme_logo_section', 'settings' => 'theme_logo', ))); $wp_customize->add_setting('foo_logo'); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'foo_logo', array( 'label' => __('Footer Logo', 'theme'), 'section' => 'theme_logo_section', 'settings' => 'foo_logo', ))); } add_action('customize_register', 'themeslug_theme_customizer'); require_once('wp_bootstrap_navwalker.php'); if( function_exists('acf_add_options_page') ) { acf_add_options_page(array( 'page_title' => 'General Company Information', 'menu_title' => 'Company Information', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', 'redirect' => false )); } function custom_secondary_header() { $labels = array( 'name' => _x( 'Home Header', 'Post Type General Name', 'sage' ), 'singular_name' => _x( 'Home Header', 'Post Type Singular Name', 'sage' ), 'menu_name' => __( 'Home Header','sage' ), 'name_admin_bar' => __( 'Home Headers', 'sage' ), ); $args = array( 'label' => __( 'Home Header', 'sage' ), 'labels' => $labels, 'supports' => array( 'title', 'thumbnail', ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-images-alt2', 'menu_position' => 5, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'home_header', $args ); $labels = array( 'name' => _x( 'Secondary Header', 'Post Type General Name', 'sage' ), 'singular_name' => _x( 'Secondary Header', 'Post Type Singular Name', 'sage' ), 'menu_name' => __( 'Secondary Header','sage' ), 'name_admin_bar' => __( 'Secondary Headers', 'sage' ), ); $args = array( 'label' => __( 'Secondary Header', 'sage' ), 'labels' => $labels, 'supports' => array( 'title', 'thumbnail', ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-images-alt2', 'menu_position' => 5, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type('secondary_header', $args ); $servicelabels = array( 'name' => 'Testimonials', 'singular_name' => 'Testimonial', 'menu_name' => 'Testimonials', 'name_admin_bar' => 'Testimonials', 'archives' => 'Testimonial Archives', 'attributes' => 'Testimonial Attributes', 'parent_item_colon' => 'Parent Testimonial:', 'all_items' => 'All Testimonials', 'add_new_item' => 'Add New Testimonial', 'add_new' => 'Add New', 'new_item' => 'New Testimonial', 'edit_item' => 'Edit Testimonial', 'update_item' => 'Update Testimonial', 'view_item' => 'View Testimonial', 'view_items' => 'View Testimonials', 'search_items' => 'Search Testimonial', 'not_found' => 'Not found', 'not_found_in_trash' => 'Not found in Trash', 'featured_image' => 'Featured Image', 'set_featured_image' => 'Set featured image', 'remove_featured_image' => 'Remove featured image', 'use_featured_image' => 'Use as featured image', 'insert_into_item' => 'Insert into Testimonial', 'uploaded_to_this_item' => 'Uploaded to this Testimonial', 'items_list' => 'Testimonials list', 'items_list_navigation' => 'Testimonials list navigation', 'filter_items_list' => 'Filter Testimonials list', ); $testimonialargs = array( 'label' => 'Testimonial', 'description' => 'Testimonials will be updated and managed here', 'labels' => $servicelabels, 'supports' => array( 'title', 'editor', '', '', ), 'taxonomies' => array( '', '' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 15, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'testimonial', $testimonialargs ); $labels = array( 'name' => _x( 'Faqs', 'Post Type General Name', 'chooselifemarketing' ), 'singular_name' => _x( 'Faq', 'Post Type Singular Name', 'chooselifemarketing' ), 'menu_name' => __( 'Faqs', 'chooselifemarketing' ), 'name_admin_bar' => __( 'Faqs', 'chooselifemarketing' ), 'archives' => __( 'Faqs Archives', 'chooselifemarketing' ), 'attributes' => __( 'Faqs Attributes', 'chooselifemarketing' ), 'parent_item_colon' => __( 'Parent Faqs:', 'chooselifemarketing' ), 'all_items' => __( 'All Faqs', 'chooselifemarketing' ), 'add_new_item' => __( 'Add New faq', 'chooselifemarketing' ), 'add_new' => __( 'Add New', 'chooselifemarketing' ), 'new_item' => __( 'New faq', 'chooselifemarketing' ), 'edit_item' => __( 'Edit faq', 'chooselifemarketing' ), 'update_item' => __( 'Update faq', 'chooselifemarketing' ), 'view_item' => __( 'View faq', 'chooselifemarketing' ), 'view_items' => __( 'View Faq', 'chooselifemarketing' ), 'search_items' => __( 'Search Faqs', 'chooselifemarketing' ), 'not_found' => __( 'Not found', 'chooselifemarketing' ), 'not_found_in_trash' => __( 'Not found in Trash', 'chooselifemarketing' ), 'featured_image' => __( 'Featured Image', 'chooselifemarketing' ), 'set_featured_image' => __( 'Set featured image', 'chooselifemarketing' ), 'remove_featured_image' => __( 'Remove featured image', 'chooselifemarketing' ), 'use_featured_image' => __( 'Use as featured image', 'chooselifemarketing' ), 'insert_into_item' => __( 'Insert into faq', 'chooselifemarketing' ), 'uploaded_to_this_item' => __( 'Uploaded to this faq', 'chooselifemarketing' ), 'items_list' => __( 'faq list', 'chooselifemarketing' ), 'items_list_navigation' => __( 'faq list navigation', 'chooselifemarketing' ), 'filter_items_list' => __( 'Filter faq list', 'chooselifemarketing' ), ); $args = array( 'label' => __( 'Faq', 'chooselifemarketing' ), 'description' => __( 'Post Type Description', 'chooselifemarketing' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'revisions', ), 'taxonomies' => array( 'category', 'post_tag' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 15, 'menu_icon' => 'dashicons-format-status', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'faqs', $args ); } add_action( 'init', 'custom_secondary_header', 0 ); function sidebar_testimonial( $atts ) { extract(shortcode_atts(array( 'order' => 'asc' ), $atts)); $output = ''; $i = 1; $output .='
'; return $output; } add_shortcode( 'testimonials', 'sidebar_testimonial' ); add_shortcode( 'faq', 'faq_shortcode' ); function faq_shortcode(){ $args=array( 'posts_per_page'=> -1, 'post_type'=> 'faqs', ); query_posts( $args ); $cvaction = ''; if( have_posts() ) : while( have_posts() ): the_post(); $cvaction .= '
'; $cvaction .= '

'.get_the_title().'

'.get_the_content().'
'; endwhile; wp_reset_query(); wp_reset_postdata(); endif; return $cvaction; } // Enable shortcodes in text widgets add_filter('widget_text','do_shortcode'); function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'cc_mime_types'); function custom_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt) >= $limit) { array_pop($excerpt); $excerpt = implode(" ", $excerpt) . '...'; } else { $excerpt = implode(" ", $excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt); return $excerpt; } add_action('wp_loaded', 'output_buffer_start'); function output_buffer_start() { ob_start("output_callback"); } function output_callback($buffer) { return preg_replace( "%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%", '', $buffer ); } add_filter( 'gform_confirmation_anchor', '__return_false' ); function custom_excerpt_more( $more ) { return '';//you can change this to whatever you want } add_filter( 'excerpt_more', 'custom_excerpt_more' ); add_image_size( 'crunchify-admin-post-featured-image', 120, 120, false ); // Add the posts and pages columns filter. They can both use the same function. add_filter('manage_posts_columns', 'show_featured_image', 2); add_filter('manage_pages_columns', 'show_featured_image', 2); // Add the column function show_featured_image($crunchify_columns){ $crunchify_columns['crunchify_thumb'] = __('Featured Image'); return $crunchify_columns; } // Let's manage Post and Page Admin Panel Columns add_action('manage_posts_custom_column', 'show_post_featured_image', 5, 2); add_action('manage_pages_custom_column', 'show_post_featured_image', 5, 2); // Here we are grabbing featured-thumbnail size post thumbnail and displaying it function show_post_featured_image($crunchify_columns, $crunchify_id){ switch($crunchify_columns){ case 'crunchify_thumb': if( function_exists('the_post_thumbnail') ) echo the_post_thumbnail( 'crunchify-admin-post-featured-image' ); else echo 'hmm... your theme doesn\'t support featured image...'; break; } } function filter_category_title($title) { return str_replace(array('Category: ', 'Archives: '), '', $title); } add_filter('get_the_archive_title', 'filter_category_title'); function calevir_add_excerpt_support_for_pages() { add_post_type_support( 'page', 'excerpt' ); } add_action( 'init', 'calevir_add_excerpt_support_for_pages' ); add_action( 'after_setup_theme', function() { add_theme_support( 'responsive-embeds' ); } ); function cvloadcat_ajax_handler(){ $args=array( 'posts_per_page'=> 3, 'post_type'=> 'post', ); $args['paged'] = $_POST['page'] + 1; $args['post_status'] = 'publish'; query_posts( $args ); $cvaction = ''; if( have_posts() ) : global $wp_query; while( have_posts() ): the_post(); $cvaction .= '
'; if(has_post_thumbnail()) { $cvaction .= '
'; } $cvaction .= '

'.get_the_title().'

'.get_the_excerpt().'

Read More

'; endwhile; $posts= json_encode($wp_query->query_vars); $max_page = $wp_query->max_num_pages; wp_reset_query(); wp_reset_postdata(); endif; $cvaction .= ob_get_clean(); $data = array( "actiondata" => $cvaction, "posts" => $posts, 'max_page' => $max_page ); echo json_encode($data); wp_die(); } add_action('wp_ajax_loadmore', 'cvloadcat_ajax_handler'); // wp_ajax_{action} add_action('wp_ajax_nopriv_loadmore', 'cvloadcat_ajax_handler'); // wp_ajax_nopriv_{action} add_filter( 'wp_lazy_loading_enabled', '__return_false' ); function crunchify_stop_loading_wp_embed_and_jquery() { if (!is_admin()) { wp_deregister_script('wp-embed'); wp_deregister_script('regenerator-runtime'); wp_deregister_script('wp-polyfill'); wp_deregister_script('wp-i18n'); } } add_action('init', 'crunchify_stop_loading_wp_embed_and_jquery'); if ( !is_admin() && ( ! defined('DOING_AJAX') || ( defined('DOING_AJAX') && ! DOING_AJAX ) ) ) { ob_start( 'html5_slash_fixer' ); add_action( 'shutdown', 'html5_slash_fixer_flush' ); } function html5_slash_fixer( $buffer ) { return str_replace( ' />', '>', $buffer ); } function html5_slash_fixer_flush() { ob_end_flush(); }