Add a field into a shortcode of an extension
I’m very nooby to WordPress dev so I’ll try to explain all the details I want, don’t know if it is possible!
I’m using an extension called wp-crowfunding, in it, you can add a project from the backend or from a shortcode. In my case, I’m using et shortcode. So in it, I have a lot of fields like “title”, “description” etc… but I want to add more fields.
My issue is that I can’t override the original template (called: /shortcode/submit-form.php) by copying the file in my theme (not working). So I asked myself if I could use my function.php to modify this file without destroying the extension. If this is possible, I don’t know how to do that.
To be more precise I need to add a WYSIWYG field in that shortcode.
If you need more information 🙂
Thanks in advance!
Edit :
Ok so now i can display my form field in the shortcode, thanks to mmm :), Now i need to display the value of it in my post.
Here the code who add my form field :
add_action("plugins_loaded", function () {
if (!isset($GLOBALS["shortcode_tags"]["wpneo_crowdfunding_form"])) {
return;
}
$original_callback = $GLOBALS["shortcode_tags"]["wpneo_crowdfunding_form"];
add_shortcode("wpneo_crowdfunding_form", function ($attr, $content, $tag) use ($original_callback) {
$original_result = $original_callback($attr, $content, $tag);
// customise the HTML result of the form
$str_to_search = "<div class="wpneo-single"><div class="wpneo-name">Short Description";
$str_to_insert = '<div class="wpneo-single">';
$str_to_insert .= '<div class="wpneo-name">'.__( "Describe the team" , "wp-crowdfunding" ).'</div>';
$str_to_insert .= '<div class="wpneo-fields">';
ob_start();
wp_editor( $short_description, 'wpneo-form-team-description', array('editor_height'=>200) );
$str_to_insert .= ob_get_clean();
$str_to_insert .= '<small>'.__("Put Here Team Description","wp-crowdfunding").'</small>';
$str_to_insert .= '</div>';
$str_to_insert .= '</div>';
if (strpos($original_result, $str_to_search) !== false) {
$posToBegin = strpos($original_result, $str_to_search);
$original_result = substr_replace($original_result, $str_to_insert, $posToBegin, 0);
}
return $original_result;
}
);
});
And here the code where i want to display it :
add_filter('wpneo_crowdfunding_default_single_campaign_tabs', 'add_tab_crowdfunding_team', 20);
function add_tab_crowdfunding_team($arr){
$arr['test_tab'] = array(
'title' => __( 'The Team', 'wp-crowdfunding' ),
'priority' => 10,
'callback' => 'team_tab_view_callback'
);
return $arr;
}
function team_tab_view_callback(){
?>
<h1>HERE THE CONTENT I WANT TO DISPLAY</h1>
<?php
}
Leave an answer
You must login or register to add a new answer .