/** * Generate our simple flat pricing table HTML * @return [type] */ function dh_ptp_generate_simple_flat_pricing_table_html($id) { global $features_metabox; global $meta; $meta = get_post_meta($id, $features_metabox->get_the_id(), TRUE); /** * the string to be returned that includes the pricing table html * @var string */ $loop_index = 0; $pricing_table_html = '<div id="ptp-' . $id . '" class="ptp-pricing-table">'; foreach ($meta['column'] as $column) { // Note: beneath ifs are to prevent 'undefined variable notice'. It wasn't possible to put this code into a function since the passing argument might be undefined. //<editor-fold desc="get settings relevant to current column"> // get plan name $planname = isset($column['planname']) ? $column['planname'] : ''; // get plan price $planprice = isset($column['planprice']) ? $column['planprice'] : ''; $planfeatures = isset($column['planfeatures']) ? $column['planfeatures'] : ''; // get plan price $buttonurl = isset($column['buttonurl']) ? $column['buttonurl'] : ''; // get plan price $buttontext = isset($column['buttontext']) ? $column['buttontext'] : ''; //</editor-fold> //<editor-fold desc="set html based on if our current column is featured"> if (isset($column['feature'])) { if ($column['feature'] == "featured") { $most_popular_text = isset($meta['most-popular-label-text']) ? $meta['most-popular-label-text'] : 'Most Popular'; $feature = "ptp-highlight"; $feature_label = '<div class="ptp-most-popular">' . $most_popular_text . '</div>'; } else { $feature = ''; $feature_label = '<div class="ptp-not-most-popular"> </div>'; } } else { $feature = ''; $feature_label = '<div class="ptp-not-most-popular"> </div>'; } //</editor-fold> // create the html code $pricing_table_html .= ' <div class="ptp-col ' . dh_ptp_get_number_of_columns() . ' ' . $feature . ' ptp-col-id-' . $loop_index . '">' . $feature_label . '<ul class="ptp-item-container"> <li class="ptp-plan">' . $planname . '</li> <li class="ptp-price">' . $planprice . '</li>' . dh_ptp_features_to_html_simple_flat($planfeatures, dh_ptp_get_max_number_of_features()) . ' <li class="ptp-cta"> <a class="ptp-button" href="' . $buttonurl . '">' . $buttontext . '</a> </li> </ul> </div> '; $loop_index++; } $pricing_table_html .= '</div>'; return $pricing_table_html; }
/** * Generate our simple flat pricing table HTML * @return [type] */ function dh_ptp_generate_simple_flat_pricing_table_html($id) { global $features_metabox; global $meta; $meta = get_post_meta($id, $features_metabox->get_the_id(), TRUE); $loop_index = 0; $pricing_table_css = dh_ptp_easy_pricing_table_dynamic_css($id); $pricing_table_html = '<div id="ptp-' . $id . '" class="ptp-pricing-table">'; foreach ($meta['column'] as $column) { // Column details $plan_name = isset($column['planname']) ? $column['planname'] : ''; $plan_price = isset($column['planprice']) ? $column['planprice'] : ''; $plan_features = isset($column['planfeatures']) ? $column['planfeatures'] : ''; $button_text = isset($column['buttontext']) ? $column['buttontext'] : ''; $button_url = isset($column['buttonurl']) ? $column['buttonurl'] : ''; $button_url = trim($button_url); // Get custom shortcode if any $custom_button = false; $shortcode_pattern = '|^\\[shortcode\\](?P<custom_button>.*)\\[/shortcode\\]$|'; if (preg_match($shortcode_pattern, $button_text, $matches) || preg_match($shortcode_pattern, $button_url, $matches)) { $custom_button = $matches['custom_button']; } // Featured column $feature = ''; $feature_label = '<div class="ptp-not-most-popular"> </div>'; if (isset($column['feature']) && $column['feature'] == "featured") { $feature = "ptp-highlight"; $most_popular_text = isset($meta['most-popular-label-text']) ? $meta['most-popular-label-text'] : __('Most Popular', PTP_LOC); $feature_label = '<div class="ptp-most-popular">' . $most_popular_text . '</div>'; } // create the html code $pricing_table_html .= ' <div class="ptp-col ' . dh_ptp_get_number_of_columns() . ' ' . $feature . ' ptp-col-id-' . $loop_index . '">' . $feature_label . '<div class="ptp-item-container">' . '<div class="ptp-plan">' . $plan_name . '</div> ' . '<div class="ptp-price">' . $plan_price . '</div>' . dh_ptp_features_to_html_simple_flat($plan_features, dh_ptp_get_max_number_of_features()) . '<div class="ptp-cta">' . ($custom_button ? $custom_button : '<a class="ptp-button" id="ptp-' . $id . '-cta-' . $loop_index . '" href="' . $button_url . '">' . $button_text . '</a>') . '</div>' . '</div>' . '</div>'; $loop_index++; } $pricing_table_html .= '</div>'; return $pricing_table_css . $pricing_table_html; }