Пример #1
0
  static function settings() {

    $team_settings = TeamSettings::sharedInstance();

    if(isset($_GET['delete-template'])) {
      $team_settings->deleteCustomTemplate($_GET['delete-template']);
    }

    if (isset($_POST['team_templates']['slug'])) {
      $team_settings->updateDefaultTeamTemplateSlug($_POST['team_templates']['slug']);
      $did_update_options = true;
    }

    if (isset($_POST['custom_team_templates'])) {
      $team_settings->updateCustomTeamTemplates($_POST['custom_team_templates']);
      $did_update_options = true;
    }

    if (isset($_POST['team_meta_fields_labels'])) {
      $team_settings->updateCustomTeamMetaFields($_POST['team_meta_fields_labels'], $_POST['team_meta_fields_types']);
      $did_update_options = true;
    }

    $current_template = $team_settings->getCurrentDefaultTeamTemplate();
    $custom_templates = $team_settings->getCustomTeamTemplates();

    require_once(plugin_dir_path(__FILE__) . '../views/admin_settings.php');
  }
Пример #2
0
  public static function setupDefaults() {
    $team_settings = TeamSettings::sharedInstance();

    $current_template_slug = $team_settings->getCurrentDefaultTeamTemplate();
    if($current_template_slug == '' || $current_template_slug == NULL) {
      
      $team_settings->updateDefaultTeamTemplateSlug('list');

    } else if ($current_template_slug == 'custom' || get_option('our_team_html_template', '') != '') {

      $templates_array = array();
      $templates_array[] = array(
        'html' => get_option('our_team_html_template'),
        'css' => get_option('our_team_css_template')
      );
      $team_settings->updateCustomTeamTemplates($templates_array);
      $team_settings->updateDefaultTeamTemplateSlug('custom_1');

      delete_option('our_team_html_template');
      delete_option('our_team_css_template');
      
    }
  }
Пример #3
0
    static function team_meta_box_output($post) {

        wp_nonce_field('team_meta_box_nonce_action', 'team_meta_box_nonce');

        $team_settings = TeamSettings::sharedInstance();
        ?>

        <style type="text/css">
            label.team-label {
                float: left;
                line-height: 27px;
                width: 130px;
            }
        </style>

        <?php foreach ($team_settings->getTeamDetailsFields() as $field): ?>
            <p>
                <label for="team[<?php echo $field['slug'] ?>]" class="team-label"><?php _e($field['name']); ?>:</label>
                <?php if ($field['type'] == 'text'): ?>
                    <input type="text" name="team_meta[<?php echo $field['slug'] ?>]" value="<?php echo get_post_meta($post->ID, $field['slug'], true); ?>" />
                <?php elseif ($field['type'] == 'textarea'): ?>
                    <textarea cols=40 rows=5 name="team_meta[<?php echo $field['slug'] ?>]"><?php echo get_post_meta($post->ID, $field['slug'], true); ?></textarea>
                <?php endif; ?>
            </p>
        <?php endforeach; ?>

        <?php
    }
Пример #4
0
<?php

  $team_settings = TeamSettings::sharedInstance();

?>

<style type="text/css">
  #team-categories-wrapper,
  #team-order-wrapper,
  #team-template-wrapper {
    margin: 20px 0px;
  }
</style>

<div id="team-categories-wrapper">
  <label for="team-category">Team Category</label>
  <select name="team-category">
    <option value=''>-- Select Category --</option>
    <?php foreach(get_terms('team_category') as $cat): ?>
      <option value="<?php echo $cat->term_id; ?>"><?php echo $cat->name; ?></option>
    <?php endforeach; ?>
  </select>
</div>

<div id="team-order-wrapper">
  <label for="team-order">Team Order</label>
  <select name="team-order">
    <option value=''>-- Use Default --</option>
    <option value="asc">Ascending</option>
    <option value="desc">Descending</option>
  </select>
Пример #5
0
  static function html_for_custom_template($template_slug, $wp_query) {
    $team_settings = TeamSettings::sharedInstance();

    $output = '';

    $template = $team_settings->getCustomTeamTemplateForSlug($template_slug);
    $template_html = stripslashes($template['html']);
  	$template_css = stripslashes($template['css']);

  	$output .= "<style type=\"text/css\">$template_css</style>";

    if(strpos($template_html, '[team_loop]')) {
      $before_loop_markup = substr($template_html, 0, strpos($template_html, "[team_loop]"));
      $after_loop_markup = substr($template_html, strpos($template_html, "[/team_loop]") + strlen("[/team_loop]"), strlen($template_html) - strpos($template_html, "[/team_loop]"));
      $loop_markup = str_replace("[team_loop]", "", substr($template_html, strpos($template_html, "[team_loop]"), strpos($template_html, "[/team_loop]") - strpos($template_html, "[team_loop]")));
      $output .= $before_loop_markup;
    } else {
      $loop_markup = $template_html;
    }

    while($wp_query->have_posts()) {
      $wp_query->the_post();

      $team_name = get_the_title();
      if (has_post_thumbnail()) {
        $attachment_array = wp_get_attachment_image_src(get_post_thumbnail_id());
        $photo_url = $attachment_array[0];
        $photo_tag = '<img src="' . $photo_url . '" />';
      } else {
        $photo_url = "";
        $photo_tag = "";
      }

      $team_email = get_post_meta(get_the_ID(), 'email', true);
      $team_email_link = $team_email != '' ? "<a href=\"mailto:$team_email\">Email $team_name</a>" : "";
      $team_phone_number = get_post_meta(get_the_ID(), 'phone_number', true);
      $team_bio = get_the_content();
      $team_website = get_post_meta(get_the_ID(), 'website', true);
      $team_website_link = $team_website != '' ? "<a href=\"$team_website\" target=\"_blank\">View website</a>" : "";

      $team_categories = wp_get_post_terms(get_the_ID(), 'team_category');
      if (count($team_categories) > 0) {
        $team_category = $team_categories[0]->name;
      } else {
        $team_category = "";
      }

      $accepted_single_tags = array("[name]", "[photo_url]", "[bio]", "[category]");
  		$replace_single_values = array($team_name, $photo_url, $team_bio, $team_category);

  		$accepted_formatted_tags = array("[name_header]", "[photo]", "[email_link]", "[bio_paragraph]", "[website_link]");
  		$replace_formatted_values = array("<h3>$team_name</h3>", $photo_tag, $team_email_link, "<p>$team_bio</p>", $team_website_link);

  		$current_team_markup = str_replace($accepted_single_tags, $replace_single_values, $loop_markup);
  		$current_team_markup = str_replace($accepted_formatted_tags, $replace_formatted_values, $current_team_markup);

      preg_match_all("/\[(.*?)\]/", $current_team_markup, $other_matches);
      $team_meta_fields = get_option('team_meta_fields');

      if($team_meta_fields != '' && count($other_matches[0]) > 0) {
        foreach($other_matches[0] as $match) {
          foreach($team_meta_fields as $field) {
            $meta_key = $field['slug'];
            $shortcode_without_brackets = substr($match, 1, strlen($match) - 2);
            if($meta_key == $shortcode_without_brackets) {
              $meta_value = get_post_meta(get_the_ID(), $meta_key, true);
              $current_team_markup = str_replace($match, $meta_value, $current_team_markup);
            }
          }
        }
      }

  		$output .= $current_team_markup;
    }

    if(isset($after_loop_markup)) {
      $output .= $after_loop_markup;
    }

    return $output;
  }