我对WordPress开发非常熟悉,所以我会尽量解释我想要的所有细节,不知道是否可能!
我正在使用一个名为wp crowfunding的扩展,在其中,您可以从后端或短代码添加项目。在我的例子中,我使用的是et短代码。所以在里面,我有很多字段,比如“标题”、“描述”等等。。。但我想添加更多字段。
我的问题是,我无法通过复制主题中的文件来覆盖原始模板(名为:/shortcode/submit form.php)(不起作用)。所以我问自己是否可以使用我的功能。php修改此文件而不破坏扩展名。如果这是可能的,我不知道怎么做。
更准确地说,我需要在该短代码中添加所见即所得字段。如果需要更多信息:)
提前感谢!
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
}