コード例 #1
0
ファイル: taxonomy.php プロジェクト: wp-papi/papi
/**
 * Get property value from the database.
 *
 * @param  int    $term_id
 * @param  string $slug
 * @param  mixed  $default
 *
 * @return mixed
 */
function papi_get_term_field($term_id = null, $slug = null, $default = null)
{
    if (!is_numeric($term_id) && is_string($term_id)) {
        $default = $slug;
        $slug = $term_id;
        $term_id = null;
    }
    if (!is_string($slug) || empty($slug)) {
        return $default;
    }
    return papi_get_field(papi_get_term_id($term_id), $slug, $default, 'term');
}
コード例 #2
0
ファイル: papi.php プロジェクト: ekandreas/orasolv-intra
 static function render_modules($property_slug)
 {
     $relations = papi_get_field($property_slug);
     if ($relations) {
         foreach ($relations as $key => $relation) {
             $blade_template = rtrim(papi_get_page_type_template($relation->ID), '.php');
             $view = view($blade_template, ['module' => papi_get_page($relation->ID)]);
             $pathToCompiled = $view->path;
             include $pathToCompiled;
         }
     }
 }
コード例 #3
0
 /**
  * Update value.
  *
  * @param  Papi_Core_Property $property
  * @param  mixed  $value
  * @param  string $slug
  * @param  int    $post_id
  *
  * @return array
  */
 protected function update_value($property, $value, $slug, $post_id)
 {
     if (!is_array($value) || !$this->should_update_array($slug)) {
         return $property->import_value($value, $slug, $post_id);
     }
     $old = papi_get_field($post_id, $slug, []);
     $value = array_merge($old, $value);
     $value = $property->import_value($value, $slug, $post_id);
     if ($property->import_setting('property_array_slugs')) {
         return papi_from_property_array_slugs($value, $slug);
     }
     return $property->update_value($value, $slug, $post_id);
 }
コード例 #4
0
ファイル: class-papi-property.php プロジェクト: nlemoine/papi
 /**
  * Get value.
  *
  * @return mixed
  */
 public function get_value()
 {
     $value = $this->get_option('value');
     if (papi_is_empty($value)) {
         $type = papi_get_meta_type();
         $slug = $this->get_slug(true);
         $value = papi_get_field($slug, null, $type);
         $post_status = get_post_status($this->get_post_id());
         if (papi_is_empty($value) && ($post_status === false || $post_status === 'auto-draft')) {
             $value = $this->get_option('default');
         }
     }
     if (papi_is_empty($value)) {
         return $this->default_value;
     }
     if ($this->convert_type === 'string') {
         $value = papi_convert_to_string($value);
     }
     return papi_santize_data($value);
 }
コード例 #5
0
ファイル: sidebar.blade.php プロジェクト: lobbykit/intra
 * Try to get start page sidebar modules
 */
if (!sizeof($sidebar_modules)) {
    if ($frontpage_id = get_option('page_on_front')) {
        if ($frontpage_modules = papi_get_field($frontpage_id, 'sidebar')) {
            $sidebar_modules = $frontpage_modules;
        }
    }
}
?>

@if(sizeof($sidebar_modules))
	@foreach($sidebar_modules as $module)
        @if(Groups_Post_Access::user_can_read_post($module->ID))
            <?php 
if (papi_get_field($module->ID, 'anonymous_only') && is_user_logged_in()) {
    continue;
}
?>
    		<div class="row">
    			<?php 
$post = get_post($module->ID);
setup_postdata($GLOBALS['post'] =& $post);
bladerunner(rtrim(papi_get_page_type_template($module->ID), '.php'));
?>
                <p>&nbsp;</p>
    	    </div>
        @endif
	@endforeach
	<?php 
wp_reset_postdata();
コード例 #6
0
ファイル: class-papi-porter.php プロジェクト: wp-papi/papi
 /**
  * Export data from Papi. With or without all property options.
  *
  * @param  mixed $post_id
  * @param  bool  $only_values
  *
  * @return array
  */
 public function export($post_id, $only_values = false)
 {
     $post_id = papi_get_post_id($post_id);
     if (empty($post_id)) {
         return [];
     }
     $slugs = papi_get_slugs($post_id);
     foreach ($slugs as $key => $box) {
         foreach ($box as $index => $slug) {
             unset($slugs[$key][$index]);
             $value = papi_get_field($post_id, $slug, null);
             if ($only_values === true) {
                 $slugs[$key][$slug] = $value;
             } else {
                 $store = papi_get_meta_store($post_id);
                 // @codeCoverageIgnoreStart
                 if (is_null($store)) {
                     continue;
                 }
                 // @codeCoverageIgnoreEnd
                 $property = $store->get_property($slug);
                 // @codeCoverageIgnoreStart
                 if (!papi_is_property($property)) {
                     continue;
                 }
                 // @codeCoverageIgnoreEnd
                 $options = clone $property->get_options();
                 $options->value = $value;
                 $slugs[$key][$slug] = $options;
             }
         }
     }
     return $slugs;
 }
