Untitled
unknown
plain_text
3 years ago
20 kB
13
Indexable
<?php
/**
* Corporate Meta Astra Child Theme Theme functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Corporate Meta Astra Child Theme
* @since 1.0.0
*/
/**
* Define Constants
*/
define('CHILD_THEME_CORPORATE_META_ASTRA_CHILD_THEME_VERSION', '1.0.0');
// After setup theme
function hg_after_setup_theme_child()
{
add_theme_support('rank-math-breadcrumbs');
}
add_action('after_setup_theme', 'hg_after_setup_theme_child');
/**
* Enqueue styles
*/
function child_enqueue_styles()
{
wp_enqueue_style('hg-astra-child-theme-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_CORPORATE_META_ASTRA_CHILD_THEME_VERSION, 'all');
wp_enqueue_style('google-fonts', get_stylesheet_directory_uri() . '/google-fonts/stylesheet.css', array(), time(), 'all');
wp_enqueue_style("main_style", get_theme_file_uri('/css/main_style.css'), time());
}
add_action('wp_enqueue_scripts', 'child_enqueue_styles', 15);
/**
* Add SVG Support
*/
function kb_svg($svg_mime)
{
$svg_mime['svg'] = 'image/svg+xml';
return $svg_mime;
}
add_filter('upload_mimes', 'kb_svg');
function kb_ignore_upload_ext($checked, $file, $filename, $mimes)
{
if (!$checked['type']) {
$wp_filetype = wp_check_filetype($filename, $mimes);
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
$proper_filename = $filename;
if ($type && 0 === strpos($type, 'image/') && $ext !== 'svg') {
$ext = $type = false;
}
$checked = compact('ext', 'type', 'proper_filename');
}
return $checked;
}
add_filter('wp_check_filetype_and_ext', 'kb_ignore_upload_ext', 10, 4);
/**
* Enqueue scripts and styles.
*/
function dobla_scripts()
{
wp_enqueue_style('fontawesome', get_stylesheet_directory_uri() . '/css/fontawesome.min.css', array(), 1.0, 'screen');
wp_enqueue_style('slick-style', get_stylesheet_directory_uri() . '/css/slick.min.css', array(), 1.0);
wp_enqueue_script('typedjs', get_stylesheet_directory_uri() . '/js/typed.min.js', array(), 1.0, true);
wp_enqueue_script('typedjscm', get_stylesheet_directory_uri() . '/js/typed-cm.js', array(), 1.0, true);
wp_enqueue_script('slick-js', get_stylesheet_directory_uri() . '/js/slick.min.js', array('jquery'), 1.0 . true);
}
add_action('wp_enqueue_scripts', 'dobla_scripts');
/**
* Remove Google Fonts from Astra
*/
add_filter('astra_google_fonts_selected', function ($fonts) {
return [];
});
/**
* Remove scripts from Elementor
*/
add_filter('elementor/frontend/print_google_fonts', '__return_false');
add_action('elementor/frontend/after_register_styles', function () {
foreach (['solid', 'regular', 'brands'] as $style) {
wp_deregister_style('elementor-icons-fa-' . $style);
}
}, 20);
// add_action( 'wp_enqueue_scripts', 'remove_default_stylesheet', 20 );
// /* function remove_default_stylesheet() {
// wp_deregister_style( 'elementor-icons' );
// } */
/**
* CM color palette for WP color picker
*/
function your_prefix_astra_color_palettes()
{
$color_palettes = array(
'#ffffff',
'#666666',
'#404040',
'#475266',
'#8acccc',
'#59ba87',
'#f57329',
'#ffd170',
);
return $color_palettes;
}
add_filter('astra_color_palettes', 'your_prefix_astra_color_palettes');
function hook_css()
{
wp_enqueue_style("slick_min", get_theme_file_uri('/css/slick.min.css'));
wp_enqueue_style("main_style", get_theme_file_uri('/css/main_style.css'), time());
}
add_action('wp_head', 'hook_css');
function hook_js()
{
wp_enqueue_script('slick_scripts', get_theme_file_uri('/js/slick.min.js'), array('jquery'), true);
wp_enqueue_script('main_scripts', get_theme_file_uri('/js/scripts.js'), array('jquery'), time(), true);
}
add_action('wp_footer', 'hook_js');
// Social share
function ha_social_share($atts)
{
$sb_title = get_the_title();
$sb_url = get_the_permalink();
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u=' . $sb_url;
$twitterURL = 'https://twitter.com/intent/tweet?text=' . $sb_title . '&url=' . $sb_url;
$linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url=' . $sb_url . '&title=' . $sb_title;
$xingURL = 'https://www.xing.com/spi/shares/new?cb=0&url=' . $sb_url;
$content = '<div class="ha_social_share">';
$content .= '<a class="hs_btn facebook" href="' . $facebookURL . '" target="_blank" rel="nofollow"><svg xmlns="http://www.w3.org/2000/svg" width="13" height="26" viewBox="0 0 9.737 18.099"><path id="Icon_zocial-facebook" data-name="Icon zocial-facebook" d="M13.257,9.719V6.263h2.788V4.525a4.548,4.548,0,0,1,1.221-3.2A3.884,3.884,0,0,1,20.225,0h2.769V3.457H20.225a.61.61,0,0,0-.488.3,1.213,1.213,0,0,0-.217.733V6.262h3.474V9.718H19.519V18.1H16.044V9.719Z" transform="translate(-13.257)" fill="#4267b2"></path></svg></a>';
$content .= '<a class="hs_btn twitter" href="' . $twitterURL . '" target="_blank" rel="nofollow"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="20" viewBox="0 0 16.693 13.567"><path id="Icon_simple-twitter" data-name="Icon simple-twitter" d="M16.66,4.985a6.955,6.955,0,0,1-1.965.539A3.448,3.448,0,0,0,16.2,3.63a7.068,7.068,0,0,1-2.175.823A3.421,3.421,0,0,0,8.105,6.789a3.5,3.5,0,0,0,.088.782A9.691,9.691,0,0,1,1.141,4.005,3.354,3.354,0,0,0,.677,5.727,3.422,3.422,0,0,0,2.2,8.576,3.411,3.411,0,0,1,.65,8.147V8.19a3.424,3.424,0,0,0,2.744,3.357,3.453,3.453,0,0,1-1.538.059,3.433,3.433,0,0,0,3.2,2.377A6.863,6.863,0,0,1,.814,15.447,7.263,7.263,0,0,1,0,15.4a9.733,9.733,0,0,0,5.256,1.536,9.666,9.666,0,0,0,9.736-9.727c0-.145,0-.292-.01-.438A6.91,6.91,0,0,0,16.692,5l-.033-.014Z" transform="translate(0 -3.369)" fill="#1da1f2"/></svg></a>';
$content .= '<a class="hs_btn linkedin" href="' . $linkedInURL . '" target="_blank" rel="nofollow"><svg xmlns="http://www.w3.org/2000/svg" width="21" height="21" viewBox="0 0 14.583 14.582"><path id="Icon_awesome-linkedin-in" data-name="Icon awesome-linkedin-in" d="M3.264,14.583H.241V4.847H3.264ZM1.751,3.519A1.759,1.759,0,1,1,3.5,1.752,1.766,1.766,0,0,1,1.751,3.519ZM14.579,14.583H11.563V9.844c0-1.13-.023-2.578-1.572-2.578-1.572,0-1.813,1.227-1.813,2.5v4.821H5.158V4.847h2.9V6.175H8.1A3.177,3.177,0,0,1,10.96,4.6c3.06,0,3.622,2.015,3.622,4.632v5.348Z" transform="translate(0 -0.001)" fill="#0077b5"/></svg></a>';
$content .= '<a class="hs_btn linkedin" href="' . $xingURL . '" target="_blank" rel="nofollow"><svg xmlns="http://www.w3.org/2000/svg" width="25" height="29" viewBox="0 0 16.991 19.967"><path id="Icon_simple-xing" data-name="Icon simple-xing" d="M16.326,0a.843.843,0,0,0-.771.549s-6.2,11-6.408,11.362c.012.02,4.092,7.507,4.092,7.507a.9.9,0,0,0,.8.549h2.873a.429.429,0,0,0,.385-.183.456.456,0,0,0-.007-.446L13.236,11.92a.018.018,0,0,1,0-.018L19.613.629a.455.455,0,0,0,0-.445A.425.425,0,0,0,19.236,0ZM4.229,3.943a.442.442,0,0,0-.394.18.448.448,0,0,0,.017.442L5.8,7.934c0,.008,0,.013,0,.017l-3.057,5.4a.433.433,0,0,0,0,.44.415.415,0,0,0,.374.195H6a.882.882,0,0,0,.786-.555l3.106-5.5L7.91,4.478a.886.886,0,0,0-.8-.548H4.229v.013Z" transform="translate(-2.682)" fill="#026466"/></svg></a>';
$content .= '<div>';
return $content;
}
add_shortcode('ha_social_share_shortcode', 'ha_social_share');
// Blog page banner image
add_image_size('blog-banner-image', 940, 760, true); // Hard Crop Mode
add_action('wpcf7_mail_sent', 'ha_send_form_data_to_mailing', 10, 1);
function ha_send_form_data_to_mailing($contactform)
{
$debug = false;
// return $contactform;
switch ($contactform->id) {
case 12507:
$listId = 12;
break;
case 8289:
$listId = 6;
break;
case 890:
$listId = 22;
break;
case 9877:
$listId = 8;
break;
case 5435:
$listId = 4;
break;
case 9887:
$listId = 10;
break;
case 14585:
$listId = 15;
}
if ($debug) {
// $listId = 16;
$listId = 6;
}
if (!$listId) {
return $contactform;
}
$submission = WPCF7_Submission::get_instance();
if (!$submission) {
return $contactform;
}
$formdata = $submission->get_posted_data();
$fields = [
'E-Mail' => $formdata['E-Mail'],
'Vorname' => $formdata['Vorname'],
'Nachname' => $formdata['Nachname'],
];
if (isset($formdata['Message'])) {
$fields['Freitext Formular'] = $formdata['Message'];
}
$fields['Profiling'] = (isset($formdata['Profiling']) && !empty($formdata['Profiling'][0])) ? 1 : 0;
$fieldslist = ['Telefon', 'Anrede', 'Postleitzahl', 'Industrie', 'Mitarbeiteranzahl', 'Handlungsfelder', 'Tarifvertrag', 'Nebenleistungen', 'Unternehmensname', 'Position'];
foreach ($fieldslist as $field) {
if (isset($formdata[$field])) {
if (is_array($formdata[$field])) {
$fields[$field] = $formdata[$field][0];
} else {
$fields[$field] = $formdata[$field];
}
}
}
if (isset($formdata['utm_campaign'])) {
$fields['Kampagne'] = $formdata['utm_campaign'];
}
if (isset($formdata['utm_source'])) {
$fields['Quelle'] = $formdata['utm_source'];
}
if (isset($formdata['utm_medium'])) {
$fields['Medium'] = $formdata['utm_medium'];
}
if (isset($formdata['cmcf7_booking_form_date']))
{
// $fields['Datum Terminvereinbarung'] = $formdata['cmcf7_booking_form_date'];
$tdate = DateTime::createFromFormat('d.m.Y', $formdata['cmcf7_booking_form_date']);
$fields['Datum Terminvereinbarung'] = date_format($tdate, 'Y-m-d');
}
if (isset($formdata['cmcf7_booking_form_time']))
{
$fields['Uhrzeit Terminvereinbarung'] = $formdata['cmcf7_booking_form_time'];
}
if (in_array($listId, [4, 6, 8, 10, 12, 15])) {
$result = ha_send_form_data_to_mailing_optinrecipient($listId, $fields, $debug);
} else {
$result = ha_send_form_data_to_mailing_createrecipient($listId, $fields, $debug);
}
// DEBUG
if ($debug) {
echo '<pre>';
print_R($formdata);
echo '</pre>';
echo '<pre>';
print_R($fields);
echo '</pre>';
echo '<pre>';
print_R($result);
echo '</pre>';
}
return $contactform;
}
function ha_send_form_data_to_mailing_createrecipient($listId, $fields, $debug)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://webservice.mailingwork.de/webservice/webservice/json/createrecipient');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(
array(
'username' => HA_MAILING_USER,
'password' => HA_MAILING_PASS,
'listId' => $listId,
'fields' => $fields
)
));
return json_decode(curl_exec($ch), true);
}
function ha_send_form_data_to_mailing_optinrecipient($listId, $fieldsin, $debug)
{
if (isset($fieldsin['E-Mail'])) {
$fields[2] = $fieldsin['E-Mail'];
}
if (isset($fieldsin['Vorname'])) {
$fields[6] = $fieldsin['Vorname'];
}
if (isset($fieldsin['Nachname'])) {
$fields[8] = $fieldsin['Nachname'];
}
if (isset($fieldsin['Telefon'])) {
$fields[24] = $fieldsin['Telefon'];
}
if (isset($fieldsin['Unternehmensname'])) {
$fields[26] = $fieldsin['Unternehmensname'];
}
if (isset($fieldsin['Postleitzahl'])) {
$fields[16] = $fieldsin['Postleitzahl'];
}
if (isset($fieldsin['Mitarbeiteranzahl'])) {
$fields[18] = $fieldsin['Mitarbeiteranzahl'];
}
if (isset($fieldsin['Position'])) {
$fields[14] = $fieldsin['Position'];
}
if (isset($fieldsin['Industrie'])) {
$fields[22] = $fieldsin['Industrie'];
}
if (isset($fieldsin['Handlungsfelder'])) {
$fields[28] = $fieldsin['Handlungsfelder'];
}
if (isset($fieldsin['Tarifvertrag'])) {
$fields[32] = $fieldsin['Tarifvertrag'];
}
if (isset($fieldsin['Kampagne'])) {
$fields[41] = $fieldsin['Kampagne'];
}
if (isset($fieldsin['Medium'])) {
$fields[39] = $fieldsin['Medium'];
}
if (isset($fieldsin['Quelle'])) {
$fields[37] = $fieldsin['Quelle'];
}
if (isset($fieldsin['Postleitzahl'])) {
$fields[16] = $fieldsin['Postleitzahl'];
}
if (isset($fieldsin['Nebenleistungen'])) {
$fields[34] = $fieldsin['Nebenleistungen'];
}
if (isset($fieldsin['Datum Terminvereinbarung']))
{
$fields[64] = $fieldsin['Datum Terminvereinbarung'];
}
if (isset($fieldsin['Uhrzeit Terminvereinbarung']))
{
$fields[66] = $fieldsin['Uhrzeit Terminvereinbarung'];
}
if (!in_array($listId, [6, 12])) {
if (isset($fieldsin['Profiling'])) {
$fields[12] = $fieldsin['Profiling'];
}
if (isset($fieldsin['Anrede'])) {
$fields[4] = $fieldsin['Anrede'];
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://webservice.mailingwork.de/webservice/webservice/json/optinrecipient');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(
array(
'username' => HA_MAILING_USER,
'password' => HA_MAILING_PASS,
'optinSetupId' => $listId,
'fields' => $fields
)
));
if ($debug) {
return [
'listid' => $listId,
'fields' => $fields,
'return' => json_decode(curl_exec($ch), true)
];
}
return json_decode(curl_exec($ch), true);
}
// Remove google and astra fonts
add_filter('astra_google_fonts', '__return_empty_array');
add_filter('elementor/frontend/print_google_fonts', '__return_false');
// Redirection ==============================
function hallesche_redirect()
{
if (
isset($_SERVER['HTTPS']) &&
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'
) {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$currenturl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currenturl_relative = wp_make_link_relative($currenturl);
// echo '<pre>';
// var_dump($currenturl_relative);
// echo '</pre>';
switch ($currenturl_relative) {
case '/betriebliche-krankenversicherung-steuer':
$urlto = home_url('/betriebliche-krankenversicherung/steuer/');
break;
case '/betriebliche-krankenversicherung-steuer/':
$urlto = home_url('/betriebliche-krankenversicherung/steuer/');
break;
case '/betriebliche-krankenversicherung-leistungen':
$urlto = home_url('/betriebliche-krankenversicherung/leistungen/');
break;
case '/betriebliche-krankenversicherung-leistungen/':
$urlto = home_url('/betriebliche-krankenversicherung/leistungen/');
break;
case '/kosten':
$urlto = home_url('/betriebliche-krankenversicherung/kosten/');
break;
case '/kosten/':
$urlto = home_url('/betriebliche-krankenversicherung/kosten/');
break;
case '/betriebliche-krankenversicherung-kosten':
$urlto = home_url('/betriebliche-krankenversicherung/kosten/');
break;
case '/betriebliche-krankenversicherung-kosten/':
$urlto = home_url('/betriebliche-krankenversicherung/kosten/');
break;
case '/betriebliche-krankenversicherung-finanzierungsmodelle/':
$urlto = home_url('/betriebliche-krankenversicherung/finanzierungsmodelle/');
break;
case '/betriebliche-krankenversicherung-finanzierungsmodelle':
$urlto = home_url('/betriebliche-krankenversicherung/finanzierungsmodelle/');
break;
case '/kontakt':
$urlto = site_url('/');
break;
case '/kontakt/':
$urlto = site_url('/');
break;
case '/ratgeber-employer-branding':
$urlto = home_url('/ratgeber/employer-branding/');
break;
case '/ratgeber-employer-branding/':
$urlto = home_url('/ratgeber/employer-branding/');
break;
case '/album/feel-the-benefits/':
$urlto = home_url('/podcast/');
break;
default:
return;
}
if ($currenturl != $urlto) {
exit(wp_redirect($urlto, 301));
}
}
add_action('template_redirect', 'hallesche_redirect');
// Unregister Elementor and WP widgets
add_action('elementor/widgets/widgets_registered', function($widgets_manager){
global $elementor_widget_blacklist;
$elementor_widget_blacklist = [
'google-maps'
,'counter'
,'progress'
,'testimonial'
,'tabs'
,'accordion'
,'toggle'
,'social-icons'
,'alert'
,'audio'
,'menu-anchor'
,'sidebar'
,'star-rating',
'read-more',
'text-path',
'code-highlight'
// wp widgets ----------------- //
,'wp-widget-pages'
,'wp-widget-archives'
,'wp-widget-media_audio'
,'wp-widget-media_image'
,'wp-widget-media_gallery'
,'wp-widget-media_video'
,'wp-widget-meta'
,'wp-widget-search'
,'wp-widget-text'
,'wp-widget-categories'
,'wp-widget-recent-posts'
,'wp-widget-recent-comments'
,'wp-widget-rss'
,'wp-widget-tag_cloud'
,'wp-widget-nav_menu'
,'wp-widget-custom_html'
,'wp-widget-polylang'
,'wp-widget-calendar'
,'wp-widget-elementor-library'
];
foreach($elementor_widget_blacklist as $widget_name){
$widgets_manager->unregister($widget_name);
}
}, 15);
// Unregister Elementor pro widgets
add_action('elementor/widgets/register', function($widgets_manager){
$elementor_widget_blacklists = [
'portfolio',
'google-maps'
,'form'
,'login'
,'media-carousel'
,'testimonial-carousel'
,'pricing'
,'facebook-comment'
,'animated-headline'
,'price-list'
,'price-table'
,'facebook-button'
,'facebook-comments'
,'facebook-embed'
,'facebook-page'
,'add-to-cart'
,'categories'
,'elements'
,'products'
,'flip-box'
,'carousel'
,'countdown'
,'share-buttons'
,'author-box'
,'breadcrumbs'
,'search-form'
,'post-comments'
,'theme-elements'
,'template'
,'wp-widget-audio'
,'woocommerce'
,'social'
,'library',
'reviews',
'hotspot',
'paypal-button',
'table-of-contents',
'video-playlist',
'text-path',
'code-highlight'
];
foreach($elementor_widget_blacklists as $widget_name){
$widgets_manager->unregister($widget_name);
}
}, 15);
// Disable Gutenburg editor
add_filter('use_block_editor_for_post', '__return_false', 10);
// Add CSS for removing extra icon in post editor
add_action('admin_head', 'hall_custom_css');
function hall_custom_css() {
echo '<style>
.wp-pointer {
display: none !important;
}
</style>';
}
function hall_manage_header_menus(){
$header_menu = get_field('select_menu_visibilty');
if ($header_menu) {
echo '<style>
.elementor-element-2542728, .elementor-element-7db058b, .elementor-sticky__spacer {
display: none !important;
}
.main-header-sticky {
box-shadow: none;
position: inherit !important;
}
.elementor-element-06191ab {
position: inherit !important;
}
.main-header-sticky #site-logo img {
width: 100% !important;
}
.main-header.main-header-sticky {
padding-top: inherit !important;
padding-bottom: inherit !important;
}
.main-header .elementor-widget-theme-site-logo a {
pointer-events: none;
cursor: none;
}
</style>';
} else {
echo '
<script>
$ = jQuery;
$(document).ready(function() {
window.onscroll = function(e) {
if(window.scrollY >= 100){
document.querySelector(\'.main-header\')?.classList?.add(\'main-header-sticky\')
}else {
document.querySelector(\'.main-header\')?.classList?.remove(\'main-header-sticky\')
}
};
});
</script>
';
}
}
add_action( 'wp_head', 'hall_manage_header_menus' );
function hallcreate_post_type() {
register_post_type( 'podcast',
array(
'labels' => array(
'name' => __( 'podcast' ),
'singular_name' => __( 'podcast' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'podcast'),
)
);
}
add_action( 'init', 'hallcreate_post_type' );
Editor is loading...