$logo,
'about' => $about,
'home' => $home,
'home_projects' => $home_projects,
'twitter' => $twitter,
'twitter_via' => $twitter_via,
'fb' => $fb,
'fb_via' => $fbname,
'google' => $google,
'g_via' => $gname,
'li' => $li,
'li_via' => $liname);
update_option('fivehundred_theme_settings', $settings);
echo '
';
}
else {
$settings = get_option('fivehundred_theme_settings');
$logo = $settings['logo'];
$about = stripslashes($settings['about']);
$home_projects = $settings['home_projects'];
$twitter = $settings['twitter'];
$twitter_via = $settings['twitter_via'];
$fb = $settings['fb'];
$fbname = $settings['fb_via'];
$google = $settings['google'];
$gname = $settings['g_via'];
$li = $settings['li'];
$liname = $settings['li_via'];
}
// set up the project home page dropdown
$projects = get_ign_projects();
$levels = '
|
|
';
include 'templates/admin/_themeSettings.php';
}
add_action('pre_get_posts', 'projects_archive_display');
function projects_archive_display($query) {
if (is_post_type_archive('ignition_product')) {
$query->set('posts_per_page',9);
return;
}
}
function the_project_summary($id) {
$project_id = get_post_meta($id, 'ign_project_id', true);
$image_url = the_project_image($id, "1");
$name = get_post_meta($id, 'ign_product_name', true);
$short_desc = html_entity_decode(get_post_meta($id, 'ign_project_description', true));
$total = get_fund_total($id);
$goal = the_project_goal($id);
$end = get_post_meta($id, 'ign_fund_end', true);
$end_type = get_post_meta($id, 'ign_end_type', true);
// ID Function
// GETTING product default settings
$default_prod_settings = getProductDefaultSettings();
// Getting product settings and if they are not present, set the default settings as product settings
$prod_settings = getProductSettings($project_id);
if ($prod_settings == -1) {
$prod_settings = $default_prod_settings;
}
$currency_code = $prod_settings->currency_code;
//GETTING the currency symbols
$cCode = setCurrencyCode($currency_code);
if ($end !== '') {
$show_dates = true;
$end = str_replace('/', ' ', $end);
$end = explode(' ', $end);
$end_string = $end[2].'-'.$end[0].'-'.$end[1];
$end_date = strtotime($end_string);
$now = time();
$dif = number_format(($end_date - $now)/86400);
if ($dif < 0) {
$dif = 0;
}
}
else {
$show_dates = false;
}
// percentage bar
if ($total == 0 || $total == '') {
$percentage = 0;
}
else {
$percentage = number_format($total / $goal, 3, '.', ',')*100;
}
$summary = new stdClass;
$summary->end_type = $end_type;
$summary->image_url = $image_url;
$summary->name = $name;
$summary->short_description = $short_desc;
$summary->total = number_format($total, 2, '.', ',');
$summary->goal = number_format($goal, 0, '.', ',');
$summary->show_dates = $show_dates;
if ($show_dates == true) {
$summary->days_left = $dif;
}
$summary->percentage = $percentage;
$summary->currency_code = $cCode;
return $summary;
}
function the_project_content($id) {
$name = get_post_meta($id, 'ign_product_name', true);
$short_desc = html_entity_decode(get_post_meta($id, 'ign_project_description', true));
$long_desc = get_post_meta($id, 'ign_project_long_description', true);
$content = new stdClass;
$content->name = $name;
$content->short_description = $short_desc;
$content->long_description = html_entity_decode($long_desc);
return $content;
}
function the_project_hDeck($id) {
// *payment button, *learn more,
$goal = the_project_goal($id);
$total = get_fund_total($id);
// GETTING product default settings
$default_prod_settings = getProductDefaultSettings();
$end_type = get_post_meta($id, 'ign_end_type', true);
// Getting product settings and if they are not present, set the default settings as product settings
$prod_settings = getProductSettings($id);
if ($prod_settings == -1) {
$prod_settings = $default_prod_settings;
}
$currency_code = $prod_settings->currency_code;
//GETTING the currency symbols
$cCode = setCurrencyCode($currency_code);
// date info
$end_raw = get_post_meta($id, 'ign_fund_end', true);
if ($end_raw !== '') {
$show_dates = true;
$end = str_replace('/', ' ', $end_raw);
$end = explode(' ', $end);
$end_string = $end[2].'-'.$end[0].'-'.$end[1];
$month = $end[0];
$day = $end[1];
$year = $end[2];
$end_date = strtotime($end_string);
$now = time();
// days left
$dif = number_format(($end_date - $now)/86400);
if ($dif < 0) {
$dif = 0;
}
}
else {
$show_dates = false;
}
// percentage bar
if ($total == 0) {
$percentage = 0;
}
else {
$percentage = number_format($total / $goal, 3, '.', ',')*100;
}
$pledges_count = get_backer_total($id);
$button_url = null;
$hDeck = new stdClass;
$hDeck->end_type = $end_type;
$hDeck->goal = number_format($goal, 0, '.', ',');
$hDeck->total = number_format($total, 0, '.', ',');
$hDeck->show_dates = $show_dates;
if ($show_dates == true) {
$hDeck->end = $end_raw;
$hDeck->day = $day;
$hDeck->month = date('F', mktime(0, 0, 0,$month, 10));
$hDeck->year = $year;
$hDeck->days_left = $dif;
}
$hDeck->percentage = $percentage;
$hDeck->pledges = number_format($pledges_count);
$hDeck->currency_code = $cCode;
return $hDeck;
}
function the_project_video($id) {
$video = get_post_meta($id, 'ign_product_video', true);
return html_entity_decode($video);
}
function the_levels($id) {
global $wpdb;
$project_id = get_post_meta($id, 'ign_project_id', true);
$level_count = get_post_meta($id, 'ign_product_level_count', true);
// GETTING product default settings
$default_prod_settings = getProductDefaultSettings();
// Getting product settings and if they are not present, set the default settings as product settings
$prod_settings = getProductSettings($project_id);
if ($prod_settings == -1) {
$prod_settings = $default_prod_settings;
}
$currency_code = $prod_settings->currency_code;
//GETTING the currency symbols
$cCode = setCurrencyCode($currency_code);
$level_data = array();
for ($i=1; $i <= $level_count; $i++) {
$level_sales = $wpdb->prepare('SELECT COUNT(*) as count FROM '.$wpdb->prefix.'ign_pay_info WHERE product_id=%d AND product_level = %d', $project_id, $i);
$return_sales = $wpdb->get_row($level_sales);
$level_sales = $return_sales->count;
if ($i == 1) {
$level_title = html_entity_decode(get_post_meta($id, 'ign_product_title', true));
$level_desc = html_entity_decode(get_post_meta($id, 'ign_product_details', true));
$level_price = get_post_meta($id, 'ign_product_price', true);
if ($level_price > 0) {
$level_price = number_format($level_price, 0, '.', ',');
}
$level_limit = get_post_meta($id, 'ign_product_limit', true);
$level_data[] = array('title' => $level_title,
'description' => $level_desc,
'price' => $level_price,
'sold' => $level_sales,
'limit' => $level_limit,
'currency_code' => $cCode);
}
else {
$level_title = html_entity_decode(get_post_meta($id, 'ign_product_level_'.$i.'_title', true));
$level_desc = html_entity_decode(get_post_meta($id, 'ign_product_level_'.$i.'_desc', true));
$level_price = get_post_meta($id, 'ign_product_level_'.$i.'_price', true);
if ($level_price > 0) {
$level_price = number_format($level_price, 0, '.', ',');
}
$level_limit = get_post_meta($id, 'ign_product_level_'.$i.'_limit', true);
$level_data[] = array('title' => $level_title,
'description' => $level_desc,
'price' => $level_price,
'limit' => $level_limit,
'sold' => $level_sales,
'currency_code' => $cCode);
}
}
return $level_data;
}
function have_projects() {
global $wpdb;
$proj_return = get_ign_projects();
if ($proj_return) {
return true;
}
else {
return false;
}
}
// not in use --
function the_project($id) {
$project_id = get_post_meta($id, 'ign_project_id', true);
$project = get_ign_project($project_id);
$pay_info = get_pay_info($project_id);
$fund_total = array('fund_total' => get_fund_total($pay_info));
$meta = get_post_meta($id);
$the_project = array_merge( $project, $pay_info, $fund_total, $meta);
return $the_project;
}
function get_ign_project($id) {
global $wpdb;
$proj_query = $wpdb->prepare('SELECT * FROM '.$wpdb->prefix.'ign_products WHERE id=%d', absint($id));
$proj_return = $wpdb->get_row($proj_query);
return $proj_return;
}
function get_ign_projects() {
global $wpdb;
$proj_query = 'SELECT * FROM '.$wpdb->prefix.'ign_products';
$proj_return = $wpdb->get_results($proj_query);
return $proj_return;
}
function get_pay_info($id) {
global $wpdb;
$pay_query = $wpdb->prepare('SELECT * FROM '.$wpdb->prefix.'ign_pay_info WHERE product_id=%d', absint($id));
$pay_return = $wpdb->get_results($pay_query);
return $pay_return;
}
function get_fund_total($id) {
$project_id = get_post_meta($id, 'ign_project_id', true);
$pay_info = get_pay_info($project_id);
$total = 0;
foreach ($pay_info as $fund) {
$total = $total + $fund->prod_price;
}
return $total;
}
function get_backer_total($id) {
global $wpdb;
$project_id = get_post_meta($id, 'ign_project_id', true);
$get_pledgers = $wpdb->prepare('SELECT COUNT(*) AS count FROM '.$wpdb->prefix.'ign_pay_info WHERE product_id=%d', $project_id);
$return_pledgers = $wpdb->get_row($get_pledgers);
return $return_pledgers->count;
}
function the_project_image($id, $num) {
$num = 'ign_product_image'.$num;
$image = get_post_meta($id, $num, true);
return $image;
}
function the_project_goal($id) {
global $wpdb;
$project_id = get_post_meta($id, 'ign_project_id', true);
$goal_query = $wpdb->prepare('SELECT goal FROM '.$wpdb->prefix.'ign_products WHERE id=%d', $project_id);
$goal_return = $wpdb->get_row($goal_query);
return $goal_return->goal;
}
function fh_fa_shortcodes($attrs) {
if (isset($attrs)) {
$icon = $attrs['type'];
if (isset($attrs['size'])) {
$size = $attrs['size'];
}
else {
$size = '';
}
$output = ' ';
}
else {
$output = '';
}
return $output;
}
add_shortcode('icon', 'fh_fa_shortcodes');
// This is below
add_action('after_setup_theme', 'fivehundred_setup');
function fivehundred_setup(){
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'menus' );
register_nav_menus(
array(
'main-menu' => __( 'Main Menu', 'fivehundred' ),
'footer-menu' => __( 'Footer Menu', 'fivehundred' )
)
);
}
// Image Sizes added and Allowing to select those image sizes in Media Insert Admin
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'projectpage-large', 640, 9999 ); // For Project Pages with Unlimited Height allowed
add_image_size( 'single-thumb', 700, 105, true ); // For Single Posts (cropped)
}
add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );
function custom_image_sizes_choose( $sizes ) {
$custom_sizes = array(
'projectpage-large' => 'Project Page Full Width',
'single-thumb' => 'Single Post Thumb'
);
return array_merge( $sizes, $custom_sizes );
}
// for custom comments
if ( ! function_exists( 'fivehundred_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own fivehundred_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
*/
function fivehundred_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
// Display trackbacks differently than normal comments.
?>
id="comment-">
', '' ); ?>
id="li-comment-">
__('Sidebar Widget Area', 'fivehundred'),
'id' => 'primary-widget-area',
'before_widget' => '',
'after_widget' => "",
'before_title' => '',
) );
register_sidebar( array (
'name' => __('Projects Sidebar Area', 'fivehundred'),
'id' => 'projects-widget-area',
'before_widget' => '',
'after_widget' => "",
'before_title' => '',
'description' => __( 'This sidebar is located below the Levels on each Project page.', 'fivehundred' ),
) );
register_sidebar( array (
'name' => __('Home Sidebar Area', 'fivehundred'),
'id' => 'home-widget-area',
'before_widget' => '',
'after_widget' => "",
'before_title' => '',
'description' => __( 'This sidebar is located on the Home Page, to the right of About Us', 'fivehundred' ),
) );
}
$preset_widgets = array (
'primary-aside' => array( 'search', 'pages', 'categories', 'archives' ),
);
function widont($str = '')
{
$str = rtrim($str);
$space = strrpos($str, ' ');
if ($space !== false)
{
$str = substr($str, 0, $space).' '.substr($str, $space + 1);
}
return $str;
}
add_filter('the_title', 'widont');
function fivehundred_admin_notice(){
if (!is_plugin_active('ignitiondeck/ignitiondeck.php')) {
echo '';
}
}
add_action('admin_notices', 'fivehundred_admin_notice');
/**
Required by WordPress
**/
add_theme_support( 'automatic-feed-links' );
if ( ! isset( $content_width ) ) $content_width = 960
?>