コード例 #7
0
          <div class="startpageheaderend">{!! $module->thirdliner !!}</div>
          <p class="startpageherop">{{ $module->sellpoint }}</p>
          <div class="w-row startpageherorow">
            <div class="w-col w-col-6 w-col-small-6 w-clearfix">
              <?php 
$link = papi_get_field($module->id, 'link1');
?>
              @if( $link )
                <a href="{{ $link->url }}" class="w-inline-block startpageherobtn1">
                  <div class="startpageherobtn1text">{{ $link->title }}</div>
                </a>
              @endif
            </div>
            <div class="w-col w-col-6 w-col-small-6">
              <?php 
$link = papi_get_field($module->id, 'link2');
?>
              @if( $link )
                <a href="{{ $link->url }}" class="w-inline-block startpageherobtn2">
                  <div class="startpageherobtn1text startpageherobtn2text">{{ $link->title }}</div>
                </a>
              @endif
            </div>
          </div>
        </div>
        <div data-ix="scrollfingerback" class="startpageherofingerdiv"></div>
      </div>
    </div>
  </div>
  @include('views.parts.pointers.blue_right')
コード例 #8
0
ファイル: product-card.php プロジェクト: ekandreas/nordiciron
<?php

$image_field = papi_get_field('image');
$image = null;
$image = isset($image_field->sizes['small']) ? $image_field->sizes['small']['url'] : $image;
$image = isset($image_field->sizes['medium']) ? $image_field->sizes['medium']['url'] : $image;
$image = isset($image_field->sizes['large']) ? $image_field->sizes['large']['url'] : $image;
?>

  <div class="card">
<a href="<?php 
the_permalink();
?>
">
    <div class="card-image">
      <img src="<?php 
echo $image;
?>
" alt="<?php 
echo get_the_title();
?>
">
    </div>
    <div class="card-header">
      <?php 
echo get_the_title();
?>
    </div>
    <div class="card-copy">
      <p>
      <?php 
コード例 #9
0
ファイル: article-page.php プロジェクト: rasmusbe/dev-theme
<?php

