public function create_subscription($data = null)
 {
     $settings = get_option('fwe_settings');
     if (!fwe_theme_option_exists('mailchimp_api_key')) {
         return new WP_Error('apikey', 'Please enter a MailChimp API key in Theme Options');
     }
     if (!fwe_theme_option_exists('mailchimp_list_id')) {
         return new WP_Error('nolist', 'Please select a MailChimp list in Theme Options');
     }
     if (!array_key_exists('name', $data) || empty($data['name'])) {
         return new WP_Error('noname', 'Please enter your name and try again!');
     }
     if (!array_key_exists('email', $data) || empty($data['email']) || !is_email($data['email'])) {
         return new WP_Error('noemail', 'Please enter a valid email address and try again!');
     }
     $first_name = fwe_get_given_name($data['name']);
     $last_name = fwe_get_surname($data['name']);
     $chimp = new \Drewm\MailChimp($settings['mailchimp_api_key']);
     $result = $chimp->call('lists/subscribe', array('id' => $settings['mailchimp_list_id'], 'email' => array('email' => $data['email']), 'merge_vars' => array('FNAME' => $first_name, 'LNAME' => $last_name)));
     if (array_key_exists('status', $result) && $result['status'] === 'error') {
         return new WP_Error('error', $result['error']);
     }
     $resp = new WP_JSON_Response();
     $result['status'] = 'success';
     $result['message'] = $settings['subscribe_success_message'];
     $resp->set_data($result);
     return $resp;
 }
Example #2
0
/**
 * Fourth Wall Events
 * WordPress Login Logo Customization
 */
function fwe_login_logo()
{
    $settings = get_option('fwe_settings');
    if (!fwe_theme_option_exists('admin_logo')) {
        return;
    }
    list($src, $width, $height, $scale) = wp_get_attachment_image_src($settings['admin_logo'], 'full');
    ?>
  <style type="text/css">
    body.login div#login h1 a {
      background-image: url('<?php 
    echo $src;
    ?>
');
      background-size: <?php 
    echo $width;
    ?>
px <?php 
    echo $height;
    ?>
px;
      background-repeat: no-repeat;
      width: <?php 
    echo $width;
    ?>
px;
      height: <?php 
    echo $height;
    ?>
px;
    }
  </style>
<?php 
}
function fwe_gforms_request_signature($route, $method = 'GET')
{
    $settings = get_option('fwe_settings');
    if (fwe_theme_option_exists('gforms_api_key') && fwe_theme_option_exists('gforms_private_key')) {
        $api_key = $settings['gforms_api_key'];
        $private_key = $settings['gforms_private_key'];
    } else {
        $api_key = 'bf72b8cd58';
        $private_key = '3d86b92f6e1a864';
    }
    $expiration = strtotime('+60 mins');
    $sign_string = sprintf('%s:%s:%s:%s', $api_key, $method, $route, $expires);
    $hash = hash_hmac('sha1', $sign_string, $private_key, true);
    return rawurlencode(base64_encode($hash));
}
<?php

global $fwe_settings;
$has_banner = fwe_theme_option_exists('where_weve_been_banner');
if ($has_banner) {
    $banner = wp_get_attachment_image_src($fwe_settings['where_weve_been_banner'], 'full');
    ?>
  <section class="banner where-weve-been">
    <figure id="page-banner">
      <img src="<?php 
    echo $banner[0];
    ?>
" alt="Where We've Been" width="100%">
      <figcaption>Where We've Been</figcaption>
    </figure>
  </section>
<?php 
}
<?php

