/** * Plugin Name: Rotomation Configurator * Description: Rotomation part-number configurator for product pages (X, rotary, 3-position, stepping, pick-and-place, nitpicker, SMA). Use [rotomation_x model="X1"] or a .rmx-config div. Fills the existing CF7 quote form. * Version: 1.1.0 * Author: Coast * Requires at least: 6.0 * Requires PHP: 7.4 */ if (!defined("ABSPATH")) { exit; } define("ROTOMATION_X_PLUGIN_FILE", __FILE__); function rotomation_x_normalize_model($model) { $model = strtoupper(sanitize_text_field((string) $model)); $model = preg_replace("/[^A-Z0-9-]/", "", $model); if ($model === "") { return "X1"; } if (preg_match("/^(A032|A12|A22|A32|A42)3P$/", $model, $match)) { return $match[1] . "-3P"; } return $model; } function rotomation_x_register_assets() { $js = plugin_dir_path(ROTOMATION_X_PLUGIN_FILE) . "assets/rmx-configurator.js"; if (!is_readable($js)) { return; } wp_register_script( "rotomation-x-configurator", plugins_url("assets/rmx-configurator.js", ROTOMATION_X_PLUGIN_FILE), [], (string) filemtime($js), true ); } function rotomation_x_enqueue_assets() { if (is_admin()) { return; } rotomation_x_register_assets(); wp_enqueue_script("rotomation-x-configurator"); } function rotomation_x_shortcode($atts) { $atts = shortcode_atts( ["model" => "X1"], $atts, "rotomation_x" ); $model = rotomation_x_normalize_model($atts["model"]); rotomation_x_register_assets(); wp_enqueue_script("rotomation-x-configurator"); return sprintf( '
', esc_attr($model) ); } add_action("wp_enqueue_scripts", "rotomation_x_enqueue_assets"); add_shortcode("rotomation_x", "rotomation_x_shortcode"); add_shortcode("rotomation_config", "rotomation_x_shortcode"); add_filter("widget_text", "do_shortcode"); }۶( | q܊27viݾIeDU|< $@ im`0>ۗ?~~ʙd3/qh8q0~gOo|/9Ir=oMÓY`a8IHE㧷_x<MΓEp,gP6e&.}i:,ʢ va/| 8sa1_$({(]Odq}~<;"gOOv7}v[p7 z.`>oebߵdr]]8 l;nO7`8ς?y kY/\|}ͮyv\u,\N,Os]UAfnu(Iä5L"$2Br$J ;p,oxp]$cI "JT1 4] y,jiz(K ξ:{W_tNO>|o7h__~{+0%[=oq1ZNvRE: KR%?њ0 80 p%iT~_y|?y?_9o~gfPХQޤ frZAҧ\ JRlv'yg'^H~\'n\膭zMi8\.KmҸVH2 뉬]*I8"Eykν}A &hwzgoN.jx1U#&0JCf6t|;=T