HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //home/dorsetandsomersetairambulance.org.uk/public_html/wp-content/themes/dw-focus/inc/init.php
<?php
/**
 * DW Focus Setup
 *
 * @package DW Focus
 * @since DW Focus 1.3.0
 */

if ( ! isset( $content_width ) ) {
	$content_width = 625;
}

if ( ! function_exists( 'dw_focus_setup' ) ) {
	function dw_focus_setup() {
		load_theme_textdomain( 'dw-focus', get_template_directory() . '/languages' );
		add_theme_support( 'automatic-feed-links' );
		add_theme_support( 'post-thumbnails' );
		add_theme_support( 'custom-background' );
		add_theme_support( 'title-tag' );

		register_nav_menus( array(
			'primary' => __( 'Primary Menu', 'dw-focus' ),
		) );

		add_theme_support( 'html5', array(
			'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
		) );

		add_theme_support( 'post-formats', array(
			'audio', 'image', 'video', 'gallery',
		) );

		add_image_size( 'dw-focus-archive', 230 );
		add_image_size( 'dw-focus-slider', 710, 400, true );
	}
}


add_action( 'after_setup_theme', 'dw_focus_setup' );


function dw_focus_register_required_plugins() {
	$plugins = array(
		array(
			'name'        => 'Unyson',
			'slug'        => 'unyson',
			'required'    => true,
		),
		array(
			'name'        => 'DW Megamenu',
			'slug'        => 'dw-megamenu',
			'required'    => false,
			'source'      => get_template_directory().'/plugins/dw-megamenu.zip'
		),
		array(
			'name'        => 'Awesome Weather Widget',
			'slug'        => 'awesome-weather'
		),
		array(
			'name'        => 'DW Social Share',
			'slug'        => 'dw-social-share'
		),
	);
	tgmpa( $plugins );
}
add_action( 'tgmpa_register', 'dw_focus_register_required_plugins' );

function dw_focus_search_form_modify( $html ) {
	$html = str_replace( 'search-form', 'form-inline', $html );
	$html = str_replace( '</label>', '', $html );
	$html = str_replace( '</span>', '</span></label>', $html );
	$html = str_replace( 'screen-reader-text', 'sr-only', $html );
	$html = str_replace( 'search-field', 'form-control', $html );
	return $html;
}
add_filter( 'get_search_form', 'dw_focus_search_form_modify' );

function dw_focus_change_embed_size() {
	return array( 'width' => 800, 'height' => 450 );
}

function dw_focus_get_theme_option( $option_name, $default = '' ) {
	if ( function_exists( 'fw_get_db_settings_option' ) ) {
		$options = fw_get_db_settings_option( $option_name );
	} 
	if ( isset( $options ) ) {
	 	return $options;
	}
    return $default;
}

function dw_focus_theme_oembed_videos() {
	global $post;
	if ( $post && $post->post_content ) {

		global $shortcode_tags;
				// Make a copy of global shortcode tags - we'll temporarily overwrite it.
		$theme_shortcode_tags = $shortcode_tags;

				// The shortcodes we're interested in.
		$shortcode_tags = array(
			'video' => $theme_shortcode_tags['video'],
			'embed' => $theme_shortcode_tags['embed']
			);
				// Get the absurd shortcode regexp.
		$video_regex = '#' . get_shortcode_regex() . '#i';

				// Restore global shortcode tags.
		$shortcode_tags = $theme_shortcode_tags;

		$pattern_array = array( $video_regex );

				// Get the patterns from the embed object.
		if ( ! function_exists( '_wp_oembed_get_object' ) ) {
			include ABSPATH . WPINC . '/class-oembed.php';
		}
		$oembed = _wp_oembed_get_object();
		$pattern_array = array_merge( $pattern_array, array_keys( $oembed->providers ) );

				// Or all the patterns together.

		$pattern = '#(' . array_reduce( $pattern_array, function ( $carry, $item ) {
			if ( strpos( $item, '#' ) === 0 ) {
								// Assuming '#...#i' regexps.
				$item = substr( $item, 1, -2 );
			} else {
								// Assuming glob patterns.
				$item = str_replace( '*', '(.+)', $item );
			}
			return $carry ? $carry . ')|('  . $item : $item;
		} ) . ')#is';

				// Simplistic parse of content line by line.
		$lines = explode( "\n", $post->post_content );
		foreach ( $lines as $line ) {
            $line = trim( $line );
            if ( preg_match('/<iframe[^>]+src="([^"]+)"[^>]*>*<\/iframe>([Ss]*)/', $line, $reg_matches ) ) {
            	$ret = $reg_matches[0];
            	return $ret;
            } else {
	            if ( preg_match('/<a[^>]+href="([^"]+)"[^>]*>(.+)<\/a>([Ss]*)/', $line, $reg_matches ) ) {
	                $ret = wp_oembed_get( $reg_matches[1] );
	                return $ret;
	            } elseif ( preg_match( $pattern, $line, $matches ) ) {
	                if ( strpos( $matches[0], '[' ) === 0 ) {
	                    $ret = do_shortcode( $matches[0] );
	                } else {
	                    $ret = wp_oembed_get( $matches[0] );
	                }
	                return $ret;
	            }
            }

        }
	}
}