/** * @param $styles * * @return MC4WP_Styles_Builder */ public static function build($styles) { if (!self::$instance instanceof MC4WP_Styles_Builder) { self::$instance = new MC4WP_Styles_Builder(); } $builder = self::$instance; // clean-up styles array $builder->clean(); // sanitize submitted styles $builder->sanitize($styles); // listen for user-triggered actions (delete, copy, ..) $builder->act(); // return all styles (for WP options API) return $builder->styles; }
/** * Show form settings page */ public function show_form_settings() { $tab = isset($_GET['tab']) ? $_GET['tab'] : 'general-settings'; $opts = mc4wp_get_options('form'); if ($tab === 'general-settings') { $table = new MC4WP_Forms_Table(); } else { // get all forms $forms = get_posts(array('post_type' => 'mc4wp-form', 'post_status' => 'publish', 'posts_per_page' => -1)); // get form to which styles should apply if (isset($_GET['form_id'])) { $form_id = absint($_GET['form_id']); } elseif (isset($forms[0])) { $form_id = $forms[0]->ID; } else { $form_id = 0; } // get css settings for this form (or 0) $builder = new MC4WP_Styles_Builder(); $styles = $builder->get_form_styles($form_id); // create preview url $preview_url = add_query_arg(array('form_id' => $form_id, '_mc4wp_css_preview' => 1)); } require MC4WP_PLUGIN_DIR . 'includes/views/pages/admin-form-settings.php'; }
/** * Show Styles Builder page */ function show_page() { $forms = mc4wp_get_forms(); $form_id = $forms[0]->ID; // get form to which styles should apply if (isset($_GET['form_id'])) { $form_id = absint($_GET['form_id']); } $form = mc4wp_get_form($form_id); // get css settings for this form (or 0) $builder = new MC4WP_Styles_Builder(); $styles = $builder->get_form_styles($form_id); // create preview url $preview_url = add_query_arg(array('form_id' => $form_id, '_mc4wp_styles_builder_preview' => 1), home_url()); require dirname(__FILE__) . '/../views/styles-builder.php'; }