HEX
Server: Apache
System: Linux srv-plesk28.ps.kz 5.14.0-284.18.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 29 17:06:27 EDT 2023 x86_64
User: greencl1 (10085)
PHP: 8.1.33
Disabled: apache_setenv,dl,eval,exec,openlog,passthru,pcntl_exec,pcntl_fork,popen,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,socket_create,socket_create_listen,socket_create_pair,syslog,system,socket_listen,stream_socket_server
Upload Files
File: /var/www/vhosts/greenclinic.kz/newsite/wp-content/themes/green-clinic/inc/template-functions.php
<?php

require 'vendor/autoload.php';

use Sendpulse\RestApi\ApiClient;
use Sendpulse\RestApi\Storage\FileStorage;
use Sendpulse\RestApi\ApiClientException;

/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package Green_clinic
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function green_clinic_body_classes( $classes ) {
	// Adds a class of hfeed to non-singular pages.
	global $post;
	if ( is_front_page() ){
		$classes[] = 'hfeed';
		$classes[] = 'front-page';
		$classes[] = 'main';
	}else{
		$classes[] = 'main not-front-page hfeed ';
		$classes[] = 'page-' .$post->post_name;   
	}

	return $classes;
}
add_filter( 'body_class', 'green_clinic_body_classes' );

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 */
function green_clinic_pingback_header() {
	if ( is_singular() && pings_open() ) {
		printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
	}
}
add_action( 'wp_head', 'green_clinic_pingback_header' ); 

/**
 * Filter the_content
 */
function action_the_content($content)
{
  $content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
  $content = preg_replace('/<p>(<iframe\s+.*)<\/p>/iU', '<div class="media-video"><div class="media-video-169">\1</div></div>', $content);
  return $content;
}
add_action('the_content', 'action_the_content', 10, 1);


/**
 * ContactForm7 action wpcf7_before_send_mail
 */
function action_wpcf7_before_send_mail($contact_form, &$abort, $submission)
{
  $formid = $contact_form->id();

  if ( $formid == 1049 ) {
    // sendpulse
    $client_id = 'd2fe6587051c5d6bdeb3b5ffcd0cb3ee';
    $client_secret = '41049bd5737b061c53873b5eb4415c6e';
    $mailinglist = 1066610;

    $info = $submission->get_posted_data('sendpulse-field');
    $info = ( $info ) ? json_decode($info,true) : [];

    $data = [
      'email' => $submission->get_posted_data('you-email'),
      'variables' => [
        'phone' => $submission->get_posted_data('you-phone'),
        'Name' => $submission->get_posted_data('you-name'),
        'Surname' => $submission->get_posted_data('you-last-name'),
        'Date' => date('m/d/Y', strtotime($info['date'])),
        'Age' => $info['age'],
        'Specialist' => $info['specialist'],
      ]
    ];

    $apiClient = new ApiClient($client_id, $client_secret, new FileStorage());
    $result = $apiClient->post("addressbooks/{$mailinglist}/emails", [
      'emails' => [ $data ]
    ]);
  }
}
add_action('wpcf7_before_send_mail', 'action_wpcf7_before_send_mail', 99, 3);