get_header();
while (have_posts()) {
    the_post();
    ?>

<div class="entry">
	<?php 
    the_title('<h1 class="entry-title">', '</h1>');
    ?>

	<?php 
    $hero = papi_get_field('hero_image');
    if ($hero) {
        ?>
			<div class="entry-hero">
				<img src="<?php 
        echo $hero->url;
        ?>
" />
			</div>
			<?php 
    }
    ?>

	<div class="entry-text">
		<?php 
    the_papi_field('editor');
    ?>
	</div>
コード例 #10
0
 /**
  * Restore to post revision.
  *
  * @param int $post_id
  * @param int $revision_id
  */
 public function restore_post_revision($post_id, $revision_id)
 {
     $slugs = papi_get_slugs($revision_id, true);
     foreach ($slugs as $slug) {
         $value = papi_get_field($revision_id, $slug);
         if (papi_is_empty($value)) {
             papi_delete_field($post_id, $slug);
         } else {
             papi_update_field($post_id, $slug, $value);
         }
     }
 }
コード例 #11
0
    /**
     * Render property html.
     */
    public function html()
    {
        $post_id = papi_get_post_id();
        $settings = $this->get_settings();
        // Create query array for every page type.
        $page_types = array_map(function ($page_type) {
            return ['key' => papi_get_page_type_key(), 'value' => $page_type, 'compare' => 'LIKE'];
        }, papi_to_array($settings->page_type));
        // Add relation.
        $page_types['relation'] = 'OR';
        // Prepare arguments for WP_Query.
        $args = ['post_type' => 'any', 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'meta_query' => $page_types];
        $query = new WP_Query($args);
        $posts = $query->get_posts();
        $values = [];
        foreach (papi_to_array($settings->slug) as $slug) {
            foreach ($posts as $post) {
                $val = papi_get_field($post->ID, $slug);
                $val = array_filter(papi_to_array($val), function ($item) use($post_id) {
                    return is_object($item) && $item->ID === $post_id;
                });
                if (empty($val)) {
                    continue;
                }
                $page_type = papi_get_entry_type_by_meta_id($post->ID);
                if (empty($page_type)) {
                    continue;
                }
                // Create the array
                if (!isset($values[$post->post_type])) {
                    $values[$post->post_type] = [];
                }
                if (!isset($values[$post->post_type][$page_type->name])) {
                    $values[$post->post_type][$page_type->name] = [];
                }
                // Add the post
                if (!isset($values[$post->post_type][$page_type->name][$post->ID]) && !empty($val)) {
                    $values[$post->post_type][$page_type->name][$post->ID] = $post;
                }
            }
        }
        ?>
		<ul class="papi-property-reference" data-papi-rule="<?php 
        echo esc_attr($this->html_name());
        ?>
">
			<?php 
        if (empty($values)) {
            ?>
				<p>
					<?php 
            esc_html_e('No references exists', 'papi');
            ?>
				</p>
			<?php 
        }
        ksort($values);
        foreach ($values as $title => $val) {
            $post_type = get_post_type_object($title);
            ?>
				<li>
					<h3><?php 
            echo esc_html($post_type->labels->name);
            ?>
</h3>
					<div class="handlediv" title="Click to toggle"><br></div>
				</li>
				<li>
					<div class="page-types">
						<ul>
							<?php 
            ksort($val);
            foreach ($val as $name => $posts) {
                ?>
								<li class="heading-border">
									<h4><?php 
                echo esc_html($name);
                ?>
</h4>
									<div class="handlediv" title="Click to toggle"><br></div>
								</li>
								<li>
									<div class="box">
										<?php 
                $i = 0;
                foreach ($posts as $post) {
                    ?>
											<a href="<?php 
                    echo esc_attr(get_edit_post_link($post->ID));
                    ?>
"><?php 
                    echo esc_html($post->post_title);
                    ?>
</a>
										<?php 
                    $i++;
                }
                ?>
										<div class="clear"></div>
									</div>
								</li>
							<?php 
            }
            ?>
						</ul>
						<div class="clear"></div>
					</div>
				</li>
			<?php 
        }
        ?>
		</ul>
		<?php 
    }
コード例 #12
0
ファイル: option.php プロジェクト: ekandreas/papi
/**
 * Get property value for property on a option page.
 *
 * @param  string $slug
 * @param  mixed  $default
 *
 * @return mixed
 */
function papi_get_option($slug, $default = null)
{
    return papi_get_field(0, $slug, $default, Papi_Option_Page::TYPE);
}
コード例 #13
0
<div class="wrap">
	<div id="primary" class="content-home">
		<main id="main" class="site-main" role="main">

			<?php 
while (have_posts()) {
    the_post();
    ?>

				<?php 
    get_template_part('template-parts/content', 'home');
    ?>

                <?php 
    $products = papi_get_field('products');
    if ($products) {
        ?>
					<div class="cards">
                	<?php 
        foreach ($products as $key => $product) {
            $post = get_post($product->ID);
            setup_postdata($post);
            get_template_part('templates/parts/product-card');
        }
        ?>
					</div>
                	<?php 
    }
    wp_reset_postdata();
    ?>
コード例 #14
0
ファイル: option.php プロジェクト: wp-papi/papi
/**
 * Get property value for property on a option page.
 *
 * @param  string $slug
 * @param  mixed  $default
 *
 * @return mixed
 */
function papi_get_option($slug, $default = null)
{
    return papi_get_field(0, $slug, $default, 'option');
}
コード例 #15
0
ファイル: option.php プロジェクト: KristoferN/papi
/**
 * Get property value for property on a option page.
 *
 * @param  string $slug
 * @param  mixed  $default
 *
 * @return mixed
 */
function papi_get_option($slug, $default = null)
{
    return papi_get_field(0, $slug, $default, Papi_Core_Page::TYPE_OPTION);
}
コード例 #16
0
ファイル: pusher.blade.php プロジェクト: ekandreas/aekab
            <div class="blogpuffright">
              <div class="w-clearfix blogpuffheaderdiv">
                <div class="blogpuffheaderleft">

                  @if( papi_get_page_type_id() == 'blog-post' )
                        <div class="blogpuffdate">{{ __('BLOGGPOST','AEKAB' ) }}</div>
                  @elseif( papi_get_page_type_id() == 'portfolio-post' )
                        <div class="blogpuffdate">{{ __('UPPDRAG','AEKAB' ) }}</div>
                  @else
                        <div class="blogpuffdate">{{ __('NYHET','AEKAB' ) }}</div>
                  @endif

                </div>
                <div class="blogpuffheaderright">
                  <?php 
$main_cat = papi_get_field('main_category');
?>
                  @if( $main_cat && property_exists( $main_cat, 'name' ) )
                    <div class="blogpuffheadertxt">{{ $main_cat->name }}</div>
                  @endif
                </div>
              </div>
              <a href="{{ get_the_permalink() }}" class="w-inline-block blogpuffclickarea"><h3 class="blogpuffheadline">{{the_title()}}</h3>
                <p class="blogpuffbody">
                  {!! get_post_excerpt() !!}                
                </p>
              </a>
            </div>
          </div> 

コード例 #17
0
            @endforeach
          @endif

          <?php 
wp_reset_postdata();
?>
            

        </div>
      </div>
    </div>
  </div>
  <div class="w-section sectionpuffsmorenews">
    <div class="w-container">
      <?php 
$more = papi_get_field($module->id, 'more');
?>
      @if( $more )
      <a href="{{ $more->url }}" class="w-inline-block startpagelinkblockmorenews">
        <div>{{ $more->title }}</div>
      </a>
      @endif
    </div>
  </div>
  @include('views.parts.swisch')

@include('views.parts.admin-edit')


コード例 #18
0
ファイル: payoff.blade.php プロジェクト: ekandreas/aekab
<?php

$type = 1;
$payoff = 'Ledord för oss är respons, nyfikenhet, affärsförståelse och kvalitetsinsatser.';
if (isset($module)) {
    $type = $module->type;
    $payoff = $module->words;
} else {
    $post_payoff = papi_get_field('payoff');
    if ($post_payoff) {
        $payoff = $post_payoff;
    }
    $type = 2;
}
?>


@if( $type == 2 )
	<div class="w-section sectiongreypayoff">
		<div class="w-container">
			<h2 class="startpagepayoff1 payoff2">{{ $payoff }}</h2>
		</div>
	</div>
	@include('views.parts.pointers.gray_right')
@else
	<div class="w-section startpagesectionpayoff1">
		<div class="w-container">
			<h1 class="startpagepayoff1">{{ $payoff }}</h1>
		</div>
	</div>
@endif
コード例 #19
0
$matches = papi_get_field($module->id, 'matches');
if ($matches) {
    foreach ($matches as $match) {
        if (!$cat_list == '') {
            $cat_list .= ',';
        }
        $cat_list .= $match['term']->term_id;
    }
}
?>
<div class="row">

	<div class="col-md-12">

		<?php 
$length = (int) papi_get_field($module->id, 'excerpt_length');
$args = ['post_type' => 'post'];
if ($cat_list != '') {
    $args['cat'] = $cat_list;
}
$the_query = new WP_Query($args);
?>
		@if( $the_query->have_posts() )
			@if( $title=papi_get_field( $module->id, 'title' ) )
				<h2>{{ $title }}</h2>
			@endif
			@while ( $the_query->have_posts() )
				{{ $the_query->the_post() }}
					<h3>{{ the_title() }}</h3>
					{!! get_post_excerpt( get_the_ID(), $length, false) !!}
					<br/>
コード例 #20
0
 /**
  * Get property value.
  *
  * @param  Papi_Core_Conditional_Rule $rule
  *
  * @return mixed
  */
 private function get_value(Papi_Core_Conditional_Rule $rule)
 {
     if (papi_doing_ajax()) {
         $source = $rule->get_source();
         $meta_id = papi_get_meta_id();
         $entry_type = papi_get_entry_type_by_meta_id($meta_id);
         if (!papi_is_empty($source) && $entry_type instanceof Papi_Entry_Type !== false) {
             if (papi_is_property($entry_type->get_property($rule->slug))) {
                 return $this->get_deep_value($rule->slug, $source);
             }
         }
     }
     if (!papi_is_empty($rule->get_source())) {
         return $this->get_deep_value($rule->slug, $rule->get_source());
     }
     $slug = $rule->get_field_slug();
     $type = papi_get_meta_type();
     $value = papi_get_field($slug, null, $type);
     return $this->get_deep_value($slug, $value);
 }
コード例 #21
0
<?php

$link = papi_get_field($module->ID, 'link');
?>

<div class="panel panel-default">
	<div class="panel-heading">
		<h3 class="panel-title">{{ get_the_title( $module->ID ) }}</h3>
	</div>
	<div class="panel-body">
		@if( has_post_thumbnail( $module->ID ) )
			<div class="thumbnail">
			    <?php 
$feat_image_url = wp_get_attachment_url(get_post_thumbnail_id($module->ID));
?>
				<img src="{{ $feat_image_url }}" class="img-responsive" />
			</div>
		@endif
		<p>{!! papi_get_field( $module->ID, 'text' ) !!}</p>
		@if( $link )
			<div class="caption text-center">
					<p>
						<a href="{{ $link->url }}" class="btn btn-warning">{{ $link->title }}</a>
					</p>
			</div>
		@endif
	</div>
</div>


コード例 #22
0
ファイル: deprecated.php プロジェクト: KristoferN/papi
/**
 * Get value for a property on a page.
 *
 * You should use papi_get_field() instead.
 *
 * @param int    $post_id
 * @param string $slug
 * @param mixed  $default
 * @param string $type
 *
 * @deprecated deprecated since version 2.0.0.
 *
 * @return mixed
 */
function papi_field($post_id = null, $slug = null, $default = null, $type = 'post')
{
    _deprecated_function(__FUNCTION__, '2.0.0', 'papi_get_field');
    return papi_get_field($post_id, $slug, $default, $type);
}
コード例 #23
0
ファイル: page.php プロジェクト: nlemoine/papi
/**
 * Echo the value for property.
 *
 * @param int    $id
 * @param string $slug
 * @param mixed  $default
 */
function the_papi_field($id = null, $slug = null, $default = null)
{
    $value = papi_get_field($id, $slug, $default);
    if (is_array($value)) {
        $value = implode(', ', $value);
    }
    if (is_object($value)) {
        $value = papi_convert_to_string($value);
    }
    echo esc_html($value);
}
コード例 #24
0
 /**
  * Get value.
  *
  * @return mixed
  */
 public function get_value()
 {
     $value = $this->get_option('value');
     if (papi_is_empty($value)) {
         $slug = $this->get_slug(true);
         if ($this->is_option_page()) {
             $value = papi_get_option($slug);
         } else {
             $value = papi_get_field($this->get_post_id(), $slug);
         }
         $post_status = get_post_status($this->get_post_id());
         if (papi_is_empty($value) && ($post_status === false || $post_status === 'auto-draft')) {
             $value = $this->get_option('default');
         }
     }
     return $this->prepare_value($value);
 }
コード例 #25
0
ファイル: index.blade.php プロジェクト: ekandreas/aekab
@extends('views.layouts.master')

@section('main')

	<?php 
$modules = papi_get_field(get_the_ID(), 'page_modules');
?>
	
	@if( $modules )
		@foreach( $modules as $module )
			@include( rtrim( papi_get_page_type_template($module->ID), '.php' ), [ 'module' => papi_get_page($module->ID) ] )
		@endforeach
	@endif

@endsection
コード例 #26
0
ファイル: page.php プロジェクト: ekandreas/papi
/**
 * Echo the value for property on a page.
 *
 * @param int    $post_id
 * @param string $slug
 * @param mixed  $default
 */
function the_papi_field($post_id = null, $slug = null, $default = null)
{
    $value = papi_get_field($post_id, $slug, $default);
    if (is_array($value)) {
        $value = implode(', ', $value);
    }
    echo $value;
}
コード例 #27
0
 /**
  * Get property value.
  *
  * @param  Papi_Core_Conditional_Rule $rule
  *
  * @return mixed
  */
 private function get_value(Papi_Core_Conditional_Rule $rule)
 {
     if (papi_doing_ajax()) {
         $source = $rule->get_source();
         $post_id = papi_get_post_id();
         $page_type = papi_get_page_type_by_post_id($post_id);
         if (!papi_is_empty($source) && $page_type instanceof Papi_Page_Type !== false) {
             if (papi_is_property($page_type->get_property($rule->slug))) {
                 return $this->get_deep_value($rule->slug, $source);
             }
         }
     }
     if (!papi_is_empty($rule->get_source())) {
         return $this->get_deep_value($rule->slug, $rule->get_source());
     }
     $slug = $rule->get_field_slug();
     if (papi_is_option_page()) {
         $value = papi_get_option($slug);
     } else {
         $value = papi_get_field($slug);
     }
     return $this->get_deep_value($slug, $value);
 }