did some sniff sniff
This commit is contained in:
140
functions.php
140
functions.php
@@ -15,7 +15,7 @@ if ( ! function_exists( 'sophia_after_dark_setup' ) ) :
|
||||
* runs before the init hook. The init hook is too late for some features, such
|
||||
* as indicating support for post thumbnails.
|
||||
*/
|
||||
function sophia_after_dark_setup(){
|
||||
function sophia_after_dark_setup() {
|
||||
/*
|
||||
* Make theme available for translation.
|
||||
* Translations can be filed in the /languages/ directory.
|
||||
@@ -49,30 +49,35 @@ if ( ! function_exists( 'sophia_after_dark_setup' ) ) :
|
||||
add_image_size( 'sophia-after-dark-slider-post', 1200, 700, true );
|
||||
|
||||
// This theme uses wp_nav_menu() in one location.
|
||||
register_nav_menus( array(
|
||||
'top_header_menu' => esc_html__( 'Top Header', 'sophia-after-dark' ),
|
||||
'primary_menu' => esc_html__( 'Primary', 'sophia-after-dark' ),
|
||||
'footer_menu' => esc_html__( 'Footer', 'sophia-after-dark' ),
|
||||
) );
|
||||
register_nav_menus(
|
||||
array(
|
||||
'top_header_menu' => esc_html__( 'Top Header', 'sophia-after-dark' ),
|
||||
'primary_menu' => esc_html__( 'Primary', 'sophia-after-dark' ),
|
||||
'footer_menu' => esc_html__( 'Footer', 'sophia-after-dark' ),
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* 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',
|
||||
) );
|
||||
add_theme_support(
|
||||
'html5',
|
||||
array(
|
||||
'search-form',
|
||||
'comment-form',
|
||||
'comment-list',
|
||||
'gallery',
|
||||
'caption',
|
||||
)
|
||||
);
|
||||
|
||||
// Set up the WordPress core custom background feature.
|
||||
// Disabled in V1.4.3
|
||||
//add_theme_support( 'custom-background', apply_filters( 'sophia_after_dark_custom_background_args', array(
|
||||
//'default-color' => 'ffffff',
|
||||
//'default-image' => '',
|
||||
//) ) );
|
||||
// add_theme_support( 'custom-background', apply_filters( 'sophia_after_dark_custom_background_args', array(
|
||||
// 'default-color' => 'ffffff',
|
||||
// 'default-image' => '',
|
||||
// ) ) );
|
||||
|
||||
// Add theme support for selective refresh for widgets.
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
@@ -82,24 +87,27 @@ if ( ! function_exists( 'sophia_after_dark_setup' ) ) :
|
||||
*
|
||||
* @link https://codex.wordpress.org/Theme_Logo
|
||||
*/
|
||||
add_theme_support( 'custom-logo', array(
|
||||
'height' => 250,
|
||||
'width' => 250,
|
||||
'flex-width' => true,
|
||||
'flex-height' => true,
|
||||
) );
|
||||
add_theme_support(
|
||||
'custom-logo',
|
||||
array(
|
||||
'height' => 250,
|
||||
'width' => 250,
|
||||
'flex-width' => true,
|
||||
'flex-height' => true,
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Registers an editor stylesheet for the theme.
|
||||
*/
|
||||
add_editor_style( 'assets/css/sad-editor-style.css' );
|
||||
|
||||
/**
|
||||
* Restoring the classic Widgets Editor
|
||||
*
|
||||
* @since 1.1.5
|
||||
*/
|
||||
$sophia_after_dark_enable_widgets_editor = get_theme_mod( 'sophia_after_dark_enable_widgets_editor', false );
|
||||
|
||||
/**
|
||||
* Restoring the classic Widgets Editor
|
||||
*
|
||||
* @since 1.1.5
|
||||
*/
|
||||
$sophia_after_dark_enable_widgets_editor = get_theme_mod( 'sophia_after_dark_enable_widgets_editor', false );
|
||||
if ( false === $sophia_after_dark_enable_widgets_editor ) {
|
||||
remove_theme_support( 'widgets-block-editor' );
|
||||
}
|
||||
@@ -128,20 +136,19 @@ add_action( 'after_setup_theme', 'sophia_after_dark_content_width', 0 );
|
||||
* @global string $sophia_after_dark_theme_version
|
||||
*/
|
||||
function sophia_after_dark_theme_version_info() {
|
||||
$sophia_after_dark_theme_info = wp_get_theme();
|
||||
$sophia_after_dark_theme_info = wp_get_theme();
|
||||
$GLOBALS['sophia_after_dark_theme_version'] = $sophia_after_dark_theme_info->get( 'Version' );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'sophia_after_dark_theme_version_info', 0 );
|
||||
|
||||
/**
|
||||
* Function for displaying menu item description
|
||||
*
|
||||
*/
|
||||
function sophia_after_dark_nav_description( $item_output, $item, $depth, $menu_args ) {
|
||||
if ( !empty( $item->description ) ) {
|
||||
$item_output = str_replace( $menu_args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $menu_args->link_after . '</a>', $item_output );
|
||||
}
|
||||
return $item_output;
|
||||
if ( ! empty( $item->description ) ) {
|
||||
$item_output = str_replace( $menu_args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $menu_args->link_after . '</a>', $item_output );
|
||||
}
|
||||
return $item_output;
|
||||
}
|
||||
add_filter( 'walker_nav_menu_start_el', 'sophia_after_dark_nav_description', 10, 4 );
|
||||
|
||||
@@ -149,7 +156,7 @@ add_filter( 'walker_nav_menu_start_el', 'sophia_after_dark_nav_description', 10,
|
||||
* Implement the Custom Header feature.
|
||||
* Disabled in V1.4.3
|
||||
*/
|
||||
//require get_template_directory() . '/inc/custom-header.php';
|
||||
// require get_template_directory() . '/inc/custom-header.php';
|
||||
|
||||
/**
|
||||
* Custom template tags for this theme.
|
||||
@@ -181,7 +188,7 @@ require get_template_directory() . '/inc/hooks/sad-custom-hooks.php';
|
||||
/**
|
||||
* Load custom hook top header file
|
||||
*/
|
||||
require get_template_directory() . '/inc/hooks/sad-top-header-hooks.php';
|
||||
require get_template_directory() . '/inc/hooks/sad-top-header-hooks.php';
|
||||
|
||||
/**
|
||||
* Load widget functions file
|
||||
@@ -201,38 +208,41 @@ if ( ! function_exists( 'breadcrumb_trail' ) ) {
|
||||
}
|
||||
|
||||
// Function to allow images in WordPress comments
|
||||
function allow_images_in_comments($comment_content) {
|
||||
// Allow only specific HTML tags, including <img>
|
||||
$allowed_tags = array(
|
||||
'a' => array('href' => array(), 'title' => array()),
|
||||
'em' => array(),
|
||||
'strong' => array(),
|
||||
'img' => array(
|
||||
'src' => array(),
|
||||
'alt' => array(),
|
||||
'width' => array(),
|
||||
'height' => array(),
|
||||
'class' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
// Strip out disallowed tags but keep allowed ones
|
||||
return wp_kses($comment_content, $allowed_tags);
|
||||
function allow_images_in_comments( $comment_content ) {
|
||||
// Allow only specific HTML tags, including <img>
|
||||
$allowed_tags = array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'title' => array(),
|
||||
),
|
||||
'em' => array(),
|
||||
'strong' => array(),
|
||||
'img' => array(
|
||||
'src' => array(),
|
||||
'alt' => array(),
|
||||
'width' => array(),
|
||||
'height' => array(),
|
||||
'class' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
// Strip out disallowed tags but keep allowed ones
|
||||
return wp_kses( $comment_content, $allowed_tags );
|
||||
}
|
||||
|
||||
// Hook to filter the comment text before displaying it
|
||||
add_filter('comment_text', 'allow_images_in_comments');
|
||||
add_filter( 'comment_text', 'allow_images_in_comments' );
|
||||
|
||||
// Function to make URLs for images clickable in comments
|
||||
function clickable_images_in_comments($comment_content) {
|
||||
// Automatically convert image URLs to HTML <img> tags
|
||||
$comment_content = preg_replace(
|
||||
'/(http:\/\/[^\s"]+\.(jpg|jpeg|png|gif))/i',
|
||||
'<img src="$1" alt="" class="comment-image" />',
|
||||
$comment_content
|
||||
);
|
||||
return $comment_content;
|
||||
function clickable_images_in_comments( $comment_content ) {
|
||||
// Automatically convert image URLs to HTML <img> tags
|
||||
$comment_content = preg_replace(
|
||||
'/(http:\/\/[^\s"]+\.(jpg|jpeg|png|gif))/i',
|
||||
'<img src="$1" alt="" class="comment-image" />',
|
||||
$comment_content
|
||||
);
|
||||
return $comment_content;
|
||||
}
|
||||
|
||||
// Hook to make image URLs clickable
|
||||
add_filter('comment_text', 'clickable_images_in_comments');
|
||||
add_filter( 'comment_text', 'clickable_images_in_comments' );
|
||||
|
||||
Reference in New Issue
Block a user