function wck_fep_dashboard() { /* set the static var to true */ self::$wck_fep_dashboard_add_scripts = true; if (!is_user_logged_in()) { return wck_fep_output_lilo_form(); } $user_id = get_current_user_id(); /* get post types */ $args = array('public' => true); $output = 'objects'; // or objects $post_types = get_post_types($args, $output); $dashboard = ""; $dashboard .= '<div id="fep-dashboard">'; $dashboard .= '<ul id="wck-fep-tabs">'; $dashboard .= apply_filters('wck_fep_dashboard_profile_tab', '<li><a href="#wck-fep-update-form">' . __('My Profile', 'wck') . '</a></li>'); if (!empty($post_types)) { foreach ($post_types as $post_type) { if ($post_type->name != 'attachment' && $post_type->name != 'wck-meta-box' && $post_type->name != 'wck-frontend-posting' && $post_type->name != 'wck-option-page' && $post_type->name != 'wck-option-field') { $args = array('numberposts' => -1, 'author' => $user_id, 'post_type' => $post_type->name); $posts = get_posts(apply_filters('wck_fep_dashbord_get_posts_args', $args)); if (!empty($posts)) { $dashboard .= '<li><a href="#fep-' . $post_type->name . '">' . __('My ', 'wck') . $post_type->label . '</a></li>'; } } } } $dashboard .= '</ul>'; $dashboard .= wck_fep_output_user_profile(); if (!empty($post_types)) { foreach ($post_types as $post_type) { if ($post_type->name != 'attachment' && $post_type->name != 'wck-meta-box' && $post_type->name != 'wck-frontend-posting') { $args = array('numberposts' => -1, 'author' => $user_id, 'post_type' => $post_type->name); $posts = get_posts(apply_filters('wck_fep_dashbord_get_posts_args', $args)); if (!empty($posts)) { $dashboard .= '<div id="fep-' . $post_type->name . '">'; $dashboard .= '<h3 class="fep-' . $post_type->name . '">' . __('My ', 'wck') . $post_type->label . '</h3>'; $dashboard .= '<ul id="fep-' . $post_type->name . '">'; foreach ($posts as $post) { /* build edit link */ $args = array('post_type' => 'wck-frontend-posting', 'numberposts' => -1); $all_forms = get_posts($args); $shortcode_page_id = ''; $edit_link = ''; if (!empty($all_forms)) { foreach ($all_forms as $form) { $wck_fep_args = get_post_meta($form->ID, 'wck_fep_args', true); if (!empty($wck_fep_args)) { if ($wck_fep_args[0]['post-type'] == $post_type->name) { if (isset($wck_fep_args[0]['shortcode-page'])) { $shortcode_page_id = $wck_fep_args[0]['shortcode-page']; break; } } } } } if (!empty($shortcode_page_id)) { $arr_params = array('action' => 'edit', 'post_id' => $post->ID); $edit_link = add_query_arg($arr_params, get_permalink($shortcode_page_id)); } $dashboard .= '<li id="' . $post->ID . '"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a>'; if (!empty($edit_link)) { $dashboard .= ' <a class="wck-edit-post" href="' . $edit_link . '">' . __('Edit', 'wck') . '</a> '; } $delete_nonce = wp_create_nonce('wck-fep-delete-entry'); $dashboard .= ' <a class="wck-delete-post" href="javascript:void(0)" onclick="wckFepDeletePost(\'' . $post->ID . '\', \'' . $delete_nonce . '\')">' . __('Delete', 'wck') . '</a> </li>'; } $dashboard .= '</ul></div>'; } } } } $dashboard .= '</div>'; return $dashboard; }
/** * Shortcode Function */ static function handle_shortcode($atts) { self::$add_script = true; /* output login logout form */ $lilo_form = wck_fep_output_lilo_form(); return $lilo_form; }