/*
Title: MailChimp Settings
Setting: fwe_settings
Tab: MailChimp
*/
// Load MailChimp API wrapper
$theme_dir = trailingslashit(dirname(__FILE__)) . '../../../';
require_once $theme_dir . 'includes/vendor/autoload.php';
$fwe_settings = get_option('fwe_settings');
piklist('field', array('type' => 'text', 'field' => 'mailchimp_api_key', 'label' => 'MailChimp API Key', 'description' => 'You can find this by viewing your profile in MailChimp and selecting Extras &gt; API Keys', 'value' => 'cbb2a7e4d7c04540270ae1d494efe0c0-us8'));
if (fwe_theme_option_exists('mailchimp_api_key')) {
    $mc = new \Drewm\MailChimp($fwe_settings['mailchimp_api_key']);
    $lists = $mc->call('lists/list');
    $list_choices = array('' => '-- Select a List --');
    foreach ($lists['data'] as $list) {
        $list_choices[$list['id']] = $list['name'];
    }
    piklist('field', array('type' => 'select', 'field' => 'mailchimp_list_id', 'label' => 'Subscriber List', 'choices' => $list_choices));
}
piklist('field', array('type' => 'textarea', 'field' => 'subscribe_success_message', 'label' => 'Subscription Success Message', 'description' => 'Displayed to users upon successful subscription to FWE\'s email list. No HTML allowed.', 'value' => 'Thanks for subscribing! Please check your inbox for a confirmation link.', 'attributes' => array('rows' => 4, 'cols' => 40)));
<?php

global $fwe_settings;
$slider_speed = fwe_theme_option_exists('global_slider_speed') ? $fwe_settings['global_slider_speed'] : 8;
?>
<div class="main-page-slider">
  <div class="slides" data-speed="<?php 
echo esc_attr($slider_speed);
?>
">
    <?php 
for ($i = 0; $i < count($slider_images['image']); $i++) {
    ?>
      <?php 
    $title = $slider_images['title'][$i];
    $link_url = $slider_images['link_url'][$i];
    $image = fwe_get_first_valid_image($slider_images['image'][$i]);
    $image = wp_get_attachment_image_src($image, 'full');
    $src_attr = fwe_lazy_load_img_src($image[0], $i);
    ?>
      <figure class="slide">
        <a href="<?php 
    echo esc_url($link_url);
    ?>
">
          <img <?php 
    echo $src_attr;
    ?>
 alt="<?php 
    echo $title;
    ?>
<?php

/**
 * Facebook Feed Partial
 */
global $fwe_settings;
if (fwe_theme_option_exists('facebook_page_url')) {
    ?>
  <section id="facebook" class="content-section bg-none">
    <div class="section-inner">
      <h2>Fourth Wall on Facebook</h2>

      <div
        class="fb-like-box"
        data-href="<?php 
    echo esc_url($fwe_settings['facebook_page_url']);
    ?>
"
        data-width="<?php 
    echo $fwe_settings['facebook_widget_width'];
    ?>
"
        data-height="<?php 
    echo $fwe_settings['facebook_widget_height'];
    ?>
"
        data-colorscheme="light"
        data-show-faces="false"
        data-header="false"
        data-stream="true"
        data-show-border="<?php 
" itemprop="thumbnailUrl">
        </div>
      <?php 
        }
        ?>

      <div class="post-intro" itemprop="text">
        <div class="intro-inner">
          <?php 
        the_content();
        ?>
        </div>
      </div>

      <?php 
        if (fwe_theme_option_exists('hire_us_form_id')) {
            ?>
        <div id="hire-form" class="post-content">
          <?php 
            $form = GFAPI::get_form($fwe_settings['hire_us_form_id']);
            $fields = $form['fields'];
            ?>
          <form action="<?php 
            echo site_url('/wp-json/fwe/hire-us');
            ?>
" method="post">
            <p>
              Hi, <label for="hire-name">my name is</label> <?php 
            fwe_gform_input($fields[0], array('class' => 'madlib', 'id' => 'hire-name'));
            ?>
, and <label for="hire-company">I work at</label> <?php 
<?php

global $fwe_settings;
if (fwe_theme_option_exists('where_weve_been_intro') && !empty($fwe_settings['where_weve_been_intro'])) {
    ?>
  <div class="archive-intro">
    <?php 
    echo apply_filters('the_content', $fwe_settings['where_weve_been_intro']);
    ?>
  </div>
<?php 
}