Created
January 8, 2021 14:23
-
-
Save xlawok/859c8e0432d417da4920bbc3ec7ad633 to your computer and use it in GitHub Desktop.
Wordpress - Carbon fields + contact form 7 list all forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// define( 'Carbon_Fields\URL', get_parent_theme_file_path( 'vendor/htmlburger/carbon-fields' ) ); | |
// \Carbon_Fields\Carbon_Fields::boot(); | |
define('Carbon_Fields\URL', WP_PLUGIN_URL. '/carbon-fields/vendor/htmlburger/carbon-fields'); | |
use Carbon_Fields\Container; | |
use Carbon_Fields\Field; | |
function sc_get_contact_forms7(){ | |
$posts = get_posts(array( | |
'post_type' => 'wpcf7_contact_form', | |
'numberposts' => -1 | |
)); | |
$listing_forms=[]; | |
foreach ( $posts as $id => $p ) { | |
$listing_forms[ $id ] =$p->post_title; | |
} | |
return $listing_forms; | |
} | |
add_action( 'carbon_fields_register_fields', 'crb_attach_theme_options' ); | |
function crb_attach_theme_options() { | |
Container::make( 'theme_options', __( 'Główne opcje tematu' ) ) | |
->add_fields( array( | |
Field::make( 'separator', 'theme_first_separator', 'LOGO' ), | |
) ); | |
Container::make( 'post_meta', 'Edycja treści strony' ) | |
// ->where( 'post_id', '=', get_option( 'page_on_front' ) ) | |
->where( 'post_type', '=', 'page' ) | |
->add_fields( array( | |
Field::make( 'select', 'page_form','Wybierz formularz na stronę' ) | |
->add_options( 'sc_get_contact_forms7' ), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment