This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 4
Machform Function / Plugin for Wordpress
Started 9 years ago by celsiusmarketing | 3 posts |
-
Hey everyone, I kept running into javascript conflicts with machforms on wordpress sites so I created this nifty little shortcode plugin that has been a big help.
You can add this to your theme's functions.php file or you can simply create a new wordpress plugin and drop this code in there (which is what I suggest you do).
To call the form within a post all you need to do is use this shortcode:
[macform id=12345 height=12345]
Hope this helps! It has been a big help for our agency!
// Enqueue Scripts [MACHFORM]
function machform_scripts() {
//register scripts for our theme
wp_register_script('machform-post-message', 'http://YOUR-DOMAIN.COM/js/jquery.ba-postmessage.min.js', '', '', true );
wp_register_script('machform-loader', 'http://YOUR-DOMAIN.COM/js/machform_loader.js', '', '', true );
}// Shortcode [MACHFORM]
function machform_shortcode($atts){
// Load Machform Scripts in Footer
wp_enqueue_script( 'machform-post-message' );
wp_enqueue_script( 'machform-loader' );//Attributes added to shortcodes
Extract( shortcode_atts( array(
'id'=>'none',
'height'=>'none',
), $atts ));
$formcode = '<script type="text/javascript">var __machform_url = \'http://YOUR-DOMAIN.COM/embed.php?id='.$id.'\'; var __machform_height = '.$height.';</script><div id="mf_placeholder"></div>';return do_shortcode($formcode);
};add_action( 'wp_enqueue_scripts', 'machform_scripts' );
add_shortcode("machform", "machform_shortcode");
Posted 9 years ago # -
How is this different than this plugin? https://wordpress.org/plugins/machform-shortcode/
Posted 9 years ago # -
No clue isaacl, I stay away from repository wordpress plugins, as many times they become abandoned. I created this as a simple tool for anyone here that wishes to use this on their wordpress site.
Posted 9 years ago #
Reply
You must log in to post.