text ACF表格前端短代码插件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text ACF表格前端短代码插件相关的知识,希望对你有一定的参考价值。
<?php
/*
Plugin Name: ACF Front End Forms
Plugin URI: https://navarrojr.com
Description: Create forms on the front end of the site from ACF field groups.
Version: 0.0.1
Author: Dave Navarro, Jr.
Author URI: https://navarrojr.com
*/
//* Add required acf_form_head() function to head of page
function am_do_acf_form_head() {
if ( !is_admin() )
acf_form_head();
}
add_action( 'get_header', 'am_do_acf_form_head', 1 );
//* Add custom body class to the head
function am_acf_form_class( $classes ) {
$classes[] = 'acf-form-front';
return $classes;
}
add_filter( 'body_class', 'am_acf_form_class' );
//* ACF Form Short Code
function am_sc_acf_form( $attr ) {
$cpt = $attr['cpt'];
$post_id = $_GET['postid'];
$title = ( $attr['title'] == 1 ) || ( $attr['title'] == 'y' ) || ( $attr['title'] == 'yes' );
$content = ( $attr['content'] == 1 ) || ( $attr['content'] == 'y' ) || ( $attr['content'] == 'yes' );
$submit = 'submit';
if ( empty( $post_id ) ) {
$post_id = 'new_post';
} else {
$submit = 'update';
}
$options = array( 'id' => 'acf_form',
'post_id' => $post_id,
'label_placement' => 'top',
'instruction_placement' => 'field',
'new_post' => array( 'post_type' => $cpt, 'post_status' => 'publish'),
'submit_value' => $submit,
'updated_message' => __( 'Client Updated', 'acf' ),
'post_title' => $title,
'post_content' => $content,
'return' => '%post_url%',
);
ob_start();
acf_form( $options );
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
add_shortcode( 'do_acf_form', 'am_sc_acf_form' );
以上是关于text ACF表格前端短代码插件的主要内容,如果未能解决你的问题,请参考以下文章
php 使用ACF字段创建包含短代码的HREF链接
php 使用ACF字段创建包含短代码的HREF链接
php acf字段中的短代码(非所见即所得)
php Beaver Builder / Beaver Themer ACF Map短代码
datatables 前端表格插件 增删改查功能
ACF 循环表复选框(WordPress)的问题