PHP 8.1.33
Preview: functions.php Size: 11.10 KB
/home/jambtst2015/public_html/tomorrowzfurniture.com/wp-content/themes/franchise/functions.php

<?php
/**
 * Moral functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Moral
 */

if ( ! function_exists( 'franchise_setup' ) ) :
	/**
	 * Sets up theme defaults and registers support for various WordPress features.
	 *
	 * Note that this function is hooked into the after_setup_theme hook, which
	 * runs before the init hook. The init hook is too late for some features, such
	 * as indicating support for post thumbnails.
	 */
	function franchise_setup() {
		/*
		 * Make theme available for translation.
		 * Translations can be filed in the /languages/ directory.
		 * If you're building a theme based on Moral, use a find and replace
		 * to change 'franchise' to the name of your theme in all the template files.
		 */
		load_theme_textdomain( 'franchise' );

		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );

		/*
		 * Let WordPress manage the document title.
		 * By adding theme support, we declare that this theme does not use a
		 * hard-coded <title> tag in the document head, and expect WordPress to
		 * provide it for us.
		 */
		add_theme_support( 'title-tag' );

		/*
		 * Enable support for Post Thumbnails on posts and pages.
		 *
		 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
		 */
		add_theme_support( 'post-thumbnails' );
		
		add_image_size( 'franchise-home-blog', 400, 300, true );

		// This theme uses wp_nav_menu() in one location.
		register_nav_menus( array(
			'primary' => esc_html__( 'Primary', 'franchise' ),
		) );

		/*
		 * Switch default core markup for search form, comment form, and comments
		 * to output valid HTML5.
		 */
		add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );

		// Set up the WordPress core custom background feature.
		add_theme_support( 'custom-background', apply_filters( 'franchise_custom_background_args', array(
			'default-color' => 'ffffff',
			'default-image' => '',
		) ) );

		// Add theme support for selective refresh for widgets.
		// add_theme_support( 'customize-selective-refresh-widgets' );

		/**
		 * Add support for core custom logo.
		 *
		 * @link https://codex.wordpress.org/Theme_Logo
		 */
		add_theme_support( 'custom-logo', array(
			'height'      => 250,
			'width'       => 250,
			'flex-width'  => true,
			'flex-height' => true,
		) );
	    
    	/*
    	 * 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', franchise_fonts_url() ) );

    	// Gutenberg support
		add_theme_support( 'editor-color-palette', array(
	       	array(
				'name' => esc_html__( 'Blue', 'franchise' ),
				'slug' => 'blue',
				'color' => '#2c7dfa',
	       	),
	       	array(
	           	'name' => esc_html__( 'Green', 'franchise' ),
	           	'slug' => 'green',
	           	'color' => '#07d79c',
	       	),
	       	array(
	           	'name' => esc_html__( 'Orange', 'franchise' ),
	           	'slug' => 'orange',
	           	'color' => '#ff8737',
	       	),
	       	array(
	           	'name' => esc_html__( 'Black', 'franchise' ),
	           	'slug' => 'black',
	           	'color' => '#2f3633',
	       	),
	       	array(
	           	'name' => esc_html__( 'Grey', 'franchise' ),
	           	'slug' => 'grey',
	           	'color' => '#82868b',
	       	),
	   	));

		add_theme_support( 'align-wide' );
		add_theme_support( 'editor-font-sizes', array(
		   	array(
		       	'name' => esc_html__( 'small', 'franchise' ),
		       	'shortName' => esc_html__( 'S', 'franchise' ),
		       	'size' => 12,
		       	'slug' => 'small'
		   	),
		   	array(
		       	'name' => esc_html__( 'regular', 'franchise' ),
		       	'shortName' => esc_html__( 'M', 'franchise' ),
		       	'size' => 16,
		       	'slug' => 'regular'
		   	),
		   	array(
		       	'name' => esc_html__( 'larger', 'franchise' ),
		       	'shortName' => esc_html__( 'L', 'franchise' ),
		       	'size' => 36,
		       	'slug' => 'larger'
		   	),
		   	array(
		       	'name' => esc_html__( 'huge', 'franchise' ),
		       	'shortName' => esc_html__( 'XL', 'franchise' ),
		       	'size' => 48,
		       	'slug' => 'huge'
		   	)
		));
		add_theme_support('editor-styles');
		add_theme_support( 'wp-block-styles' );
	}
endif;
add_action( 'after_setup_theme', 'franchise_setup' );

/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function franchise_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'franchise_content_width', 900 );
}
add_action( 'after_setup_theme', 'franchise_content_width', 0 );

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function franchise_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Primary Sidebar', 'franchise' ),
		'id'            => 'sidebar-1',
		'description'   => esc_html__( 'Add widgets here.', 'franchise' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );

	for ( $i=1; $i <= 3; $i++ ) { 
		register_sidebar( array(
			'name'          => esc_html__( 'Footer Widget Area ', 'franchise' )  . $i,
			'id'            => 'footer-' . $i,
			'description'   => esc_html__( 'Add widgets here.', 'franchise' ),
			'before_widget' => '<section id="%1$s" class="widget %2$s">',
			'after_widget'  => '</section>',
			'before_title'  => '<h2 class="widget-title">',
			'after_title'   => '</h2>',
		) );
	}
}
add_action( 'widgets_init', 'franchise_widgets_init' );

/**
 * Register custom fonts.
 */
