< ?php require get_template_directory() . '/post-types/bioproduct.php'; require get_template_directory() . '/post-types/distributor.php'; require get_template_directory() . '/post-types/socialmedia.php'; require get_template_directory() . '/post-types/contact.php'; /** * Do not edit anything in this file unless you know what you're doing */ use Roots\Sage\Config; use Roots\Sage\Container; /** * Helper function for prettying up errors * @param string $message * @param string $subtitle * @param string $title */ $sage_error = function ($message, $subtitle = '', $title = '') { $title = $title ?: __('Sage › Error', 'sage'); $footer = 'roots.io/sage/docs/'; $message = "

{$title}
{$subtitle}

{$message}

{$footer}

"; wp_die($message, $title); }; /** * Ensure compatible version of PHP is used */ if (version_compare('7.1', phpversion(), '>=')) { $sage_error(__('You must be using PHP 7.1 or greater.', 'sage'), __('Invalid PHP version', 'sage')); } /** * Ensure compatible version of WordPress is used */ if (version_compare('4.7.0', get_bloginfo('version'), '>=')) { $sage_error(__('You must be using WordPress 4.7.0 or greater.', 'sage'), __('Invalid WordPress version', 'sage')); } /** * Ensure dependencies are loaded */ if (!class_exists('Roots\\Sage\\Container')) { if (!file_exists($composer = __DIR__.'/../vendor/autoload.php')) { $sage_error( __('You must run composer install from the Sage directory.', 'sage'), __('Autoloader not found.', 'sage') ); } require_once $composer; } /** * Sage required files * * The mapped array determines the code library included in your theme. * Add or remove files to the array as needed. Supports child theme overrides. */ array_map(function ($file) use ($sage_error) { $file = "../app/{$file}.php"; if (!locate_template($file, true, true)) { $sage_error(sprintf(__('Error locating %s for inclusion.', 'sage'), $file), 'File not found'); } }, ['helpers', 'setup', 'filters', 'admin']); /** * Here's what's happening with these hooks: * 1. WordPress initially detects theme in themes/sage/resources * 2. Upon activation, we tell WordPress that the theme is actually in themes/sage/resources/views * 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage/resources * * We do this so that the Template Hierarchy will look in themes/sage/resources/views for core WordPress themes * But functions.php, style.css, and index.php are all still located in themes/sage/resources * * This is not compatible with the WordPress Customizer theme preview prior to theme activation * * get_template_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources * get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources * locate_template() * ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views * └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources */ array_map( 'add_filter', ['theme_file_path', 'theme_file_uri', 'parent_theme_file_path', 'parent_theme_file_uri'], array_fill(0, 4, 'dirname') ); Container::getInstance() ->bindIf('config', function () { return new Config([ 'assets' => require dirname(__DIR__).'/config/assets.php', 'theme' => require dirname(__DIR__).'/config/theme.php', 'view' => require dirname(__DIR__).'/config/view.php', ]); }, true); add_image_size('customImageSize', 650, 650, true); add_image_size('productImage', 80, 180, true); add_image_size('frontblog', 900, 900, true); add_image_size('newsletter', 730, 730, true); add_image_size('about', 600, 600, true); add_image_size('productSingle', 250, 250, true); add_image_size('news', 500, 500, true); add_image_size('media', 450, 450, true); add_image_size('program', 70, 70, true); function custom_excerpt_length( $length ) { return 25; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); function wpsites_query( $query ) { //if ( $query->is_archive() && $query->is_main_query() ) { // $query->set( 'posts_per_page', 2 ); // } } add_action( 'pre_get_posts', 'wpsites_query' ); function pagination_simple( $args = array() ) { global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var('paged')); echo ''; } } function icl_post_languages(){ $languages = icl_get_languages('skip_missing=1'); if(1 < count($languages)){ foreach($languages as $l){ if(!$l['active']) { $langs[] = '
  • '.$l['language_code'].'
  • '; } else { $langs[] = '
  • '.$l['language_code'].'
  • '; } } echo ''; } } if( function_exists('acf_add_options_page') ) { acf_add_options_page(array( 'page_title' => 'Theme General Settings', 'menu_title' => 'Theme Settings', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', 'redirect' => false )); acf_add_options_sub_page(array( 'page_title' => 'Theme Header Settings', 'menu_title' => 'Header', 'parent_slug' => 'theme-general-settings', )); acf_add_options_sub_page(array( 'page_title' => 'Theme Footer Settings', 'menu_title' => 'Footer', 'parent_slug' => 'theme-general-settings', )); } $discountSend = "test"; $vmail = "test"; $newsletterSend = "test"; $message = "Błąd SMTP"; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $vmail; if(isset($_POST['user_email'])) { $vmail = trim($_POST['user_email']); //echo $vmail; if (!filter_var($vmail, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; return false; } try { $to = 'biuro@biodermic.pl'; $subject = 'Formularz kontaktowy Biodermic'; $body = ''; $body .= $_POST['firstName'] . '
    '; $body .= $_POST['lastName'] . '
    '; $body .= $_POST['userText'] . '
    '; $headers[] = 'From: Biodermic < '. $vmail . '>'; $headers[] = 'Cc: Marcin Waniek '; $headers[] = 'Content-Type: text/html; charset=UTF-8'; wp_mail( $to, $subject, $body, $headers ); $message = "Wiadomość została wysłana"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } if(!$phpmailer->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $phpmailer->ErrorInfo; exit; } else { echo $message; } } if(isset($_POST['newsletterAgree'])) { $vmail = trim($_POST['newsletterAgree']); //echo $vmail; if (!filter_var($vmail, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; return false; } try { $to = 'biuro@biodermic.pl'; $subject = 'Zapis na newsletter'; $body = 'Zapis na newsletter: '; $body .= $_POST['newsletterAgree'] . '
    '; $headers[] = 'From: Biodermic '; //$headers[] = 'Cc: Marcin Waniek '; $headers[] = 'Content-Type: text/html; charset=UTF-8'; wp_mail( $to, $subject, $body, $headers ); $message = "Twój adres email został zapisany do newslettera"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } if(!$phpmailer->Send()) { $newsletterSend = false; echo 'Message could not be sent.'; echo 'Mailer Error: ' . $phpmailer->ErrorInfo; exit; } else { echo $message; } } if(isset($_POST['getDiscount'])) { $vmail = trim($_POST['getDiscount']); //echo $vmail; if (!filter_var($vmail, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; return false; } try { $to = 'biuro@biodermic.pl'; $subject = 'Zniżka'; $body = 'Zniżka dla: '; $body .= $_POST['getDiscount'] . '
    '; $headers[] = 'From: Biodermic '; // $headers[] = 'Cc: Marcin Waniek '; $headers[] = 'Content-Type: text/html; charset=UTF-8'; wp_mail( $to, $subject, $body, $headers ); $message = "Zapytanie zostało wysłane"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } if(!$phpmailer->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $phpmailer->ErrorInfo; exit; } else { echo $message; } } } function SearchFilter($query) { if ($query->is_search) { // && isset($_GET['searchsubmit']) $query->set('post_type', array('bioproduct')); } return $query; } add_filter('pre_get_posts','SearchFilter');