| Server IP : 10.200.247.200 / Your IP : 216.73.217.19 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/usa_sites/governmentgrants.us/wp-content/themes/governmentgrants/ |
Upload File : |
<?php
/**
* Naren Designs functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Naren_Designs
* @since 1.0
*/
/**
* Naren Designs only works in WordPress 4.7 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
return;
}
/**
* 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 narendesigns_setup() {
/*
* Make theme available for translation.
* If you're building a theme based on Naren Designs, use a find and replace
* to change 'narendesigns' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'narendesigns' );
// 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( 'narendesigns-featured-image', 1920, 1280, true );
add_image_size( 'narendesigns-thumbnail-avatar', 100, 100, true );
// Set the default content width.
$GLOBALS['content_width'] = 525;
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'top' => __( 'Top Menu', 'narendesigns' ),
'social' => __( 'Social Links Menu', 'narendesigns' ),
) );
/*
* 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',
) );
/*
* Enable support for Post Formats.
*
* See: https://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
'gallery',
'audio',
) );
// Add theme support for Custom Logo.
add_theme_support( 'custom-logo', array(
'width' => 250,
'height' => 250,
'flex-width' => true,
) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/*
* 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', narendesigns_fonts_url() ) );
// Define and register starter content to showcase the theme on new sites.
$starter_content = array(
'widgets' => array(
// Place three core-defined widgets in the sidebar area.
'sidebar-1' => array(
'text_business_info',
'search',
'text_about',
),
// Add the core-defined business info widget to the footer 1 area.
'sidebar-2' => array(
'text_business_info',
),
// Put two core-defined widgets in the footer 2 area.
'sidebar-3' => array(
'text_about',
'search',
),
),
// Specify the core-defined pages to create and add custom thumbnails to some of them.
'posts' => array(
'home',
'about' => array(
'thumbnail' => '{{image-sandwich}}',
),
'contact' => array(
'thumbnail' => '{{image-espresso}}',
),
'blog' => array(
'thumbnail' => '{{image-coffee}}',
),
'homepage-section' => array(
'thumbnail' => '{{image-espresso}}',
),
),
// Create the custom image attachments used as post thumbnails for pages.
'attachments' => array(
'image-espresso' => array(
'post_title' => _x( 'Espresso', 'Theme starter content', 'narendesigns' ),
'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
),
'image-sandwich' => array(
'post_title' => _x( 'Sandwich', 'Theme starter content', 'narendesigns' ),
'file' => 'assets/images/sandwich.jpg',
),
'image-coffee' => array(
'post_title' => _x( 'Coffee', 'Theme starter content', 'narendesigns' ),
'file' => 'assets/images/coffee.jpg',
),
),
// Default to a static front page and assign the front and posts pages.
'options' => array(
'show_on_front' => 'page',
'page_on_front' => '{{home}}',
'page_for_posts' => '{{blog}}',
),
// Set the front page section theme mods to the IDs of the core-registered pages.
'theme_mods' => array(
'panel_1' => '{{homepage-section}}',
'panel_2' => '{{about}}',
'panel_3' => '{{blog}}',
'panel_4' => '{{contact}}',
),
// Set up nav menus for each of the two areas registered in the theme.
'nav_menus' => array(
// Assign a menu to the "top" location.
'top' => array(
'name' => __( 'Top Menu', 'narendesigns' ),
'items' => array(
'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
'page_about',
'page_blog',
'page_contact',
),
),
// Assign a menu to the "social" location.
'social' => array(
'name' => __( 'Social Links Menu', 'narendesigns' ),
'items' => array(
'link_yelp',
'link_facebook',
'link_twitter',
'link_instagram',
'link_email',
),
),
),
);
/**
* Filters Naren Designs array of starter content.
*
* @since Naren Designs 1.1
*
* @param array $starter_content Array of starter content.
*/
$starter_content = apply_filters( 'narendesigns_starter_content', $starter_content );
add_theme_support( 'starter-content', $starter_content );
}
add_action( 'after_setup_theme', 'narendesigns_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 narendesigns_content_width() {
$content_width = $GLOBALS['content_width'];
// Get layout.
$page_layout = get_theme_mod( 'page_layout' );
// Check if layout is one column.
if ( 'one-column' === $page_layout ) {
if ( narendesigns_is_frontpage() ) {
$content_width = 644;
} elseif ( is_page() ) {
$content_width = 740;
}
}
// Check if is single post and there is no sidebar.
if ( is_single() && ! is_active_sidebar( 'sidebar-1' ) ) {
$content_width = 740;
}
/**
* Filter Naren Designs content width of the theme.
*
* @since Naren Designs 1.0
*
* @param int $content_width Content width in pixels.
*/
$GLOBALS['content_width'] = apply_filters( 'narendesigns_content_width', $content_width );
}
add_action( 'template_redirect', 'narendesigns_content_width', 0 );
/**
* Register custom fonts.
*/
function narendesigns_fonts_url() {
$fonts_url = '';
/*
* Translators: If there are characters in your language that are not
* supported by Libre Franklin, translate this to 'off'. Do not translate
* into your own language.
*/
$libre_franklin = _x( 'on', 'Libre Franklin font: on or off', 'narendesigns' );
if ( 'off' !== $libre_franklin ) {
$font_families = array();
$font_families[] = 'Libre Franklin:300,300i,400,400i,600,600i,800,800i';
$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 );
}
/**
* Add preconnect for Google Fonts.
*
* @since Naren Designs 1.0
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array $urls URLs to print for resource hints.
*/
function narendesigns_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'narendesigns-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin',
);
}
return $urls;
}
add_filter( 'wp_resource_hints', 'narendesigns_resource_hints', 10, 2 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function narendesigns_widgets_init() {
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'narendesigns' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'narendesigns' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Footer 1', 'narendesigns' ),
'id' => 'sidebar-2',
'description' => __( 'Add widgets here to appear in your footer.', 'narendesigns' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Footer 2', 'narendesigns' ),
'id' => 'sidebar-3',
'description' => __( 'Add widgets here to appear in your footer.', 'narendesigns' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Featured Services', 'narendesigns' ),
'id' => 'sidebar-4',
'description' => __( 'Add widgets here to appear in features services boxes.', 'narendesigns' ),
'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', 'narendesigns_widgets_init' );
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
* a 'Continue reading' link.
*
* @since Naren Designs 1.0
*
* @param string $link Link to single post/page.
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function narendesigns_excerpt_more( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'narendesigns' ), get_the_title( get_the_ID() ) )
);
return ' … ' . $link;
}
add_filter( 'excerpt_more', 'narendesigns_excerpt_more' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function narendesigns_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '<link rel="pingback" href="%s">' . "\n", get_bloginfo( 'pingback_url' ) );
}
}
add_action( 'wp_head', 'narendesigns_pingback_header' );
/**
* Display custom color CSS.
*/
/*
function narendesigns_colors_css_wrap() {
if ( 'custom' !== get_theme_mod( 'colorscheme' ) && ! is_customize_preview() ) {
return;
}
require_once( get_parent_theme_file_path( '/inc/color-patterns.php' ) );
$hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
?>
<style type="text/css" id="custom-theme-colors" <?php if ( is_customize_preview() ) { echo 'data-hue="' . $hue . '"'; } ?>>
<?php echo narendesigns_custom_colors_css(); ?>
</style>
<?php }
add_action( 'wp_head', 'narendesigns_colors_css_wrap' );
*/
/**
* Add custom image sizes attribute to enhance responsive image functionality
* for content images.
*
* @since Naren Designs 1.0
*
* @param string $sizes A source size value for use in a 'sizes' attribute.
* @param array $size Image size. Accepts an array of width and height
* values in pixels (in that order).
* @return string A source size value for use in a content image 'sizes' attribute.
*/
function narendesigns_content_image_sizes_attr( $sizes, $size ) {
$width = $size[0];
if ( 740 <= $width ) {
$sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px';
}
if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
$sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
}
}
return $sizes;
}
add_filter( 'wp_calculate_image_sizes', 'narendesigns_content_image_sizes_attr', 10, 2 );
/**
* Filter the `sizes` value in the header image markup.
*
* @since Naren Designs 1.0
*
* @param string $html The HTML image tag markup being filtered.
* @param object $header The custom header object returned by 'get_custom_header()'.
* @param array $attr Array of the attributes for the image tag.
* @return string The filtered header image HTML.
*/
function narendesigns_header_image_tag( $html, $header, $attr ) {
if ( isset( $attr['sizes'] ) ) {
$html = str_replace( $attr['sizes'], '100vw', $html );
}
return $html;
}
add_filter( 'get_header_image_tag', 'narendesigns_header_image_tag', 10, 3 );
/**
* Add custom image sizes attribute to enhance responsive image functionality
* for post thumbnails.
*
* @since Naren Designs 1.0
*
* @param array $attr Attributes for the image markup.
* @param int $attachment Image attachment ID.
* @param array $size Registered image size or flat array of height and width dimensions.
* @return array The filtered attributes for the image markup.
*/
function narendesigns_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
if ( is_archive() || is_search() || is_home() ) {
$attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
} else {
$attr['sizes'] = '100vw';
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'narendesigns_post_thumbnail_sizes_attr', 10, 3 );
/**
* Use front-page.php when Front page displays is set to a static page.
*
* @since Naren Designs 1.0
*
* @param string $template front-page.php.
*
* @return string The template to be used: blank if is_home() is true (defaults to index.php), else $template.
*/
function narendesigns_front_page_template( $template ) {
return is_home() ? '' : $template;
}
add_filter( 'frontpage_template', 'narendesigns_front_page_template' );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Naren Designs 1.4
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function narendesigns_widget_tag_cloud_args( $args ) {
$args['largest'] = 1;
$args['smallest'] = 1;
$args['unit'] = 'em';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'narendesigns_widget_tag_cloud_args' );
/**
* Implement the Custom Header feature.
*/
require get_parent_theme_file_path( '/inc/custom-header.php' );
/**
* Custom template tags for this theme.
*/
require get_parent_theme_file_path( '/inc/template-tags.php' );
/**
* Additional features to allow styling of the templates.
*/
require get_parent_theme_file_path( '/inc/template-functions.php' );
/**
* Customizer additions.
*/
require get_parent_theme_file_path( '/inc/customizer.php' );
/**
* SVG icons functions and filters.
*/
//require get_parent_theme_file_path( '/inc/icon-functions.php' );
/*Narendesigns custom additions*/
/**
* Custom functions and definitions for narendesigns
**/
remove_action('wp_head', 'rsd_link'); //removes EditURI/RSD (Really Simple Discovery) link.
remove_action('wp_head', 'wlwmanifest_link'); //removes wlwmanifest (Windows Live Writer) link.
remove_action('wp_head', 'wp_generator'); //removes meta name generator.
remove_action('wp_head', 'wp_shortlink_wp_head'); //removes shortlink.
remove_action( 'wp_head', 'feed_links', 2 ); //removes feed links.
remove_action('wp_head', 'feed_links_extra', 3 ); //removes comments feed.
// Remove the REST API endpoint.
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
// Turn off oEmbed auto discovery.
add_filter( 'embed_oembed_discover', '__return_false' );
// Don't filter oEmbed results.
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
// Remove oEmbed discovery links.
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
// Remove oEmbed-specific JavaScript from the front-end and back-end.
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
// Remove all embeds rewrite rules.
//add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
// Remove theme styles
function unhook_parent_style() {
wp_dequeue_style( 'twentyseventeen-fonts-css' );
wp_deregister_style( 'twentyseventeen-fonts-css' );
wp_deregister_style('classic-theme-styles');
wp_dequeue_style('classic-theme-styles');
wp_deregister_style('global-styles');
wp_dequeue_style('global-styles');
}
add_action( 'wp_enqueue_scripts', 'unhook_parent_style', 20 );
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
// Remove Dns Prefetch
function remove_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}
return $hints;
}
add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
/*remove plugin css files*/
function give_dequeue_plugin_css() {
wp_dequeue_style('additional-parent-style');
wp_deregister_style('additional-parent-style');
}
add_action('wp_enqueue_scripts','give_dequeue_plugin_css', 100);
// Remove wp-embed.js from footer
function my_deregister_scripts(){
wp_deregister_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_deregister_scripts' );
remove_filter( 'twentyseventeen_social_links_icons', 'wpautop' );
//add_filter( 'pre_comment_content', 'esc_html' ); // remove html from comemnt
// stop loading admin bar
//add_filter('show_admin_bar', '__return_false'); // disable admin bar
//Remove Howdy
add_filter('gettext', 'change_howdy', 10, 3);
function change_howdy($translated, $text, $domain) {
if (!is_admin() || 'default' != $domain)
return $translated;
if (false !== strpos($translated, 'Howdy'))
return str_replace('Howdy', 'Welcome', $translated);
return $translated;
}
// Addd support for svg image upload
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
//Header Menu
function wp_custom_header_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'wp_custom_header_menu' );
//Amp Mobile menu
function wp_custom_mobile_menu() {
register_nav_menu('mobile-menu',__( 'Mobile Menu' ));
}
add_action( 'init', 'wp_custom_mobile_menu' );
//new amp image
if(is_admin()){
// add the filter
add_filter( 'image_send_to_editor', 'filter_ampimage_send_to_editor', 10, 8 );
// define the image_send_to_editor callback
function filter_ampimage_send_to_editor( $html, $id, $caption, $title, $align, $url, $size = 'full', $alt ) {
// make filter magic happen here...
// return $html;
$metadata = wp_get_attachment_metadata ($id);
$url = wp_get_attachment_url($id);
$layout = get_field('layout', $id);
$layout_fixed = get_field('layout_fixed', $id);
$min_width = get_field('min_width', $id);
$max_width = get_field('max_width', $id);
$image_attributes = wp_get_attachment_image_src( $attachment_id, $size = 'full' );
//image layout
$image_layout = get_field('image_layout', $id);
if ( !empty($layout) && empty($layout_fixed) ) {
return '<amp-img src="'.$url.'" width="'.$metadata['width'].'" height="'.$metadata['height'].'" alt="'.$alt.'" class="amp-img" id="amp-img-'.$id.'" layout="'.$layout.'"></amp-img>';
}
elseif( !empty($layout) && !empty($layout_fixed) ){
return '<div class="align-center"><amp-img src="'.$url.'" width="'.$metadata['width'].'" height="'.$metadata['height'].'" alt="'.$alt.'" class="amp-img" id="amp-img-'.$id.'" layout="'.$layout_fixed.'" media="(min-width:'.$min_width.')"></amp-img><amp-img src="'.$url.'" width="'.$metadata['width'].'" height="'.$metadata['height'].'" alt="'.$alt.'" class="amp-img" id="amp-img-'.$id.'" layout="'.$layout.'" media="(max-width:'.$max_width.')"></amp-img></div>';
}
};
}
//Page Slug Body Class
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_name . '-' . $post->post_type;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
//ACF remove auto p
remove_filter ('acf_the_content', 'wpautop');
//Shortcodes
function accordion_shortcode( $atts, $content = null ) {
return '<amp-accordion><section>' . $content . '</section></amp-accordion>';
}
add_shortcode( 'amp-accordion', 'accordion_shortcode' );
add_theme_support('post-thumbnails');
function is_post_type($type){
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
return false;
}
//remove recent comments inline style
add_filter( 'show_recent_comments_widget_style', function() { return false; });
//shortcode for email and phone number
function primary_email_function() {
$primary_emailid = get_field( 'primary_email_address', 'option');
return '<a href="mailto:' . $primary_emailid . '" class="email primary"> ' . $primary_emailid . '</a>';
}
add_shortcode('email-primary', 'primary_email_function');
//usage [email-primary]
function secondary_email_function() {
$secondary_emailid = get_field( 'secondary_email_address', 'option');
return '<a href="mailto:' . $secondary_emailid . '" class="email secondary "> ' . $secondary_emailid . '</a>';
}
add_shortcode('email-secondary', 'secondary_email_function');
//usage [email-secondary]
function primary_phone_function() {
$primary_phone = get_field( 'primary_phone_number', 'option');
return '<a href="tel:' . $primary_phone . '" class="primary phone">' . $primary_phone . '</a>';
}
add_shortcode('phone-primary', 'primary_phone_function');
//usage [phone-primary]
function secondary_phone_function() {
$secondary_phone = get_field( 'secondary_phone_number', 'option');
return '<a href="tel:' . $secondary_phone . '" class="secondary phone"> ' . $secondary_phone . '</a>';
}
add_shortcode('phone-secondary', 'secondary_phone_function');
//usage [phone-secondary]
function address_function() {
$address = get_field( 'address', 'option');
return '<p>' . $address . '</p>';
}
add_shortcode('address', 'address_function');
//usage [address]
//social links shortcodes
function facebook_function() {
$facebook_url = get_field( 'facebook_url', 'option');
return '<a href="' . $facebook_url . '" class="facebook"><i class="fa fa-facebook"></i></a>';
}
add_shortcode('facebook', 'facebook_function');
//usage [facebook]
function twitter_function() {
$twitter_url = get_field( 'twitter_url', 'option');
return '<a href="' . $twitter_url . '" class="twitter"><i class="fa fa-twitter"></i></a>';
}
add_shortcode('twitter', 'twitter_function');
//usage [twitter]
function google_plus_function() {
$google_url = get_field( 'google+_url', 'option');
return '<a href="' . $google_url . '" class="google-plus"><i class="fa fa-google-plus"></i></a>';
}
add_shortcode('google-plus', 'google_plus_function');
//usage [google-plus]
function linkedin_function() {
$linkedin_url = get_field( 'linkedin_url', 'option');
return '<a href="' . $linkedin_url . '" class="linkedin"><i class="fa fa-linkedin"></i></a>';
}
add_shortcode('linkedin', 'linkedin_function');
//usage [linkedin]
function pinterest_function() {
$pinterest_url = get_field( 'pinterest_url', 'option');
return '<a href="' . $pinterest_url . '" class="pinterest"><i class="fa fa-pinterest-p"></i></a>';
}
add_shortcode('pinterest', 'pinterest_function');
//usage [pinterest]
function instagram_function() {
$instagram_url = get_field( 'instagram_url', 'option');
return '<a href="' . $instagram_url . '" class="instagram"><i class="fa fa-instagram"></i></a>';
}
add_shortcode('instagram', 'instagram_function');
//usage [instagram]
function tumblr_function() {
$tumblr_url = get_field( 'tumblr_url', 'option');
return '<a href="' . $tumblr_url . '" class="tumblr"><i class="fa fa-tumblr"></i></a>';
}
add_shortcode('tumblr', 'tumblr_function');
//usage [tumblr]
function youtube_function() {
$youtube_url = get_field( 'youtube_url', 'option');
return '<a href="' . $youtube_url . '" class="youtube"><i class="fa fa-youtube"></i></a>';
}
add_shortcode('youtube', 'youtube_function');
//usage [youtube]
//Remove customizer options
add_action( "customize_register", "narendesigns_theme_customize_register" );
function narendesigns_theme_customize_register( $wp_customize ) {
//=============================================================
// Remove header image and widgets option from theme customizer
//=============================================================
$wp_customize->remove_control("header_image");
$wp_customize->remove_panel("widgets");
//=============================================================
// Remove Colors, Background image, and Static front page
// option from theme customizer
//=============================================================
$wp_customize->remove_section("title_tagline");
$wp_customize->remove_section("header_image");
$wp_customize->remove_section("custom_css");
$wp_customize->remove_section("colors");
$wp_customize->remove_section("background_image");
$wp_customize->remove_section("static_front_page");
}
/*ACF Options Page*/
if( function_exists('acf_add_options_page') ) {
//acf_add_options_page('Theme Settings');
$option_page = acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Header Settings',
'menu_title' => 'Header',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Footer Settings',
'menu_title' => 'Footer',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Social Network Profiles',
'menu_title' => 'Social Profiles',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Contact Information',
'menu_title' => 'Contact Details',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Google Analytics',
'menu_title' => 'Google Analytics',
'parent_slug' => 'theme-general-settings',
));
}
function slider_add_meta_boxes($post)
{
add_meta_box('ImageSliderMeta',__('image'),'slider_image_meta_box', 'amp_slider');
}
add_action('init', 'my_remove_editor_from_post_type');
function my_remove_editor_from_post_type() {
remove_post_type_support( 'page', 'editor' );
}
//remove featured image meta box from pages
add_action('do_meta_boxes', 'remove_page_thumbnail_box');
function remove_page_thumbnail_box() {
remove_meta_box( 'postimagediv','page','side' );
}
//remove featured image meta box from posts
add_action('do_meta_boxes', 'remove_post_thumbnail_box');
function remove_post_thumbnail_box() {
remove_meta_box( 'postimagediv','post','side' );
}
// remove p and br tags from default wordpress editor
remove_filter( 'the_content', 'wpautop' );
//Remove WPAUTOP from ACF TinyMCE Editor
function acf_wysiwyg_remove_wpautop() {
remove_filter('acf_the_content', 'wpautop' );
}
add_action('acf/init', 'acf_wysiwyg_remove_wpautop');
/* Automatically set the image Title, Alt-Text, Caption & Description upon upload
--------------------------------------------------------------------------------------*/
add_action( 'add_attachment', 'narendesigns_image_meta_upon_image_upload' );
function narendesigns_image_meta_upon_image_upload( $post_ID ) {
// Check if uploaded file is an image, else do nothing
if ( wp_attachment_is_image( $post_ID ) ) {
$my_image_title = get_post( $post_ID )->post_title;
// Sanitize the title: remove hyphens, underscores & extra spaces:
$my_image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ', $my_image_title );
// Sanitize the title: capitalize first letter of every word (other letters lower case):
$my_image_title = ucwords( strtolower( $my_image_title ) );
// Create an array with the image meta (Title, Caption, Description) to be updated
// Note: comment out the Excerpt/Caption or Content/Description lines if not needed
$my_image_meta = array(
'ID' => $post_ID, // Specify the image (ID) to be updated
'post_title' => $my_image_title, // Set image Title to sanitized title
//'post_excerpt' => $my_image_title, // Set image Caption (Excerpt) to sanitized title
//'post_content' => $my_image_title, // Set image Description (Content) to sanitized title
);
// Set the image Alt-Text
update_post_meta( $post_ID, '_wp_attachment_image_alt', $my_image_title );
// Set the image meta (e.g. Title, Excerpt, Content)
wp_update_post( $my_image_meta );
}
}
// Enable the use of shortcodes in text widgets.
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
//* Add categories to Custom post types (CPT) to categories taxonomy
add_action( 'init', 'narendesigns_add_category_taxonomy_to_events' );
function narendesigns_add_category_taxonomy_to_events() {
register_taxonomy_for_object_type( 'category', 'products_list' );
}
function caption_off() {
return true;
}
add_filter( 'disable_captions', 'caption_off' );
add_filter( 'disable_captions', '__return_true' );
//Disable visual editor
//add_filter( 'user_can_richedit' , '__return_false', 50 );
add_action('admin_head', 'admin_css');
function admin_css() {
echo '<style>
.wp-switch-editor.switch-tmce {display:none;}
</style>';
}
//add_filter( 'wp_default_editor', create_function( '', 'return "html";' ) );
function set_default_editor() {
$r = 'html';
return $r;
}
add_filter( 'wp_default_editor', 'set_default_editor' );
//Disable gutenberg style/scripts in Front
function wps_deregister_styles() {
wp_dequeue_style( 'wp-block-library' );
}
add_action( 'wp_print_styles', 'wps_deregister_styles', 100 );
add_filter( 'wp-block-library', '__return_false' );