Пример #1
0
function get_primary_category($post, $without = array('featured', 'hp_lead', 'sponsored'))
{
    $primary_category_data = simple_fields_value('primary_category', $post);
    if ($primary_category_data && $primary_category_data['selected_value']) {
        $primary_category = get_term_by('name', $primary_category_data['selected_value'], 'category');
    } else {
        $primary_category = get_post_categories($post, $without, 1);
    }
    return $primary_category;
}
Пример #2
0
                    ?>
</a></h3> <?php 
                }
            }
            if (has_post_thumbnail() || $post_embed_video_yt != '' || $post_embed_video_vm != '') {
                if ($img_position == 'inside' || $row_position == 'center') {
                    if ($row_position == 'center') {
                        $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(720, 205), true);
                        $srcf = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', true);
                    } else {
                        if ($img_position == 'inside') {
                            $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(720, 405), true);
                            $srcf = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', true);
                        }
                    }
                    $field_value = simple_fields_value("status_field");
                    if ($field_value != '') {
                        if ($field_value == 'dropdown_num_2') {
                            ?>
													<div class="badge abandoned <?php 
                            if ($row_position == 'center') {
                                ?>
badge-top-padding<?php 
                            }
                            ?>
"></div><?php 
                        } else {
                            if ($field_value == 'dropdown_num_3') {
                                ?>
													<div class="badge stealth-mode <?php 
                                if ($row_position == 'center') {
 function testManuallyAddedFieldsExtendedReturn()
 {
     $post_id = 11;
     // test single/first values
     $vals = simple_fields_value("field_radiobuttons", $post_id, "extended_return=1");
     $vals_expected = array("selected_value" => "Radiobutton 3", "selected_radiobutton" => array("value" => "Radiobutton 3", "key" => "radiobutton_num_4", "is_selected" => 1), "radiobuttons" => array(array("value" => "Radiobutton 1", "key" => "radiobutton_num_2", "is_selected" => ""), array("value" => "Radiobutton 2", "key" => "radiobutton_num_3", "is_selected" => ""), array("value" => "Radiobutton 3", "key" => "radiobutton_num_4", "is_selected" => 1)));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_dropdown", $post_id, "extended_return=1");
     $vals_expected = array('selected_value' => 'Dropdown 2', 'selected_option' => array('value' => 'Dropdown 2', 'key' => 'dropdown_num_3', 'is_selected' => true), 'options' => array(0 => array('value' => 'Dropdown 1', 'key' => 'dropdown_num_2', 'is_selected' => false), 1 => array('value' => 'Dropdown 2', 'key' => 'dropdown_num_3', 'is_selected' => true), 2 => array('value' => 'Dropdown 3', 'key' => 'dropdown_num_4', 'is_selected' => false)));
     $this->assertEquals($vals_expected, $vals);
     // check just keys for now, should check more of course
     $vals = simple_fields_value("field_file", $post_id, "extended_return=1");
     #echo var_export($vals);
     $attachment_id = 14;
     $vals_expected = array('id' => 14, 'is_image' => true, 'url' => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 'mime' => 'image/jpeg', 'link' => array('full' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="1024" height="768" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-full" alt="product-cat-2" title="product-cat-2" /></a>', 'thumbnail' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="150" height="112" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-thumbnail" alt="product-cat-2" title="product-cat-2" /></a>', 'medium' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="300" height="225" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-medium" alt="product-cat-2" title="product-cat-2" /></a>', 'large' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="584" height="438" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-large" alt="product-cat-2" title="product-cat-2" /></a>', 'post-thumbnail' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="384" height="288" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-post-thumbnail" alt="product-cat-2" title="product-cat-2" /></a>', 'large-feature' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="384" height="288" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-large-feature" alt="product-cat-2" title="product-cat-2" /></a>', 'small-feature' => '<a href=\'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg\' title=\'product-cat-2\'><img width="400" height="300" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-small-feature" alt="product-cat-2" title="product-cat-2" /></a>'), 'image' => array('full' => '<img width="1024" height="768" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-full" alt="product-cat-2" title="product-cat-2" />', 'thumbnail' => '<img width="150" height="112" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-thumbnail" alt="product-cat-2" title="product-cat-2" />', 'medium' => '<img width="300" height="225" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-medium" alt="product-cat-2" title="product-cat-2" />', 'large' => '<img width="584" height="438" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-large" alt="product-cat-2" title="product-cat-2" />', 'post-thumbnail' => '<img width="384" height="288" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-post-thumbnail" alt="product-cat-2" title="product-cat-2" />', 'large-feature' => '<img width="384" height="288" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-large-feature" alt="product-cat-2" title="product-cat-2" />', 'small-feature' => '<img width="400" height="300" src="http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg" class="attachment-small-feature" alt="product-cat-2" title="product-cat-2" />'), 'image_src' => array('full' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 1024, 2 => 768, 3 => false), 'thumbnail' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 150, 2 => 112, 3 => false), 'medium' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 300, 2 => 225, 3 => false), 'large' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 584, 2 => 438, 3 => false), 'post-thumbnail' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 384, 2 => 288, 3 => false), 'large-feature' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 384, 2 => 288, 3 => false), 'small-feature' => array(0 => 'http://unit-test.simple-fields.com/wp/wp-content/uploads/2012/10/product-cat-2.jpeg', 1 => 400, 2 => 300, 3 => false)), 'metadata' => array('width' => '1024', 'height' => '768', 'hwstring_small' => 'height=\'96\' width=\'128\'', 'file' => '2012/10/product-cat-2.jpeg', 'image_meta' => array('aperture' => '0', 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => '0', 'copyright' => '', 'focal_length' => '0', 'iso' => '0', 'shutter_speed' => '0', 'title' => '')), 'post' => get_post($attachment_id));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_post", $post_id, "extended_return=1");
     $vals_expected = array('id' => 11, 'title' => 'Post with fields', 'permalink' => 'http://unit-test.simple-fields.com/?p=11', 'post' => get_post($post_id));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_taxonomy", $post_id, "extended_return=1");
     $vals_expected = array('name' => 'post_tag', 'singular_name' => 'Tag', 'plural_name' => 'Tags', "taxonomy" => get_taxonomy("post_tag"));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_taxonomy_term", $post_id, "extended_return=1");
     $vals_expected = array("terms" => array(0 => array("name" => "Uncategorized", "slug" => "uncategorized", "id" => 1, "term" => get_term_by("id", 1, "category"))));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_date", $post_id, "extended_return=1");
     $vals_expected = array('saved_value' => '12/10/2012', 'timestamp' => 1350000000, 'date_format' => 'October 12, 2012', 'date_format_i18n' => 'October 12, 2012');
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_user", $post_id, "extended_return=1");
     $vals_expected = array('id' => 1, 'first_name' => '', 'last_name' => '', 'user_login' => 'admin', 'user_email' => '*****@*****.**', 'user_nicename' => 'admin', 'display_name' => 'admin', 'user' => get_user_by("id", 1));
     $this->assertEquals($vals_expected, $vals);
 }