function franchise_fonts_url() {
	$fonts_url = '';

	$font_families = array();
	
	/*
	 * Translators: If there are characters in your language that are not
	 * supported by Montserrat, translate this to 'off'. Do not translate
	 * into your own language.
	 */
	$montserrat = _x( 'on', 'Montserrat font: on or off', 'franchise' );

	if ( 'off' !== $montserrat ) {
		$font_families[] = 'Montserrat:300,400,500,600,700';
	}

	$playfair_display = _x( 'on', 'Playfair Display font: on or off', 'franchise' );

	if ( 'off' !== $playfair_display ) {
		$font_families[] = 'Playfair Display:400,700';
	}

	$query_args = array(
		'family' => urlencode( implode( '|', $font_families ) ),
		'subset' => urlencode( 'latin,latin-ext' ),
	);

	$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );

	return esc_url_raw( $fonts_url );
}

/**
 * Enqueue scripts and styles.
 */
function franchise_scripts() {
	// Add custom fonts, used in the main stylesheet.
	wp_enqueue_style( 'franchise-fonts', franchise_fonts_url(), array(), null );

	wp_enqueue_style( 'slick', get_theme_file_uri() . '/assets/css/slick.css', '', '1.8.0' );

	wp_enqueue_style( 'slick-theme', get_theme_file_uri() . '/assets/css/slick-theme.css', '', '1.8.0' );

	// blocks
	wp_enqueue_style( 'franchise-blocks', get_template_directory_uri() . '/assets/css/blocks.css' );

	wp_enqueue_style( 'franchise-style', get_stylesheet_uri() );

	wp_enqueue_script( 'packery-pkgd', get_theme_file_uri( '/assets/js/packery.pkgd.js' ), array( 'jquery' ), '20151215', true );

	wp_enqueue_script( 'jquery-matchHeight', get_theme_file_uri( '/assets/js/jquery.matchHeight.js' ), array( 'jquery' ), '20151215', true );

	wp_enqueue_script( 'slick-jquery', get_theme_file_uri( '/assets/js/slick.js' ), array( 'jquery' ), '20151215', true );

	wp_enqueue_script( 'franchise-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array(), '20151215', true );

	wp_enqueue_script( 'franchise-skip-link-focus-fix', get_theme_file_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20151215', true );

	wp_enqueue_script( 'franchise-custom', get_theme_file_uri( '/assets/js/custom.js' ), array(), '20151215', true );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'franchise_scripts' );

/**
 * Enqueue editor styles for Gutenberg
 *
 * @since Franchise 1.0.0
 */
function franchise_block_editor_styles() {
	// Block styles.
	wp_enqueue_style( 'franchise-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ) );
	// Add custom fonts.
	wp_enqueue_style( 'franchise-fonts', franchise_fonts_url(), array(), null );
}
add_action( 'enqueue_block_editor_assets', 'franchise_block_editor_styles' );

/**
 * Custom template tags for this theme.
 */
require get_parent_theme_file_path( '/inc/template-tags.php' );

/**
 * Functions which enhance the theme by hooking into WordPress.
 */
require get_parent_theme_file_path( '/inc/template-functions.php' );

/**
 * Customizer additions.
 */
require get_parent_theme_file_path( '/inc/customizer.php' );

/**
 * Load Jetpack compatibility file.
 */
if ( defined( 'JETPACK__VERSION' ) ) {
	require get_parent_theme_file_path() . '/inc/jetpack.php';
}

/**
 * SVG icons functions and filters.
 */
require get_parent_theme_file_path( '/inc/icon-functions.php' );

/**
 * Admin welcome page
 */
require get_parent_theme_file_path( '/inc/welcome.php' );

/**
 * TGMPA call
 */
require get_parent_theme_file_path( '/inc/tgmpa/call.php' );

/**
 * OCDI compatibility.
 */
if ( class_exists( 'OCDI_Plugin' ) ) {
	require get_parent_theme_file_path( '/inc/ocdi.php' );
}

/**
 * Enqueue admin css.
 * @return [type] [description]
 */
function franchise_load_custom_wp_admin_style( $hook ) {
	if ( 'appearance_page_franchise-welcome' != $hook ) {
        return;
    }
    wp_register_style( 'franchise-admin', get_theme_file_uri( 'assets/css/franchise-admin.css' ), false, '1.0.0' );
    wp_enqueue_style( 'franchise-admin' );
}
add_action( 'admin_enqueue_scripts', 'franchise_load_custom_wp_admin_style' );

/**
 * Styles the header image and text displayed on the blog.
 *
 * @see franchise_custom_header_setup().
 */
function franchise_header_text_style() {
	// If we get this far, we have custom styles. Let's do this.
	$header_text_display = get_theme_mod( 'franchise_header_text_display', true );
	?>
	<style type="text/css">
	<?php if ( ! $header_text_display ) : ?>
		#site-identity {
			display: none;
		}
	<?php endif; ?>

	.site-title a{
		color: <?php echo esc_attr( get_theme_mod( 'franchise_header_title_color', '#cf3140' ) ); ?>;
	}
	.site-description {
		color: <?php echo esc_attr( get_theme_mod( 'franchise_header_tagline', '#2e2e2e' ) ); ?>;
	}
	</style>
	<?php
}
add_action( 'wp_head', 'franchise_header_text_style' );

if ( ! function_exists( 'franchise_exclude_sticky_posts' ) ) {
    function franchise_exclude_sticky_posts( $query ) {
        if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) {
            $sticky_posts = get_option( 'sticky_posts' );  
            if ( ! empty( $sticky_posts ) ) {
            	$query->set('post__not_in', $sticky_posts );
            }
            $query->set('ignore_sticky_posts', true );
        }
    }
}
add_action( 'pre_get_posts', 'franchise_exclude_sticky_posts' );

Directory Contents

Dirs: 5 × Files: 18

Name Size Perms Modified Actions
assets DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
inc DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
languages DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
1.01 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.72 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.84 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.74 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
951 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
11.10 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.67 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.94 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.65 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
17.62 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.50 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.84 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
257.98 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.78 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
876 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
368 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.60 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
112.95 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).