php ACF:Ukázkapráce的瞬态
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php ACF:Ukázkapráce的瞬态相关的知识,希望对你有一定的参考价值。
<?php
/*-----------------------------------------------------------------------------------
/* HEADER - SOCIAL SITES
/*---------------------------------------------------------------------------------*/
// If this file is called directly, abort.
if ( !defined( 'WPINC' ) ) {
die;
}
class Transient_Global_Social_Sites {
private $transient_name;
private $transient_expiration;
public function __construct() {
// set transient name
$this->transient_name = 'sk_global_socials';
// set transient expiration
$this->transient_expiration = 1 * WEEK_IN_SECONDS;
// remove transient
add_action( 'acf/save_post', array( $this, 'remove_data' ), 20 );
}
/**
* GET DATA
*
**/
public function get_data() {
// TRANSIENTS
if ( false === ( $data = get_transient( $this->transient_name ) ) ) {
$data = array();
$data['facebook'] = get_option( 'options_sk_global_social_facebook' );
$data['instagram'] = get_option( 'options_sk_global_social_instagram' );
$data['twitter'] = get_option( 'options_sk_global_social_twitter' );
$data['pinterest'] = get_option( 'options_sk_global_social_pinterest' );
$data['linkedin'] = get_option( 'options_sk_global_social_linkedin' );
// SAVE TRANSIENT
set_transient( $this->transient_name, $data, $this->transient_expiration );
}
return $data;
}
/**
* REMOVE TRANSIENT
*
**/
private function remove_data() {
if ( empty( $_POST['acf'] ) ) {
return;
}
$fields = $_POST['acf'];
if ( isset( $fields['field_5b841df149c49'] ) ||
isset( $fields['field_5b841dfd49c4a'] ) ||
isset( $fields['field_5b841e0549c4b'] ) ||
isset( $fields['field_5b841e1249c4c'] ) ||
isset( $fields['field_5b841e1b49c4d'] ) ) {
delete_transient( $this->transient_name );
}
}
}
?>
<?php
// SOCIAL SITES
$social_transient = new Transient_Global_Social_Sites();
$social_data = $social_transient->get_data();
if ( $social_data ) :
?>
<div class="m-social">
<ul class="m-social__list">
<?php
// Facebook
if ( isset( $social_data['facebook'] ) && !empty( $social_data['facebook'] ) ) :
?>
<li class="m-social__item" title="Show on Facebook">
<a href="<?php echo esc_url( $social_data['facebook'] ); ?>" target="_blank" class="m-social__link">Facebook</a>
</li>
<?php
endif;
// Twitter
if ( isset( $social_data['twitter'] ) && !empty( $social_data['twitter'] ) ) :
?>
<li class="m-social__item" title="Show on Twitter">
<a href="<?php echo esc_url( $social_data['twitter'] ); ?>" target="_blank" class="m-social__link">Twitter</a>
</li>
<?php
endif;
// LinkedIn
if ( isset( $social_data['linkedin'] ) && !empty( $social_data['linkedin'] ) ) :
?>
<li class="m-social__item" title="Show on LinkedIn">
<a href="<?php echo esc_url( $social_data['linkedin'] ); ?>" target="_blank" class="m-social__link">LinkedIn</a>
</li>
<?php
endif;
// Pinterest
if ( isset( $social_data['pinterest'] ) && !empty( $social_data['pinterest'] ) ) :
?>
<li class="m-social__item" title="Show on Pinterest">
<a href="<?php echo esc_url( $social_data['pinterest'] ); ?>" target="_blank" class="m-social__link">Pinterest</a>
</li>
<?php
endif;
// Instagram
if ( isset( $social_data['instagram'] ) && !empty( $social_data['instagram'] ) ) :
?>
<li class="m-social__item" title="Show on Instagram">
<a href="<?php echo esc_url( $social_data['instagram'] ); ?>" target="_blank" class="m-social__link">Instagram</a>
</li>
<?php
endif;
?>
</ul>
</div>
<?php
endif;
?>
以上是关于php ACF:Ukázkapráce的瞬态的主要内容,如果未能解决你的问题,请参考以下文章
html Hračka - ukázka主题 - vygenerovánístrktury
scss 模块mixin - ukázkamodulovéhopřístupu
php 使用JavaScript将数据保存到ACF Repeater字段 - 教程:https://www.22nds.com/acf-repeater-field-javascript/
html Ukázkazanořeného地图对象 - SCSS(2rozměrný)
在帖子创建期间计算 PHP date_diff 并保存到 ACF 字段
php ACF w / ACF超链接#ACF