function lambda_theme_activate() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; #----------------------------------------------------------------- # multisite installation #----------------------------------------------------------------- $table_prefix = lambda_get_table_prefix(); #----------------------------------------------------------------- # creates the table manager table #----------------------------------------------------------------- $table_lambda_tables = $table_prefix . "lambda_tables"; if ($wpdb->get_var("show tables like '{$table_lambda_tables}'") != $table_lambda_tables) { $sql = "CREATE TABLE " . $table_lambda_tables . " (\n\t\t\t\t id mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t table_name VARCHAR(255) NOT NULL DEFAULT 'lambda_table_options',\n\t\t\t\t table_content TEXT,\n\t\t\t\t PRIMARY KEY (`id`),\n\t\t\t\t UNIQUE ( `table_name` ) \n\t\t\t)"; dbDelta($sql); } #----------------------------------------------------------------- # creates the table manager table #----------------------------------------------------------------- # create a few needed options add_option('lambda_version'); add_option('lambdacopyright'); add_option('lambdacopyrightlink'); # insert values for the created options update_option('lambda_version', '2.2'); update_option('lambdacopyright', 'UnitedThemes'); update_option('lambdacopyrightlink', 'http://www.unitedthemes.com/'); # disbale comments on theme activation update_option('default_comment_status', 'closed'); }
function handle_table_shortcode($atts) { extract(shortcode_atts(array("id" => '', 'class' => ''), $atts)); global $wpdb, $lambda_meta_data; $table_prefix = lambda_get_table_prefix(); $table_name = $table_prefix . "lambda_tables"; $table_result = $wpdb->get_row('SELECT * FROM ' . $table_name . ' WHERE id =' . $id); //no result? = escape if (!$table_result) { return; } ?> <?php $tabledata = lambda_prepare_load($table_result->table_content); $tabledata = $tabledata[$table_result->table_name]; $activecolumns = 0; /* count active tables */ if (is_array($tabledata['columns'])) { foreach ($tabledata['columns'] as $column) { if ($column['column_active'] == 'on') { $activecolumns++; } } } $tablegrid = array(4 => 'span3', 3 => 'span4', 2 => 'span6', 1 => 'span12'); ?> <?php $table = '<div class="lambda-pricingtable-wrap row-fluid clearfix ' . $class . '">'; if (is_array($tabledata['columns'])) { foreach ($tabledata['columns'] as $column) { if ($column['column_active'] == 'on') { $table .= '<div class="lambda-pricingtable-holder ' . $tablegrid[$activecolumns] . '">'; $featuredcol = $column['featured'] == 'yes' ? 'featured' : ''; $table .= '<div class="lambda-pricingtable ' . $featuredcol . '"> <div class="lambda-pricingtable-top"> <h3>' . $column['column_head'] . '</h3> </div> <h4><sup>' . $column['column_curr'] . '</sup>' . $column['column_price'] . '</h4> <p>' . $column['column_time'] . '</p> <ul>'; foreach ($column['column_content'] as $feature) { $table .= '<li>' . do_shortcode($feature) . '</li>'; } $table .= '</ul>'; if ($column['column_buttontext']) { $table .= '<div class="lambda-pricingtable-button"> <span class="ut-btn-holder"><a href="' . $column['column_url'] . '" class="ut-btn ut-table-btn small" target="_self">' . $column['column_buttontext'] . '</a></span> </div>'; } if ($column['column_htmltext']) { $table .= $column['column_htmltext']; } $table .= '</div>'; $table .= '</div>'; } ?> <?php } } $table .= '</div>'; return $table; }
function lambda_table_edit() { ?> <div id="lambda-option-panel" class="bootstrap-wpadmin"> <div id="ut-confirm-overlay" style="display:none;"></div> <div id="content_wrap"> <form id="tablemanager" method="post"> <div class="lambda-opttitle lambda-controls"> <div class="lambda-opttitle-pad" style="padding-bottom:0;"> <span class="lambda-version"><?php _e('Theme Version', 'delaware-theme'); echo UT_THEME_VERSION; ?> </span> <button type="submit" class="lambda_save ut-framework-btn right" name="submit" /><?php _e('Save All Changes', 'delaware-theme'); ?> </button> <div class="clear"></div> </div> </div> <div id="lambda-options-panel-title"> <?php echo _e('Table Manager', 'delaware-theme'); ?> </div> <div style="padding:20px; padding-top:0px;"> <?php global $wpdb; $tablename = $table = $_GET['edit']; ?> <input type="hidden" name="action" value="table_update" /> <input type="hidden" name="page_options" value="<?php echo $tablename; ?> " /> <div id="table-items" class="tab-pane"> <div id="single-columns row"> <?php $counter = 1; $table_prefix = lambda_get_table_prefix(); $table_lambda_tables = $table_prefix . "lambda_tables"; // get table data from database $table_content = $wpdb->get_var("SELECT table_content FROM {$table_lambda_tables} WHERE table_name = '{$tablename}'"); $table_content = lambda_prepare_load($table_content); if (!empty($table_content[$tablename]['columns'])) { $table_content = $table_content[$tablename]['columns']; } else { $table_content = lambda_table_item_array(); } foreach ($table_content as $key => $value) { ?> <div id="lambda_<?php echo $tablename . '_' . $key; ?> " class="one_fourth <?php echo $counter == 4 ? 'last' : ''; ?> "> <div class="lambda-box"> <span class="lambda-section-title"><?php _e('Column', 'delaware-theme'); ?> <?php echo $counter; ?> </span> <label for="column_<?php echo $tablename . '_' . $key; ?> "><?php _e('Activate Column?', 'delaware-theme'); ?> </label><br /> <div class="lambda_row"> <div class="btn-group" data-toggle="buttons-radio"> <button value="<?php echo $tablename . '_' . $key; ?> _on" type="button" class="btn <?php echo $value['column_active'] == 'on' ? 'active' : 'inactive'; ?> radio_<?php echo $value['column_active'] == 'on' ? 'active' : 'inactive'; ?> "><?php _e('on', 'delaware-theme'); ?> </button> <button value="<?php echo $tablename . '_' . $key; ?> _off" type="button" class="btn <?php echo $value['column_active'] == 'off' ? 'active' : 'inactive'; ?> radio_<?php echo $value['column_active'] == 'off' ? 'active' : 'inactive'; ?> "><?php _e('off', 'delaware-theme'); ?> </button> <input class="radiostate_<?php echo $value['column_active'] == 'on' ? 'active' : 'inactive'; ?> " style="display:none;" id="<?php echo $tablename . '_' . $key; ?> _on" type="radio" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_active]" value="on" <?php echo $value['column_active'] == 'on' ? 'checked="checked"' : ''; ?> /><br /> <input class="radiostate_<?php echo $value['column_active'] == 'off' ? 'active' : 'inactive'; ?> " style="display:none;" id="<?php echo $tablename . '_' . $key; ?> _off" type="radio" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_active]" value="off" <?php echo $value['column_active'] == 'off' ? 'checked="checked"' : ''; ?> /><br /> </div> </div> <hr /> <label for="column_<?php echo $tablename . '_' . $key; ?> "><?php _e('Column is featured?', 'delaware-theme'); ?> </label><br /> <div class="lambda_row"> <div class="btn-group" data-toggle="buttons-radio"> <button value="<?php echo $tablename . '_' . $key; ?> _yes" type="button" class="btn <?php echo $value['featured'] == 'yes' ? 'active' : 'inactive'; ?> radio_<?php echo $value['featured'] == 'yes' ? 'active' : 'inactive'; ?> "><?php _e('yes', 'delaware-theme'); ?> </button> <button value="<?php echo $tablename . '_' . $key; ?> _no" type="button" class="btn <?php echo $value['featured'] == 'no' ? 'active' : 'inactive'; ?> radio_<?php echo $value['featured'] == 'no' ? 'active' : 'inactive'; ?> "><?php _e('no', 'delaware-theme'); ?> </button> <input class="radiostate_<?php echo $value['featured'] == 'yes' ? 'active' : 'inactive'; ?> " style="display:none;" id="<?php echo $tablename . '_' . $key; ?> _yes" type="radio" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][featured]" value="yes" <?php echo $value['featured'] == 'yes' ? 'checked="checked"' : ''; ?> /><br /> <input class="radiostate_<?php echo $value['featured'] == 'no' ? 'active' : 'inactive'; ?> " style="display:none;" id="<?php echo $tablename . '_' . $key; ?> _no" type="radio" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][featured]" value="no" <?php echo $value['featured'] == 'no' ? 'checked="checked"' : ''; ?> /><br /> </div> </div> <hr /> <label><?php _e('Column Headline', 'delaware-theme'); ?> </label><br /> <input id="<?php echo $tablename . '_' . $key; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_head]" value="<?php echo $value['column_head']; ?> " /><br /> <hr /> <label><?php _e('Column Price', 'delaware-theme'); ?> </label><br /> <input id="<?php echo $tablename . '_' . $key; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_price]" value="<?php echo $value['column_price']; ?> " /><br /> <hr /> <label><?php _e('Price Currency', 'delaware-theme'); ?> </label><br /> <input id="<?php echo $tablename . '_' . $key; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_curr]" value="<?php echo $value['column_curr']; ?> " /><br /> <hr /> <label><?php _e('Period', 'delaware-theme'); ?> </label><br /> <input id="<?php echo $tablename . '_' . $key; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_time]" value="<?php echo $value['column_time']; ?> " /><br /> <hr /> <label><?php _e('Features', 'delaware-theme'); ?> </label><br /> <div id="features_<?php echo $tablename . '_' . $key; ?> "> <?php foreach ($value['column_content'] as $x => $feature) { ?> <div class="feature_item"> <input class="feature" id="feature_<?php echo $x; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_content][<?php echo $x; ?> ]" value="<?php echo $value['column_content'][$x]; ?> " /><br /> <button type="button" class="btn remove-feature"><i class="icon-trash"></i></button> </div> <?php } ?> </div> <button data-key="<?php echo $key; ?> " data-group="lambda_table_content" data-table="<?php echo $table; ?> " type="button" value="features_<?php echo $tablename . '_' . $key; ?> " class="add_column_feature btn" name="lambda_table_content[<?php echo $tablename; ?> ]"><i class="icon-plus"></i> <?php _e('Add Row', 'delaware-theme'); ?> </button> <div class="clear"></div> <hr /> <label><?php _e('Custom URL', 'delaware-theme'); ?> </label><br /> <input style="width:148px !important; min-width: inherit !important;" id="<?php echo $tablename . '_' . $key; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_url]" value="<?php echo $value['column_url']; ?> " /><br /> <hr /> <label><?php _e('Buttontext', 'delaware-theme'); ?> </label><br /> <input style="width:148px !important; min-width: inherit !important;" id="<?php echo $tablename . '_' . $key; ?> " type="text" name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_buttontext]" value="<?php echo $value['column_buttontext']; ?> " /><br /> <hr /> <?php $content_output = isset($value['column_htmltext']) ? $value['column_htmltext'] : ''; ?> <label><?php _e('HTML Content', 'delaware-theme'); ?> </label><br /> <textarea id="<?php echo $tablename . '_' . $key; ?> " name="lambda_table_content[<?php echo $tablename; ?> ][columns][<?php echo $key; ?> ][column_htmltext]"/><?php echo $content_output; ?> </textarea><br /> </div> </div> <?php $counter++; } // endforeach ?> <div class="clear"></div> </div><!-- /#single columns --> </div><!-- /#table items --> </div> </form> </div> </div> <?php }