<?php /** * The public-facing functionality of the plugin. * * @link http://example.com * @since 1.0.0 */ namespace Formine\front; /** * The public-facing functionality of the plugin. * * Defines the plugin name, version, and two examples hooks for how to * enqueue the admin-specific stylesheet and JavaScript. * * @author Your Name <email@example.com> */ class Controller { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $formine The ID of this plugin. */ private $formine; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $formine The name of the plugin. * @param string $version The version of this plugin. */ public function __construct($formine, $version) { $this->formine = $formine; $this->version = $version; add_shortcode('formine', [$this, 'load_shortcode']); add_shortcode('long_form', [$this, 'long_form_shortcode']); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { wp_enqueue_style( $this->formine, plugin_dir_url(__FILE__,) . 'imba2/dist/public/__assets__/app/client.css', [], $this->version, 'all' ); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { wp_enqueue_script( $this->formine, plugin_dir_url(__FILE__,) . 'imba2/dist/public/__assets__/app/client.js', [], $this->version, true ); wp_localize_script('formine', 'base', [ 'url' => get_site_url() ]); } /** * Register the shortcode for the public-facing form. */ public function load_shortcode() { ?> <script> var nonce = '<?php echo wp_create_nonce('wp_rest') ?>' </script> <div style="max-width:1024px; margin-right:auto; margin-left: auto;"> <moving-form></moving-form> </div> <?php } /** * Register the long one-page version of the form */ public function long_form_shortcode() { ?> <script> var nonce = '<?php echo wp_create_nonce('wp_rest') ?>' </script> <div style="max-width:468px; margin-right:auto; margin-left: auto;"> <vert-form></vert-form> </div> <?php } }