| Server IP : 141.193.213.10 / Your IP : 216.73.216.101 Web Server : nginx System : Linux pod-400555 6.8.0-1055-gke #61-Ubuntu SMP Tue May 26 22:57:42 UTC 2026 x86_64 User : fpm200079 ( 200079) PHP Version : 8.2.36 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nas/content/live/bartislaw/wp-content/themes/spk/includes/theme-functions/ |
Upload File : |
<?php
// 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_filter('pre_user_description', 'wp_filter_kses');
remove_action('admin_print_styles', 'print_emoji_styles');
// REMOVE WP-Head Unnecessary Tags
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.
add_theme_support('post-thumbnails');
// Enqueue Styles and js
function add_defer_attribute($tag, $handle) {
// add script handles to the array below
$scripts_to_defer = array('my-js-handle', 'another-handle');
foreach ($scripts_to_defer as $defer_script) {
if ($defer_script === $handle) {
return str_replace(' src', ' defer="defer" src', $tag);
}
}
return $tag;
}
add_filter('script_loader_tag', 'add_defer_attribute', 10, 2);
if (!is_admin()) {
function add_asyncdefer_attribute($tag, $handle) {
// if the unique handle/name of the registered script has 'async' in it
if (strpos($handle, 'async') !== false) {
// return the tag with the async attribute
return str_replace('<script ', '<script async ', $tag);
}
// if the unique handle/name of the registered script has 'defer' in it
else if (strpos($handle, 'defer') !== false) {
// return the tag with the defer attribute
return str_replace('<script ', '<script defer ', $tag);
}
// otherwise skip
else {
return $tag;
}
}
add_filter('script_loader_tag', 'add_asyncdefer_attribute', 10, 2);
}
function enqueue_my_scripts() {
// script to load asynchronously
wp_enqueue_script('theme-main-js-defer', get_template_directory_uri() . '/js/main.js', 5.1, true);
}
add_action('wp_enqueue_scripts', 'enqueue_my_scripts', 9999);
function spk_add_theme_scripts() {
/* ......................................... */
// wp_enqueue_style('theme-css', get_template_directory_uri() . '/style.css', false, '1.1', 'all');
wp_enqueue_style('theme-main-css', get_template_directory_uri() . '/css/main.css', false, '1.0', 'all');
/* ......................................... */
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
add_action('wp_footer', 'wp_print_scripts', 6);
add_action('wp_head', 'wp_enqueue_scripts', 4);
add_action('wp_footer', 'vc_page_css_enqueue', 2);
add_action('wp_footer', 'wp_enqueue_scripts', 6);
add_action('wp_footer', 'wp_print_head_scripts', 5);
}
add_action('wp_enqueue_scripts', 'spk_add_theme_scripts');
function remove_jquery_migrate(&$scripts) {
if (!is_admin()) {
$scripts->remove('jquery');
$scripts->add('jquery', false, array('jquery-core'));
}
}
add_filter('wp_default_scripts', 'remove_jquery_migrate');
/* ..............Menu Location Add............... */
function spk_menu_loc() {
register_nav_menu('menu1', __('Primary Menu', 'spk_lawyer'));
register_nav_menu('menu2', __('Secondary Menu', 'spk_lawyer'));
register_nav_menu('menu3', __('Footer Menu', 'spk_lawyer'));
}
add_action('after_setup_theme', 'spk_menu_loc');
/* ....................Image Responsive Funcation.................,... */
function spk_adjust_image_sizes_attr($sizes, $size) {
if ($size[0] > 299) {
$sizes = '(max-width: 480px) 100vw,(max-width: 767px) 40vw,' . $size[0] . 'px';
} return $sizes;
}
function spk_image_class_filter($class) {
$class = str_replace("alignleft", "float-left mb-3 mr-3 mb-sm-2", $class);
$class = str_replace("alignright", "float-right mb-3 ml-3 mb-sm-2", $class);
$class = str_replace("alignnone", "float-none", $class);
$class = str_replace("aligncenter", "mx-auto d-block pb-3", $class);
return $class;
}
function spk_remove_width_attribute($html) {
$html = preg_replace('/(width|height)="\d*"\s/', "", $html);
return $html;
}
add_filter('wp_calculate_image_sizes', 'spk_adjust_image_sizes_attr', 10, 2);
add_filter('get_image_tag_class', 'spk_image_class_filter');
add_filter('image_send_to_editor', 'spk_remove_width_attribute', 10);
/* .....................Add Category To Page Funcation................................... */
function spk_add_cat_to_page() {
register_taxonomy_for_object_type('category', 'page');
}
add_action('init', 'spk_add_cat_to_page');
/* .....................PrintArray Funcation................................... */
function MYRprintArray($array, $exit = FALSE) {
echo '<pre>' . print_r($array, TRUE) . '</pre>';
if ($exit) {
exit();
}
}
/* ..................... Hide editor on specific pages Funcation................................... */
/* .......................Limit The Excerpt Words.......................... */
function SPK_Excerpt($limit) {
return wp_trim_words(get_the_content(), $limit);
}
/* ....................Post Navigation................... */
function spk_post_nav() {
$previous = ( is_attachment() ) ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<div class="navigation-blog-detail-page">
<div class="row">
<?php
previous_post_link('<div class="col text-left">%link', __('<i class="fa fa-chevron-left" aria-hidden="true"></i> Previous Post</div>', 'spk'));
next_post_link('<div class="col text-right">%link', __('Next Post <i class="fa fa-chevron-right" aria-hidden="true"></i></div>', 'spk'));
?>
</div>
</div>
<?php
}
/* .......................Get Avatar Image Url.......................... */
function get_avatar_img_url($imgUrl) {
$doc = new DOMDocument();
$doc->loadHTML($imgUrl);
$imageTags = $doc->getElementsByTagName('img');
foreach ($imageTags as $tag) {
return $tag->getAttribute('src');
}
}
/* .....................Get Image ALt Text By Url............................. */
function GetImgAltTextByUrl($URL_IMG) {
$feature1_id = attachment_url_to_postid($URL_IMG);
$image1_alt = get_post_meta($feature1_id, '_wp_attachment_image_alt', true);
return $image1_alt;
}
/* ....................Add Inline Css Customizer Wordpress....................... */
function SPKStylesMethod() {
$CustomizerCss = get_theme_mod('custom_css');
$CustomCss = $CustomizerCss;
wp_add_inline_style('customizer-styles', $CustomCss);
}
add_action('wp_enqueue_scripts', 'SPKStylesMethod');
/* ....................Add Fav Icon in Header....................... */
function SPKAddFavicon() {
echo '<link rel="shortcut icon" type="image/png" href="' . get_theme_mod('theme_fav_ico') . '" />';
}
add_action('wp_head', 'SPKAddFavicon');
/* .......................Get Ip Address.......................... */
function MYRgetClientIP() {
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
return $_SERVER["HTTP_X_FORWARDED_FOR"];
if (isset($_SERVER["HTTP_CLIENT_IP"]))
return $_SERVER["HTTP_CLIENT_IP"];
return $_SERVER["REMOTE_ADDR"];
}
if (getenv('HTTP_X_FORWARDED_FOR'))
return getenv('HTTP_X_FORWARDED_FOR');
if (getenv('HTTP_CLIENT_IP'))
return getenv('HTTP_CLIENT_IP');
return getenv('REMOTE_ADDR');
}
/* ....................All Form Requests....................... */
add_action('wp_ajax_TestimonailAddTbl', 'TestimonailAddTbl');
add_action('wp_ajax_nopriv_TestimonailAddTbl', 'TestimonailAddTbl');
function TestimonailAddTbl() {
include_once 'other-files/add-testimonials.php';
}
/* .......................Get Contents File.......................... */
require_once 'get-contents-data.php';
function get_cYear($atts) {
$return = date('Y');
return $return;
}
add_shortcode('current_y', 'get_cYear');
/* ...................Attorney Years Shortcode....................... */
function get_cyear_sum($atts) {
global $data;
if (!empty($atts['start_year'])) {
$starting_year = $atts['start_year'];
} else {
$starting_year = "";
}
$dob = new DateTime($starting_year);
$today = new DateTime;
$age = $today->diff($dob);
return $age->format('%y');
}
add_shortcode('sum_y', 'get_cyear_sum');