Пример #4
0
					</ul>

			</div>
		</div>
	</div>


</div>
<div id="front-hero-3" role="banner">
	<div class = "row">
	<?php 
$description_title = simple_fields_value("desc_title");
?>
	<?php 
$description_content = simple_fields_value("desc_content");
?>

		<div class="medium-8 columns">
			<h4 id="section-title"><b><?php 
echo $description_title;
?>
</b></h4>
			<div class = "about-game-bg-bg">
			<div class = "about-game-bg">
						<?php 
echo $description_content;
?>
			</div>
		</div>
		</div>
Пример #5
0
if (have_posts()) {
    ?>

			<div id="home-slider-wrapper" class="slider-wrapper">
			<div id="home-slider" class="slider">
			<?php 
    // Start the loop.
    while (have_posts()) {
        the_post();
        echo "<div><a href=" . esc_url(get_permalink()) . ">";
        the_post_thumbnail('post-thumbnail');
        echo "</a>";
        $title = simple_fields_value('title') ? simple_fields_value('title') : get_the_title();
        $excerpt = str_replace("\n", '<br>', get_the_excerpt());
        $bg = simple_fields_value('color') ? simple_fields_value('color') : '1B9B82';
        $color = simple_fields_value('text_color') ? simple_fields_value('text_color') : 'FFFFFF';
        echo "<a href=" . esc_url(get_permalink()) . " class='hover-content' style='background: #" . $bg . "; color: #" . $color . "'><div class='hover-content-inner'><h2>" . $title . "<span class='delimiter' style='background: #" . $color . "'></span></h2><p>" . $excerpt . "</p></div></a>";
        echo "</div>\n";
        /*
         * Include the Post-Format-specific template for the content.
         * If you want to override this in a child theme, then include a file
         * called content-___.php (where ___ is the Post Format name) and that will be used instead.
         */
        // get_template_part( 'content', get_post_format() );
        // End the loop.
    }
    ?>
			</div><!-- #home-slider -->
			<button id="slick-prev-button" type="button" class="slick-prev slick-arrow" aria-label="Previous" role="button"></button>
			<button id="slick-next-button" type="button" class="slick-next slick-arrow" aria-label="Next" role="button"></button>
			</div><!-- #home-slider-wrapper -->
    /** 
     * Outputs the names of the post connectors attached to the post you view + outputs the values
     */
    function simple_fields_content_debug_output($the_content)
    {
        // we only want to appen the debug code when being used from get_the_content or the_content
        // but for example get_the_excerpt is also using filter the_content which leads to problems
        // so check that we are somewhere inside the right functions
        $is_inside_righ_function = FALSE;
        $arr_trace = debug_backtrace();
        $arr_trace_count = count($arr_trace);
        for ($i = 0; $i < $arr_trace_count; $i++) {
            if (isset($arr_trace[$i]["function"]) && in_array($arr_trace[$i]["function"], array("the_content", "get_the_content"))) {
                $is_inside_righ_function = TRUE;
                break;
            }
        }
        if (!$is_inside_righ_function) {
            // Don't do the debug, since we're not in the_content
            return $the_content;
        }
        $output = "";
        $output_all = "";
        $field_count = 0;
        $post_connector_with_values = simple_fields_get_all_fields_and_values_for_post(get_the_ID(), "include_deleted=0");
        if ($post_connector_with_values) {
            foreach ($post_connector_with_values["field_groups"] as $one_field_group) {
                if ($one_field_group["deleted"]) {
                    continue;
                }
                $output_all .= "<div style='font-weight:bold;margin:1em 0 0 0;'>";
                $str_is_repeatable = $one_field_group["repeatable"] ? __(" (Repeatable)", "simple-fields") : "";
                $output_all .= sprintf(__('Fieldgroup %1$s %2$s', "simple-fields"), $one_field_group["name"], $str_is_repeatable);
                $output_all .= "</div>";
                $str_all_group_fields = "";
                foreach ($one_field_group["fields"] as $one_field) {
                    if ($one_field["deleted"]) {
                        continue;
                    }
                    $field_count++;
                    $content = "";
                    $content .= "<ul style='background:#eee;padding:.5em;margin:0;display:block;'>";
                    $content .= "<li>Field <b>" . $one_field["name"] . "</b>";
                    $content .= ", type <b>" . $one_field["type"] . "</b>";
                    if (isset($one_field["slug"])) {
                        $content .= ", slug <b>" . $one_field["slug"] . "</b>";
                        $str_all_group_fields .= $one_field["slug"] . ",";
                        if ($one_field_group["repeatable"]) {
                            $content .= "<br>Use <code><b>simple_fields_values('" . $one_field["slug"] . "')</b></code> to get:";
                            ob_start();
                            sf_d(simple_fields_values($one_field["slug"]));
                            $content .= ob_get_clean();
                        } else {
                            $content .= "<br>Use <code><b>simple_fields_value('" . $one_field["slug"] . "')</b></code> to get:";
                            ob_start();
                            sf_d(simple_fields_value($one_field["slug"]));
                            $content .= ob_get_clean();
                        }
                    } else {
                        $content .= "<br>No slug for this field found (probably old field that has not been edited and saved).";
                    }
                    $content .= "</ul>";
                    $output_all .= $content;
                }
                // Show example how to get all fields in one shot
                // But only show if field has more than one field, otherwise it's kinda not useful
                if (sizeof($one_field_group["fields"]) > 1) {
                    $str_all_group_fields = preg_replace('!,$!', '', $str_all_group_fields);
                    $output_all .= "<ul style='background:#eee;padding:.5em;margin:0;display:block;'>";
                    if ($one_field_group["repeatable"]) {
                        $content = "<li>Get all fields at once: use <code><b>simple_fields_values('" . $str_all_group_fields . "')</b></code> to get:";
                        ob_start();
                        sf_d(simple_fields_values($str_all_group_fields));
                        $content .= ob_get_clean();
                    } else {
                        $content = "<li>Get all fields at once: use <code><b>simple_fields_value('" . $str_all_group_fields . "')</b></code> to get:";
                        ob_start();
                        sf_d(simple_fields_value($str_all_group_fields));
                        $content .= ob_get_clean();
                    }
                    $output_all .= $content;
                    $output_all .= "</ul>";
                }
            }
            // for each field group
        }
        if ($output_all) {
            $str_show_fields = __("Show fields.", "simple-fields");
            $str_hide_fields = __("Hide fields.", "simple-fields");
            ?>
			<script>
			window.simple_fields_post_debug_show_hide = window.simple_fields_post_debug_show_hide || function(t) {
				var $t = jQuery(t);
				var $div_wrap = $t.closest("div.simple-fields-post-debug-wrap");
				var debug_content = $div_wrap.find("div.simple-fields-post-debug-content");
				debug_content.toggle();
				if (debug_content.is(":visible")) {
					$t.text("<?php 
            echo $str_hide_fields;
            ?>
");
				} else {
					$t.text("<?php 
            echo $str_show_fields;
            ?>
");
				}
				return false;
			}
			</script>
			<?php 
            $output_all = '
				<div class="simple-fields-post-debug-wrap" style="display:block;margin:0;padding:0;">
					<p style="margin:0;padding:0;display:block;">This post has ' . $field_count . ' Simple Fields-fields attached. <a href="#" onclick="return simple_fields_post_debug_show_hide(this);">' . $str_show_fields . '</a></p>
					<div class="simple-fields-post-debug-content" style="display:none;">' . $output_all . '</div>
				</div>
				';
        }
        // if a field has the slug caption the output will be [caption] and then it will crash with some shortcodes, so we try to fix that here
        $output_all = str_replace("[", "&#91;", $output_all);
        $output_all = str_replace("]", "&#93;", $output_all);
        return $the_content . $output_all;
    }
Пример #7
0
				<a href="http://www.evocreo.com" title="EvoCreo"><img src=<?php 
echo get_stylesheet_directory_uri();
?>
/assets/images/ilmfinity/EvoCreoTitle.png></a></h1>
			</div>
			<div class="marketing">

				<div class="tagline">
					<?php 
$featured_text = simple_fields_value("featured_text");
?>
					<?php 
$contact_text = simple_fields_value("contact_us_text");
?>
					<?php 
$contact_button = simple_fields_value("contact_button_text");
?>

					<h4 class="subheader"><b><?php 
echo $featured_text;
?>
</b></h4>
					<a role="button" class="download large button show-for-small-up" href="http://evocreo.com/"><b>Learn More!</b></a>
					<div class="row">
						<a href="https://play.google.com/store/apps/details?id=ilmfinity.evocreo.main.android&hl=ens">	<img class="appStore"  src=<?php 
echo get_stylesheet_directory_uri();
?>
/assets/images/ilmfinity/android-app-on-google-play.jpg></a>
						<a href="https://itunes.apple.com/us/app/evocreo-a-monster-capture-rpg/id918997182?mt=8">	<img class="appStore" src=<?php 
echo get_stylesheet_directory_uri();
?>
Пример #8
0
				<?php 
// Field slug is "fileExample"
$file_id = simple_fields_value('main_image');
$image_info = wp_get_attachment_image_src($file_id, "full");
$image_main_url = $image_info[0];
$image_width = $image_info[1];
$image_height = $image_info[2];
?>
			<img src="<?php 
echo $image_main_url;
?>
">
			</div><!-- end #main -->
		</div><!-- end #content-sidebar-wrap -->
	</div><!-- end #content -->
<!-- END MAIN CONTENT -->

<!-- BEGIN BOTTOM WRAPPER -->	
	<div id="bottom_wrapper">
		<div id="bottom_wrapper_content">
		<?php 
$main_content = simple_fields_value("testimonial_content");
echo $main_content;
?>
		</div>
	</div>
<!-- END BOTTOM WRAPPER -->

	<?php 
do_action('genesis_after_content_sidebar_wrap');
get_footer();
Пример #9
0
<?php

$country_code = get_geoIP();
$keywords = simple_fields_value('keywords');
$keyword_arr = explode(',', $keywords);
$key_index = 0;
if (count($keyword_arr) > 1) {
    $key_index = array_rand($keyword_arr, 1);
}
$filter_key = trim(strip_tags($keyword_arr[$key_index]));
$filter_key = strtolower($filter_key);
$filter_key = keyword_dictionary($filter_key);
$filter_key = str_replace(' ', '-', $filter_key);
$custom_keyword = $filter_key;
switch ($country_code) {
    case 'PH':
        $widget_url = "http://tripzilla.ph/widgets/tp_feed/" . $custom_keyword;
        break;
    case 'MY':
        $widget_url = "http://tripzilla.my/widgets/tp_feed/" . $custom_keyword;
        break;
    default:
        $widget_url = "http://tripzilla.sg/widgets/tp_feed_new/" . $custom_keyword;
        break;
}
?>

<div class="sidebar-widget row type-1">
	<div class="inner">
		<div class="widget-title" style="margin-bottom:20px !important;"><h4>TOUR PACKAGES</h4></div>
		<iframe src="<?php 
    ?>
" title="<?php 
    the_title_attribute();
    ?>
"><?php 
    the_title();
    ?>
</a></h2>
    <p><?php 
    echo GeoMashup::location_info();
    ?>
</p>

    <?php 
    $website = simple_fields_value("website");
    $email = simple_fields_value("email");
    if (!empty($website)) {
        ?>
      <p><?php 
        echo link_to('Sito Internet', $website);
        ?>
</p>
    <?php 
    }
    if (!empty($email)) {
        ?>
      <p><?php 
        echo link_to('Indirizzo Email', 'mailto:' . $email);
        ?>
</p>
    <?php 
 function testManuallyAddedFieldsExtendedReturn()
 {
     $this->insertDataForManualAddedFields();
     $post_id = self::$post_id_for_manual_tests;
     // test single/first values
     $vals = simple_fields_value("field_radiobuttons", $post_id, "extended_return=1");
     $vals_expected = array("selected_value" => "Radiobutton 3", "selected_radiobutton" => array("value" => "Radiobutton 3", "key" => "radiobutton_num_4", "is_selected" => 1), "radiobuttons" => array(array("value" => "Radiobutton 1", "key" => "radiobutton_num_2", "is_selected" => ""), array("value" => "Radiobutton 2", "key" => "radiobutton_num_3", "is_selected" => ""), array("value" => "Radiobutton 3", "key" => "radiobutton_num_4", "is_selected" => 1)));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_dropdown", $post_id, "extended_return=1");
     $vals_expected = array('selected_value' => 'Dropdown 2', 'selected_option' => array('value' => 'Dropdown 2', 'key' => 'dropdown_num_3', 'is_selected' => true), 'options' => array(0 => array('value' => 'Dropdown 1', 'key' => 'dropdown_num_2', 'is_selected' => false), 1 => array('value' => 'Dropdown 2', 'key' => 'dropdown_num_3', 'is_selected' => true), 2 => array('value' => 'Dropdown 3', 'key' => 'dropdown_num_4', 'is_selected' => false)));
     $this->assertEquals($vals_expected, $vals);
     // check just keys for now, should check more of course
     $vals = simple_fields_value("field_file", $post_id, "extended_return=1");
     #echo var_export($vals);
     $attachment_id = 14;
     $vals_expected = array('id' => 14, 'is_image' => false, 'url' => false, 'mime' => false, 'link' => array('full' => 'Missing Attachment', 'thumbnail' => 'Missing Attachment', 'medium' => 'Missing Attachment', 'large' => 'Missing Attachment', 'post-thumbnail' => 'Missing Attachment'), 'image' => array('full' => '', 'thumbnail' => '', 'medium' => '', 'large' => '', 'post-thumbnail' => ''), 'image_src' => array('full' => false, 'thumbnail' => false, 'medium' => false, 'large' => false, 'post-thumbnail' => false), 'metadata' => false, "post" => null);
     #var_dump($vals);
     // Test file field with file that does not exist
     // Expect empty array
     $vals_expected = array();
     $this->assertEquals($vals_expected, $vals);
     // test with a real attachment
     // @todo: how to test attachments?
     // Upload attachment. code from
     // https://github.com/kurtpayne/wordpress-unit-tests/blob/master/tests/post/attachments.php#L19
     $base_64_image = "R0lGODdhAAQAA+MAAMzMzJaWlre3t5ycnMXFxbGxsaOjo76+vqqqqgAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAQAAwAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS09TV1tfY2drb3N3e3+Dh4uPk5ebn6Onq6+zt7u/w8fLz9PX29/j5+vv8/f7/AAMKHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8eP/iBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bNmzhz6tzJs6fPn0CDCh1KtKjRo0iTKl3KtKnTp1CjSp1KtarVq1izat3KtavXr2DDih1LtqzZs2jTql3Ltq3bt3Djyp1Lt67du3jz6t3Lt6/fv4ADCx5MuLDhw4gTK17MuLHjx5AjS55MubLly5gza97MubPnz6BDix5NurTp06hTq17NurXr17Bjy55Nu7bt27hz697Nu7fv38CDCx9OvLjx48iTK1/OvLnz59CjS59Ovbr169iza9/Ovbv37+DDix9Pvrz58+jTq1/Pvr379/Djy59Pv779+/jz69/Pv7///wAG/ijggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDTWaOONOOao44489ujjj0AGKeSQRBZp5JFIJqnkkkw26eSTUEYp5ZRUVmnllVhmqeWWXHbp5ZdghinmmGSWaeaZaKap5ppstunmm3DGKeecdNZp55145qnnnnz26eefgAYq6KCEFmrooYgmquiijDbq6KOQRirppJRWaumlmGaq6aacdurpp6CGKuqopJZq6qmopqrqqqy26uqrsMYq66y01mrrrbjmquuuvPbq66/ABivssMQWa+yxyCar7LLM/jbr7LPQRivttNRWa+212Gar7bbcduvtt+CGK+645JZr7rnopqvuuuy26+678MYr77z01mvvvfjmq+++/Pbr778AByzwwAQXbPDBCCes8MIMN+zwwxBHLPHEFFds8cUYZ6zxxhx37PHHIIcs8sgkl2zyySinrPLKLLfs8sswxyzzzDTXbPPNOOes88489+zzz0AHLfTQRBdt9NFIJ6300kw37ZQAAwQg9dRUV2311VhnXfUAAjjNSdRahy322Ft7vQnZaKedtdmaqO3222xn8vbcaMeNCd14h233JXn3ffXelvgt+NSAVzL44IVTcrjgiU+yuN+NS/J435FHMnne/pVDcjnemT+yOd2dO/L53KE3MjrcpS9yutupLwL26mMP0LoiUMMuNtez80157qRAzvsovv8eSvDCf0J88Z0cj/zZuy+ffPPOM4959JwoT33g0F+v+/Ta351994p/D77k4o+vefnmi45++oxYz77p67+fiPvyK0L/FAQUYEDUAwxgQAECIIAMDoAAsPnvfwfQAgEEUAAE7O91/TMAAgAowCwssIEGeKDU/FeABIrhgg7s39YyCEAPaul+JKgd3SoYAgEYIGwGMOEKCvA6rCGAhVEQQAHVNgAEyPAJC3wh2nz4gQMI4IhITKISBfBDG+RPiG77Hw6phEIRCKBvCAjB/gFqGLYBNJEEBUjbDZ9AwL4NoABPcCHdcLcBBLgti06koeAM0LUqVTEEXJzbFDNAACiKcY8gUKHa6qgEQfrtjEsw5BoJeQHS0YAAbnwcIqd0RxAIDo0ciOTcBgBIDvQRbwboJBAO4MfDefEIpFzcKRuJuhhAcnRshFIlPyA42Wlgi377ogbCaEZR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FmLQN3/Dg+vdY6sMCTU9Zw7VXRJc91DQOi7KF5vQR7Xax93QRtLU2B/QSLXJ6FDQWHnTZqndjeRYd47dgzMNiTLNlUMNabw7WWnUZ/vUFSvdk7UF+bQ5agvQXNbErPXNpfQEBT+riRrdpGAEIPVEP6JUEl9Nqwndu6vdu83du+/dvAHdzCPdzEXdzGfdzIndzKvdzM3dzO/dzQHd3SPd3UXd3Wfd3Ynd3avd3c3d3e/d3gHd7iPd7kXd7mfd7ond7q/r3e7N3e7v3e8B3f8j3f9F3f9n3f+J3f+r3f/N3f/v3fAB7gAj7gBF7gBn7gCJ7gCr7gDN7gDv7gEB7hEj7hFF7hFn7hGJ7hGr7hHN7hHv7hIB7iIj7iJF7iJn7iKJ7iKr7iLN7iLv7iMB7jMj7jNF7jNn7jOJ7jOr7jPN7jPv7jQB7kQj7kRF7kRn7kSJ7kSr7kTN7kTv7kUB7lUj7lVF7lVn7lWJ7lWr7lXN7lXv7lYB7mYj7mZF7mZn7maJ7mar7mbN7mbv7mcB7ncj7ndF7ndn7neJ7ner7nfN7nfv7ngB7ogj7ohF7ohn7oiJ7oir7ojN7ojv7okB7pkj7pIZRe6ZZ+6Zie6Zq+6Zze6Z7+6aAe6qI+6qRe6qZ+6p0eAQA7";
     $upload = wp_upload_bits("testimage_1.gif", null, base64_decode($base_64_image));
     $type = '';
     if (!empty($upload['type'])) {
         $type = $upload['type'];
     } else {
         $mime = wp_check_filetype($upload['file']);
         if ($mime) {
             $type = $mime['type'];
         }
     }
     $attachment = array('post_title' => basename($upload['file']), 'post_content' => '', 'post_type' => 'attachment', 'post_parent' => $parent_post_id, 'post_mime_type' => $type, 'guid' => $upload['url']);
     // Save the data
     $id = wp_insert_attachment($attachment, $upload['file'], $parent_post_id);
     wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file']));
     // file is uploaded, add it to post/simple fields-fields
     simple_fields_set_value($post_id, "field_file", 0, null, $id);
     // get field that was added just now
     // big array is returned, but at least check the basics
     $vals_returned = simple_fields_value("field_file", $post_id, "extended_return=1");
     $this->assertArrayHasKey('id', $vals_returned);
     $this->assertEquals($vals_returned["id"], $id);
     $this->assertArrayHasKey('is_image', $vals_returned);
     $this->assertEquals($vals_returned["is_image"], true);
     $this->assertArrayHasKey('mime', $vals_returned);
     $this->assertEquals($vals_returned["mime"], "image/gif");
     $this->assertArrayHasKey('link', $vals_returned);
     $this->assertNotEmpty($vals_returned["link"]);
     $this->assertArrayHasKey('url', $vals_returned);
     $this->assertNotEmpty($vals_returned["url"]);
     $this->assertArrayHasKey('image', $vals_returned);
     $this->assertNotEmpty($vals_returned["image"]);
     $this->assertArrayHasKey('image_src', $vals_returned);
     $this->assertNotEmpty($vals_returned["image_src"]);
     $this->assertArrayHasKey('metadata', $vals_returned);
     $this->assertNotEmpty($vals_returned["metadata"]);
     $this->assertArrayHasKey('post', $vals_returned);
     $this->assertNotEmpty($vals_returned["post"]);
     $vals = simple_fields_value("field_post", $post_id, "extended_return=1");
     $vals_expected = array('id' => $post_id, 'title' => 'Post with fields', 'permalink' => get_permalink($post_id), 'post' => get_post($post_id));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_taxonomy", $post_id, "extended_return=1");
     $vals_expected = array('name' => 'post_tag', 'singular_name' => 'Tag', 'plural_name' => 'Tags', "taxonomy" => get_taxonomy("post_tag"));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_taxonomy_term", $post_id, "extended_return=1");
     $vals_expected = array("terms" => array(0 => array("name" => "Uncategorized", "slug" => "uncategorized", "id" => 1, "term" => get_term_by("id", 1, "category"))));
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_date", $post_id, "extended_return=1");
     $vals_expected = array('saved_value' => '12/10/2012', 'timestamp' => 1350000000, 'date_format' => 'October 12, 2012', 'date_format_i18n' => 'October 12, 2012');
     $this->assertEquals($vals_expected, $vals);
     $vals = simple_fields_value("field_user", $post_id, "extended_return=1");
     $vals_expected = array('id' => 1, 'first_name' => '', 'last_name' => '', 'user_login' => 'admin', 'user_email' => '*****@*****.**', 'user_nicename' => 'admin', 'display_name' => 'admin', 'user' => get_user_by("id", 1));
     $this->assertEquals($vals_expected, $vals);
 }
Пример #12
0
<?php

/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */
$title = simple_fields_value('title') ? simple_fields_value('title') : get_the_title();
$excerpt = str_replace("\n", '<br>', get_the_excerpt());
$bg = simple_fields_value('color') ? simple_fields_value('color') : '1B9B82';
$color = simple_fields_value('text_color') ? simple_fields_value('text_color') : 'FFFFFF';
$image = simple_fields_value('image');
?>

<div class="article-single">
	<div class="header" style="background: #<?php 
echo $bg;
?>
; color: #<?php 
echo $color;
?>
">
		<?php 
echo "<div class='hover-content' style='background: #" . $bg . "; color: #" . $color . "'><div class='hover-content-inner'><h2>" . $title . "<span class='delimiter' style='background: #" . $color . "'></span></h2><p>" . $excerpt . "</p></div></div>";
?>
	</div>
	<div class="content">
Пример #13
0
/**
 * Returns all the values in a field group
 * It's a shortcut to running simple_fields_value(slugs) with all slugs already entered
 * Depending if the field group is repeatable or not, simple_field_value or simple_fields_values will be used
 *
 * @param mixed $field_group_id_or_slug
 * @return mixed, but probably array, depending on how many field the group has (just one field, and not repeatable = no array for you!)
 */
function simple_fields_fieldgroup($field_group_id_or_slug, $post_id = NULL, $options = array())
{
    if (!is_numeric($post_id)) {
        global $post;
        $post_id = $post->ID;
    }
    global $sf;
    $cache_key = "simple_fields_" . $sf->ns_key . "_fieldgroup_" . $field_group_id_or_slug . "_" . $post_id . "_" . md5(json_encode($options));
    $values = wp_cache_get($cache_key, 'simple_fields');
    if (FALSE === $values) {
        $field_group = $sf->get_field_group_by_slug($field_group_id_or_slug);
        $arr_fields = array();
        foreach ($field_group["fields"] as $one_field) {
            if ($one_field["deleted"]) {
                continue;
            }
            // add field group to each field slug
            $arr_fields[] = trim($one_field["field_group"]["slug"]) . "/" . trim($one_field["slug"]);
        }
        $str_field_slugs = join(",", $arr_fields);
        if ($field_group["repeatable"]) {
            $values = simple_fields_values($str_field_slugs, $post_id);
        } else {
            $values = simple_fields_value($str_field_slugs, $post_id);
        }
        wp_cache_set($cache_key, $values, 'simple_fields');
    }
    $values = apply_filters("simple_fields_fieldgroup", $values, $field_group_id_or_slug, $post_id, $options);
    return $values;
}
Пример #14
0
			<div class="side-content">
					<div class="twitter-follow">
						<a class="twitter-follow-button"
						href="https://twitter.com/ilmfinity"
						data-size="small">
						Follow @Ilmfinity</a>
					</div>


				<div class="fb-like" data-href="https://www.facebook.com/ilmfinity/" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>
			</div>
			</div>

	</div>
	<?php 
$field_values = simple_fields_value("contact_us_text, contact_button_text");
?>
	<div class="row">
		<div class="contact-side">
			<h4 class="subheader">Contact Us</h4>
			<div class="side-content">
			<p>Have a question for us?</p>
			<a href="#" data-reveal-id="firstModal" class="radius small button">Send an Email!</a>

			<div id="firstModal" class="reveal-modal" data-reveal>
				<a class="close-reveal-modal" aria-label="Close">&#215;</a>
				<h2 id="form">Send a Message.</h2>
				<form>
					<fieldset>
						<legend>Message Details</legend>