示例#1
2
文件: tour.php 项目: rhurling/lasso
 /**
  * When the user decides to not have this show again save user meta to make it so.
  *
  * @param array $data Sanitized data to use for saving.
  *
  * @returns bool Always returns true
  */
 public function hide($data)
 {
     $user_id = get_current_user_ID();
     update_user_meta($user_id, 'lasso_hide_tour', true);
     do_action('lasso_tour_hidden', $user_id);
     return true;
 }
示例#2
0
 /**
  * Stores user's preference to hide the submit message via AJAX
  */
 function hide()
 {
     check_ajax_referer($this->parent->slug_ . '_hide_submit', '_ajax_nonce-' . $this->parent->slug . '-hide-submit');
     //note: option will be global
     update_user_option(get_current_user_ID(), 'infinite-scroll-hide-submit', true, true);
     die(1);
 }
示例#3
0
 /**
  * Creates a gallery
  *
  * @since 0.9.2
  *
  * @param array $data Sanitized data to use for saving.
  *
  * @return array|bool On success an array containing "message" or on failure false.
  */
 public function create($data)
 {
     //@todo adapt auth callbacks to work with args.
     if (!lasso_user_can('publish_posts')) {
         return false;
     }
     $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false;
     // bail if no gallery ids
     if (empty($gallery_ids)) {
         return false;
     }
     $postid = isset($data['postid']) ? (int) $data['postid'] : false;
     $type = isset($data['gallery_type']) ? $data['gallery_type'] : false;
     // insert a new gallery
     $args = array('post_title' => $postid . '-' . rand(), 'post_status' => 'publish', 'post_type' => 'ai_galleries');
     $postid = wp_insert_post(apply_filters('lasso_insert_gallery_args', $args));
     // update gallery ids
     if ($gallery_ids) {
         update_post_meta($postid, '_ase_gallery_images', $gallery_ids);
     }
     // update the gallery type
     if (!empty($type)) {
         update_post_meta($postid, 'aesop_gallery_type', $type);
     }
     do_action('lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID());
     return array('message' => 'gallery-created');
 }
示例#4
0
 /**
  *  Delete the post thumbnail when deleted from front end
  *
  * @since 0.1
  *
  * @param array $data Sanitized data to use for saving.
  *
  * @return bool Always returns true.
  */
 public function delete($data)
 {
     $postid = isset($data['postid']) ? $data['postid'] : false;
     delete_post_thumbnail($postid);
     do_action('lasso_featured_image_deleted', $postid, get_current_user_ID());
     return true;
 }
示例#5
0
 /**
  * Process title update
  *
  * @since 0.9.2
  *
  * @param array $data Sanitized data to use for saving.
  *
  * @return bool Always returns true.
  */
 public function post($data)
 {
     $postid = isset($data['postid']) ? $data['postid'] : false;
     $title = isset($data['title']) ? $data['title'] : false;
     $args = array('ID' => (int) $postid, 'post_title' => wp_strip_all_tags($title));
     wp_update_post(apply_filters('lasso_title_updated_args', $args));
     do_action('lasso_title_updated', $postid, $title, get_current_user_ID());
     return true;
 }
示例#6
0
 /**
  * Process the post object
  *
  * @params array $data Sanitized data to use for saving.
  *
  * @since 1.0
  */
 public function post($data)
 {
     $title = $data['story_title'];
     $object = is_null($data['object']) ? false : $data['object'];
     // insert a new post
     $args = array('post_title' => $title, 'post_status' => 'draft', 'post_type' => $object, 'post_content' => apply_filters('lasso_new_object_content', __('Once upon a time...', 'lasso')));
     $postid = wp_insert_post(apply_filters('lasso_insert_object_args', $args));
     do_action('lasso_new_object', $postid, $object, $title, get_current_user_ID());
     return array('postlink' => get_permalink($postid));
 }
示例#7
0
文件: delete.php 项目: rhurling/lasso
 /**
  * Process the post delete
  *
  * @since 1.0
  */
 public function post($data)
 {
     $postid = isset($data['postid']) ? $data['postid'] : false;
     // bail out if teh current user can't publish posts
     if (!lasso_user_can('delete_post', $postid)) {
         return;
     }
     $args = array('ID' => (int) $postid, 'post_status' => 'trash');
     wp_update_post(apply_filters('lasso_object_deleted_args', $args));
     do_action('lasso_object_deleted', $postid, get_current_user_ID());
     return true;
 }
示例#8
0
文件: save.php 项目: rhurling/lasso
 /**
  * Process the post save
  *
  * @since 0.9.2
  *
  * @param array $data Sanitized data to use for saving.
  *
  * @return bool Always returns true.
  */
 public function publish_content($data)
 {
     $save_to_post_disabled = $this->save_to_post_disables();
     $postid = (int) $data['post_id'];
     $content = $data['content'];
     if ('off' == $save_to_post_disabled || empty($save_to_post_disabled)) {
         $args = array('ID' => $postid, 'post_content' => $content, 'post_status' => 'publish');
         wp_update_post(apply_filters('lasso_object_publish_args', $args));
     }
     do_action('lasso_post_published', $postid, $content, get_current_user_ID());
     return true;
 }
示例#9
0
 /**
  * Process the post update
  *
  * @since 0.9.2
  *
  * @param array $data Sanitized data to use for saving.
  *
  * @return bool Always returns true.
  */
 public function post($data)
 {
     $status = isset($data['status']) ? $data['status'] : false;
     $postid = isset($data['postid']) ? $data['postid'] : false;
     $slug = isset($data['story_slug']) ? $data['story_slug'] : false;
     $args = array('ID' => (int) $postid, 'post_name' => $slug, 'post_status' => $status);
     wp_update_post(apply_filters('lasso_object_status_update_args', $args));
     // update categories
     $cats = isset($data['story_cats']) ? $data['story_cats'] : false;
     self::set_post_terms($postid, $cats, 'category');
     // update tags
     $tags = isset($data['story_tags']) ? $data['story_tags'] : false;
     self::set_post_terms($postid, $tags, 'post_tag');
     do_action('lasso_post_updated', $postid, $slug, $status, get_current_user_ID());
     return true;
 }
 /**
  *
  *	Process the form submission
  *
  */
 function process_vote_down()
 {
     check_ajax_referer('idea_factory', 'nonce');
     if (isset($_POST['post_id'])) {
         $postid = $_POST['post_id'];
         // get vote statuses
         $has_public_voted = idea_factory_has_public_voted($postid);
         $has_private_voted = idea_factory_has_private_voted($postid);
         // get votes
         $votes = get_post_meta($postid, '_idea_votes', true);
         $total_votes = get_post_meta($postid, '_idea_total_votes', true);
         // public voting enabled
         $public_can_vote = idea_factory_get_option('if_public_voting', 'if_settings_main');
         if (is_user_logged_in()) {
             $userid = get_current_user_ID();
         } elseif (!is_user_logged_in() && $public_can_vote) {
             $userid = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 0;
         }
         // if the public can vote and the user has already voted or they are logged in and have already voted then bail out
         if ($public_can_vote && $has_public_voted || $has_private_voted) {
             echo 'already-voted';
             die;
         }
         // increase votes
         update_post_meta($postid, '_idea_votes', intval($votes) - 1);
         update_post_meta($postid, '_idea_total_votes', intval($total_votes) + 1);
         // update user meta so they can't vote on this again
         if (!is_user_logged_in() && $public_can_vote) {
             $args = array('postid' => $postid);
             idea_factory_add_public_vote($args);
         } elseif (is_user_logged_in()) {
             // update user meta so they can't vote on this again
             update_user_meta($userid, '_idea' . $postid . '_has_voted', true);
         }
         do_action('idea_factory_vote_down', $postid, $userid);
         echo 'success';
     }
     die;
 }
 /**
  *
  *	Process the form submission
  *
  */
 function process_entry()
 {
     $public_can_vote = idea_factory_get_option('if_public_voting', 'if_settings_main');
     $title = isset($_POST['idea-title']) ? $_POST['idea-title'] : null;
     $desc = isset($_POST['idea-description']) ? $_POST['idea-description'] : null;
     $must_approve = 'on' == idea_factory_get_option('if_approve_ideas', 'if_settings_main') ? 'pending' : 'publish';
     if (isset($_POST['action']) && $_POST['action'] == 'process_entry') {
         // only run for logged in users or if public is allowed
         if (!is_user_logged_in() && 'on' !== $public_can_vote) {
             return;
         }
         // ok security passes so let's process some data
         if (wp_verify_nonce($_POST['nonce'], 'if-entry-nonce')) {
             // bail if we dont have rquired fields
             if (empty($title) || empty($desc)) {
                 printf('<div class="error">%s</div>', __('Whoopsy! Looks like you forgot the Title and/or description.', 'idea-factory'));
             } else {
                 if (is_user_logged_in()) {
                     $userid = get_current_user_ID();
                 } elseif (!is_user_logged_in() && $public_can_vote) {
                     $userid = apply_filters('idea_factory_default_public_author', 1);
                 }
                 // create an ideas post type
                 $post_args = array('post_title' => wp_strip_all_tags($title), 'post_content' => idea_factory_media_filter($desc), 'post_status' => $must_approve, 'post_type' => 'ideas', 'post_author' => (int) $userid);
                 $entry_id = wp_insert_post($post_args);
                 update_post_meta($entry_id, '_idea_votes', 0);
                 update_post_meta($entry_id, '_idea_total_votes', 0);
                 do_action('idea_factory_entry_submitted', $entry_id, $userid);
                 _e('Thanks for your entry!', 'idea-factory');
                 if ($must_approve == 'pending') {
                     echo "<br/>";
                     _e('You suggestion is awaiting moderation.', 'idea-factory');
                 }
             }
         }
     }
     exit;
     // ajax
 }
示例#12
0
文件: assets.php 项目: rhurling/lasso
 public function scripts()
 {
     if (lasso_user_can('edit_posts')) {
         wp_enqueue_style('lasso-style', LASSO_URL . '/public/assets/css/lasso.css', LASSO_VERSION, true);
         wp_enqueue_script('jquery-ui-autocomplete');
         wp_enqueue_script('jquery-ui-draggable');
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_script('jquery-ui-slider');
         // media uploader
         wp_enqueue_media();
         // url for json api
         $home_url = function_exists('json_get_url_prefix') ? json_get_url_prefix() : false;
         $article_object = lasso_editor_get_option('article_class', 'lasso_editor');
         $article_object = empty($article_object) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object;
         $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor');
         $titleClass = lasso_editor_get_option('title_class', 'lasso_editor');
         $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor');
         $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor');
         // post id reference
         $postid = get_the_ID();
         $strings = array('save' => __('Save', 'lasso'), 'saving' => __('Saving...', 'lasso'), 'saved' => __('Saved!', 'lasso'), 'adding' => __('Adding...', 'lasso'), 'added' => __('Added!', 'lasso'), 'loading' => __('Loading...', 'lasso'), 'loadMore' => __('Load More', 'lasso'), 'noPostsFound' => __('No more posts found', 'lasso'), 'galleryCreated' => __('Gallery Created!', 'lasso'), 'galleryUpdated' => __('Gallery Updated!', 'lasso'), 'justWrite' => __('Just write...', 'lasso'), 'chooseImage' => __('Choose an image', 'lasso'), 'updateImage' => __('Update Image', 'lasso'), 'insertImage' => __('Insert Image', 'lasso'), 'selectImage' => __('Select Image', 'lasso'), 'removeFeatImg' => __('Remove featured image?', 'lasso'), 'updateSelectedImg' => __('Update Selected Image', 'lasso'), 'chooseImages' => __('Choose images', 'lasso'), 'editImage' => __('Edit Image', 'lasso'), 'addImages' => __('Add Images', 'lasso'), 'addNewGallery' => __('Add New Gallery', 'lasso'), 'selectGallery' => __('Select Lasso Gallery Image', 'lasso'), 'useSelectedImages' => __('Use Selected Images', 'lasso'), 'publishPost' => __('Publish Post?', 'lasso'), 'publishYes' => __('Yes, publish it!', 'lasso'), 'deletePost' => __('Trash Post?', 'lasso'), 'deleteYes' => __('Yes, trash it!', 'lasso'), 'warning' => __('Oh snap!', 'laso'), 'cancelText' => __('O.K. got it!', 'lasso'), 'missingClass' => __('It looks like we are missing the Article CSS class. Lasso will not function correctly without this CSS class.', 'lasso'), 'missingConfirm' => __('Update Settings', 'lasso'), 'helperText' => __('one more letter', 'lasso'), 'editingBackup' => __('You are currently editing a backup copy of this post.'));
         $api_url = trailingslashit(home_url()) . 'lasso-internal-api';
         $gallery_class = new gallery();
         $gallery_nonce_action = $gallery_class->nonce_action;
         $gallery_nonce = wp_create_nonce($gallery_nonce_action);
         // localized objects
         $objects = array('ajaxurl' => esc_url($api_url), 'editor' => 'lasso--content', 'article_object' => $article_object, 'featImgClass' => $featImgClass, 'titleClass' => $titleClass, 'strings' => $strings, 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url('settings.php?page=lasso-editor') : admin_url('admin.php?page=lasso-editor-settings'), 'post_status' => get_post_status($postid), 'postid' => $postid, 'permalink' => get_permalink(), 'edit_others_pages' => current_user_can('edit_others_pages') ? 'true' : 'false', 'edit_others_posts' => current_user_can('edit_others_posts') ? 'true' : 'false', 'userCanEdit' => current_user_can('edit_post', $postid), 'can_publish_posts' => current_user_can('publish_posts'), 'can_publish_pages' => current_user_can('publish_pages'), 'author' => is_user_logged_in() ? get_current_user_ID() : false, 'nonce' => wp_create_nonce('lasso_editor'), 'handle' => lasso_editor_settings_toolbar(), 'toolbar' => lasso_editor_text_toolbar(), 'toolbarHeadings' => $toolbar_headings, 'component_modal' => lasso_editor_component_modal(), 'component_sidebar' => lasso_editor_component_sidebar(), 'components' => lasso_editor_components(), 'wpImgEdit' => lasso_editor_wpimg_edit(), 'featImgControls' => lasso_editor_image_controls(), 'featImgNonce' => $gallery_nonce, 'getGallImgNonce' => $gallery_nonce, 'createGallNonce' => $gallery_nonce, 'swapGallNonce' => $gallery_nonce, 'titleNonce' => wp_create_nonce('lasso_update_title'), 'wpImgNonce' => wp_create_nonce('lasso_update_wpimg'), 'deletePost' => wp_create_nonce('lasso_delete_post'), 'searchPosts' => wp_create_nonce('lasso_search_posts'), 'component_options' => lasso_editor_options_blob(), 'newPostModal' => lasso_editor_newpost_modal(), 'allPostModal' => lasso_editor_allpost_modal(), 'mapFormFooter' => lasso_map_form_footer(), 'refreshRequired' => lasso_editor_refresh_message(), 'objectsNoSave' => $objectsNoSave, 'supportedNoSave' => lasso_supported_no_save(), 'postCategories' => lasso_get_objects('category'), 'postTags' => lasso_get_objects('tag'), 'noResultsDiv' => lasso_editor_empty_results(), 'noRevisionsDiv' => lasso_editor_empty_results('revision'), 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider($postid) : false, 'mapLocations' => get_post_meta($postid, 'ase_map_component_locations'), 'mapStart' => get_post_meta($postid, 'ase_map_component_start_point', true), 'mapZoom' => get_post_meta($postid, 'ase_map_component_zoom', true), 'revisionModal' => lasso_editor_revision_modal());
         // wp api client
         wp_enqueue_script('wp-api-js', LASSO_URL . '/public/assets/js/source/util--wp-api.js', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true);
         $settings = array('root' => home_url($home_url), 'nonce' => wp_create_nonce('wp_json'));
         wp_localize_script('wp-api-js', 'WP_API_Settings', $settings);
         $postfix = defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_script('lasso', LASSO_URL . "/public/assets/js/lasso{$postfix}.js", array('jquery'), LASSO_VERSION, true);
         wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects));
     }
 }
													<option value="<?php 
            echo $course->ID;
            ?>
" <?php 
            selected($meta_course_id, $course->ID);
            ?>
><?php 
            echo $course->post_title;
            ?>
</option>
													<?php 
            $available_course_options++;
        }
    } else {
        //check for update capabilities
        if (current_user_can('manage_options') || current_user_can('coursepress_update_notification_cap') || current_user_can('coursepress_update_my_notification_cap') && $notification_details->post_author == get_current_user_ID()) {
            ?>
													<option value="<?php 
            echo $course->ID;
            ?>
" <?php 
            selected($meta_course_id, $course->ID);
            ?>
><?php 
            echo $course->post_title;
            ?>
</option>
													<?php 
            $available_course_options++;
        }
    }
 /**
  *
  *	Process the form submission
  *
  */
 function process_entry()
 {
     $public_can_vote = avfr_get_option('avfr_public_voting', 'avfr_settings_main');
     $allowed_type = explode(",", avfr_get_option('avfr_allowed_file_types', 'avfr_settings_features'));
     $allowed_size = avfr_get_option('avfr_max_file_size', 'avfr_settings_features');
     $title = isset($_POST['avfr-title']) ? $_POST['avfr-title'] : null;
     $desc = isset($_POST['avfr-description']) ? $_POST['avfr-description'] : null;
     $uploadajx = isset($_POST['avfr-upload']) ? $_POST['avfr-upload'] : null;
     $uploadOk = 1;
     $must_approve = '1' == avfr_get_option('avfr_approve_features', 'avfr_settings_main') ? 'pending' : 'publish';
     session_start();
     if (isset($_POST['action']) && $_POST['action'] == 'process_entry') {
         // only run for logged in users or if public is allowed
         if (!is_user_logged_in() && 'on' !== $public_can_vote) {
             return;
         }
         // OK security passes so let's process some data
         if (wp_verify_nonce($_POST['nonce'], 'avfr-entry-nonce')) {
             // bail if we don't have required fields
             if (empty($title) || empty($desc)) {
                 printf('<div class="error">%s</div>', __('Whoops! Looks like you forgot the Title and/or description.', 'feature-request'));
             } else {
                 if ('on' == avfr_get_option('avfr_disable_captcha', 'avfr_settings_main') || isset($_POST["captcha"]) && $_POST["captcha"] != "" && $_SESSION["code"] == $_POST["captcha"]) {
                     if (is_user_logged_in()) {
                         $userid = get_current_user_ID();
                     } elseif (!is_user_logged_in() && $public_can_vote) {
                         $userid = apply_filters('avfr_default_public_author', 1);
                     }
                     //get array of inserted tags in front-end
                     $tags = str_replace(array('[', ']', '"', '\\'), '', $_POST['avfr-tags']);
                     $groups = $_POST['group'];
                     $tags_array = explode(',', $tags);
                     // create an feature-request post type
                     $post_args = array('post_title' => wp_strip_all_tags($title), 'post_content' => avfr_content_filter($desc), 'the_post_thumbnail' => avfr_image_filter($uploadajx), 'post_status' => $must_approve, 'post_type' => 'avfr', 'post_author' => (int) $userid);
                     if (!is_user_logged_in()) {
                         $email = $_POST['avfr-email'];
                         if (!is_email($email)) {
                             $response_array = array('success' => 'false', 'message' => __('<span class="dashicons dashicons-warning"></span>' . 'Please enter a valid email address.', 'feature-request'));
                             echo json_encode($response_array);
                             die;
                         }
                     }
                     if ($_FILES) {
                         $convert_byte_kb = $allowed_size * 1024;
                         if ($_FILES["avfr-upload"]["size"] > $convert_byte_kb) {
                             $response_array = array('success' => 'false', 'message' => __('<span class="dashicons dashicons-warning"></span>' . ' Your image size is greater than acceptable !', 'feature-request'));
                             echo json_encode($response_array);
                             die;
                         }
                         if (in_array($_FILES["avfr-upload"]["type"], $allowed_type)) {
                             //continue
                         } else {
                             $response_array = array('success' => 'false', 'message' => __('<span class="dashicons dashicons-warning"></span>' . ' Please upload acceptable image format !', 'feature-request'));
                             echo json_encode($response_array);
                             die;
                         }
                         if ($_FILES['avfr-upload']['error'] !== UPLOAD_ERR_OK) {
                             $response_array = array('success' => 'false', 'message' => __('<span class="dashicons dashicons-dismiss"></span>' . ' upload error :' . $_FILES['avfr-upload']['error'], 'feature-request'));
                             echo json_encode($response_array);
                             die;
                         } else {
                             $entry_id = wp_insert_post($post_args);
                             $attach_id = media_handle_upload('avfr-upload', $entry_id);
                             update_post_meta($entry_id, '_thumbnail_id', $attach_id);
                         }
                     } else {
                         $entry_id = wp_insert_post($post_args);
                     }
                     $entry_groups = wp_set_object_terms($entry_id, $groups, 'groups');
                     $entry_avfrtags = wp_set_object_terms($entry_id, $tags_array, 'featureTags');
                     update_post_meta($entry_id, '_avfr_votes', 0);
                     update_post_meta($entry_id, '_avfr_total_votes', 0);
                     update_post_meta($entry_id, '_avfr_status', 'open');
                     update_post_meta($entry_id, '_flag', 0);
                     if (!is_user_logged_in()) {
                         update_post_meta($entry_id, '_avfr_author_email', $email);
                     }
                     do_action('avfr_entry_submitted', $entry_id, $userid);
                     $response_array = array('success' => 'true', 'message' => __('<span class="dashicons dashicons-yes"></span>' . ' Thanks for your entry!', 'feature-request'));
                     echo json_encode($response_array);
                     if ($must_approve == 'pending') {
                         echo "<br/>";
                         $response_array = array('success' => 'true', 'message' => __('<span class="dashicons dashicons-flag"></span>' . ' You suggestion is awaiting moderation.', 'feature-request'));
                         echo json_encode($response_array);
                     }
                 } else {
                     $response_array = array('success' => 'false', 'message' => __('<span class="dashicons dashicons-warning"></span>' . ' Captcha code is not correct!', 'feature-request'));
                     echo json_encode($response_array);
                 }
             }
         }
     }
     exit;
     // Ajax
 }
        function student_workbook_table($args)
        {
            ob_start();
            extract(shortcode_atts(array('module_column_title' => __('Element', 'cp'), 'title_column_title' => __('Title', 'cp'), 'submission_date_column_title' => __('Submitted', 'cp'), 'response_column_title' => __('Answer', 'cp'), 'grade_column_title' => __('Grade', 'cp'), 'comment_column_title' => __('Comment', 'cp'), 'module_response_description_label' => __('Description', 'cp'), 'comment_label' => __('Comment', 'cp'), 'view_link_label' => __('View', 'cp'), 'view_link_class' => 'assessment-view-response-link button button-units', 'comment_link_class' => 'assessment-view-response-link button button-units', 'pending_grade_label' => __('Pending', 'cp'), 'unit_unread_label' => __('Unit Unread', 'cp'), 'unit_read_label' => __('Unit Read', 'cp'), 'single_correct_label' => __('Correct', 'cp'), 'single_incorrect_label' => __('Incorrect', 'cp'), 'non_assessable_label' => __('**'), 'table_class' => 'widefat shadow-table assessment-archive-table', 'table_labels_th_class' => 'manage-column'), $args));
            $module_column_title = sanitize_text_field($module_column_title);
            $title_column_title = sanitize_text_field($title_column_title);
            $submission_date_column_title = sanitize_text_field($submission_date_column_title);
            $response_column_title = sanitize_text_field($response_column_title);
            $grade_column_title = sanitize_text_field($grade_column_title);
            $comment_column_title = sanitize_text_field($comment_column_title);
            $module_response_description_label = sanitize_text_field($module_response_description_label);
            $comment_label = sanitize_text_field($comment_label);
            $view_link_label = sanitize_text_field($view_link_label);
            $view_link_class = sanitize_html_class($view_link_class);
            $comment_link_class = sanitize_html_class($comment_link_class);
            $pending_grade_label = sanitize_text_field($pending_grade_label);
            $unit_unread_label = sanitize_text_field($unit_unread_label);
            $unit_read_label = sanitize_text_field($unit_read_label);
            $non_assessable_label = sanitize_text_field($non_assessable_label);
            $table_class = sanitize_html_class($table_class);
            $table_labels_th_class = sanitize_html_class($table_labels_th_class);
            $single_correct_label = sanitize_text_field($single_correct_label);
            $single_incorrect_label = sanitize_text_field($single_incorrect_label);
            $columns = array("title" => $title_column_title, "submission_date" => $submission_date_column_title, "response" => $response_column_title, "grade" => $grade_column_title, "comment" => $comment_column_title);
            $col_sizes = array('45', '15', '10', '13', '5');
            ?>
			<table cellspacing="0" class="<?php 
            echo $table_class;
            ?>
">
				<thead>
					<tr>
						<?php 
            $n = 0;
            foreach ($columns as $key => $col) {
                ?>
							<th class="<?php 
                echo $table_labels_th_class;
                ?>
 column-<?php 
                echo $key;
                ?>
" width="<?php 
                echo $col_sizes[$n] . '%';
                ?>
" id="<?php 
                echo $key;
                ?>
" scope="col"><?php 
                echo $col;
                ?>
</th>
							<?php 
                $n++;
            }
            ?>
					</tr>
				</thead>

				<?php 
            $user_object = new Student(get_current_user_ID());
            $modules = Unit_Module::get_modules(get_the_ID());
            $input_modules_count = 0;
            foreach ($modules as $mod) {
                $class_name = $mod->module_type;
                if (class_exists($class_name)) {
                    if (constant($class_name . '::FRONT_SAVE')) {
                        $input_modules_count++;
                    }
                }
            }
            $current_row = 0;
            $style = '';
            foreach ($modules as $mod) {
                $class_name = $mod->module_type;
                if (class_exists($class_name)) {
                    if (constant($class_name . '::FRONT_SAVE')) {
                        $response = call_user_func($class_name . '::get_response', $user_object->ID, $mod->ID);
                        $visibility_class = count($response) >= 1 ? '' : 'less_visible_row';
                        if (count($response) >= 1) {
                            $grade_data = Unit_Module::get_response_grade($response->ID);
                        }
                        if (isset($_GET['ungraded']) && $_GET['ungraded'] == 'yes') {
                            if (count($response) >= 1 && !$grade_data) {
                                $general_col_visibility = true;
                            } else {
                                $general_col_visibility = false;
                            }
                        } else {
                            $general_col_visibility = true;
                        }
                        $style = isset($style) && 'alternate' == $style ? '' : ' alternate';
                        ?>
							<tr id='user-<?php 
                        echo $user_object->ID;
                        ?>
' class="<?php 
                        echo $style;
                        echo 'row-' . $current_row;
                        ?>
">

								<?php 
                        if ($general_col_visibility) {
                            ?>

									<td class="<?php 
                            echo $style . ' ' . $visibility_class;
                            ?>
">
										<?php 
                            echo $mod->post_title;
                            ?>
									</td>

									<td class="<?php 
                            echo $style . ' ' . $visibility_class;
                            ?>
">
										<?php 
                            echo count($response) >= 1 ? date_i18n('M d, Y', strtotime($response->post_date)) : __('Not submitted', 'cp');
                            ?>
									</td>

									<td class="<?php 
                            echo $style . ' ' . $visibility_class;
                            ?>
">
										<?php 
                            if (count($response) >= 1) {
                                ?>
											<div id="response_<?php 
                                echo $response->ID;
                                ?>
" style="display:none;">
												<?php 
                                if (isset($mod->post_content) && $mod->post_content !== '') {
                                    ?>
													<div class="module_response_description">
														<label><?php 
                                    echo $module_response_description_label;
                                    ?>
</label>
														<?php 
                                    echo $mod->post_content;
                                    ?>
													</div>
												<?php 
                                }
                                ?>
												<?php 
                                echo call_user_func($class_name . '::get_response_form', get_current_user_ID(), $mod->ID);
                                ?>

												<?php 
                                if (is_object($response) && !empty($response)) {
                                    $comment = Unit_Module::get_response_comment($response->ID);
                                    if (!empty($comment)) {
                                        ?>
														<label class="comment_label"><?php 
                                        echo $comment_label;
                                        ?>
</label>
														<div class="response_comment_front"><?php 
                                        echo $comment;
                                        ?>
</div>
													<?php 
                                    }
                                }
                                ?>
											</div>

											<a class="<?php 
                                echo sanitize_html_class($view_link_class);
                                ?>
 thickbox" href="#TB_inline?width=500&height=300&inlineId=response_<?php 
                                echo $response->ID;
                                ?>
"><?php 
                                echo sanitize_html_class($view_link_label);
                                ?>
</a>

										<?php 
                            } else {
                                echo '-';
                            }
                            ?>
									</td>

									<td class="<?php 
                            echo $style . ' ' . $visibility_class;
                            ?>
">
										<?php 
                            if (isset($grade_data)) {
                                $grade = $grade_data['grade'];
                                $instructor_id = $grade_data['instructor'];
                                $instructor_name = get_userdata($instructor_id);
                                $grade_time = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $grade_data['time']);
                            }
                            if (count($response) >= 1) {
                                if (isset($grade_data)) {
                                    if (get_post_meta($mod->ID, 'gradable_answer', true) == 'no') {
                                        echo $non_assessable_label;
                                    } else {
                                        if ('radio_input_module' == $class_name) {
                                            if (100 == $grade) {
                                                echo $single_correct_label;
                                            } else {
                                                echo $single_incorrect_label;
                                            }
                                        } else {
                                            echo $grade . '%';
                                        }
                                    }
                                } else {
                                    if (get_post_meta($mod->ID, 'gradable_answer', true) == 'no') {
                                        echo $non_assessable_label;
                                    } else {
                                        echo $pending_grade_label;
                                    }
                                }
                            } else {
                                echo '-';
                            }
                            ?>
									</td>

									<td class="<?php 
                            echo $style . ' ' . $visibility_class;
                            ?>
 td-center">
										<?php 
                            if (!empty($response)) {
                                $comment = Unit_Module::get_response_comment($response->ID);
                                if (!empty($comment)) {
                                    ?>
												<a alt="<?php 
                                    echo strip_tags($comment);
                                    ?>
" title="<?php 
                                    echo strip_tags($comment);
                                    ?>
" class="<?php 
                                    echo $comment_link_class;
                                    ?>
 thickbox" href="#TB_inline?width=500&height=300&inlineId=response_<?php 
                                    echo $response->ID;
                                    ?>
"><i class="fa fa-comment"></i></a>
											<?php 
                                }
                            } else {
                                echo '<i class="fa fa-comment-o"></i>';
                            }
                            ?>
									</td>
								<?php 
                        }
                        //general col visibility
                        ?>
							</tr>
							<?php 
                        $current_row++;
                    }
                }
            }
            if (!isset($input_modules_count) || isset($input_modules_count) && $input_modules_count == 0) {
                ?>
					<tr>
						<td colspan="7">
							<?php 
                $unit_grade = do_shortcode('[course_unit_details field="student_unit_grade" unit_id="' . get_the_ID() . '"]');
                _e('0 input elements in the selected unit.', 'cp');
                ?>
							<?php 
                if ($unit_grade == 0) {
                    echo $unit_unread_label;
                } else {
                    echo $unit_read_label;
                }
                ?>
						</td>
					</tr>
				<?php 
            }
            ?>
				<?php 
            if (0 < $current_row) {
                ?>
					<tfoot><tr><td colspan="6">** <?php 
                _e('Non-assessable elements.', 'cp');
                ?>
</td></tr></tfoot>
				<?php 
            }
            ?>
			</table>
			<?php 
            $content = ob_get_clean();
            return $content;
        }
示例#16
0
文件: tour.php 项目: rhurling/lasso
    /**
     *	Draw the modal used to house the walk through
     *	@since 0.6
     */
    public function draw_tour()
    {
        $tour_hidden = get_user_meta(get_current_user_ID(), 'lasso_hide_tour', true);
        if (lasso_user_can() && !$tour_hidden) {
            global $post;
            $nonce = wp_create_nonce('lasso-editor-tour');
            // let users add custom css classes
            $custom_classes = apply_filters('lasso_modal_tour_classes', '');
            ?>
			<div id="lasso--tour__modal" class="lasso--modal lasso--tour__modal lasso--modal__checkbox <?php 
            echo sanitize_html_class($custom_classes);
            ?>
">
				<script>
					jQuery(window).ready(function($){

						$('body').addClass('lasso-modal-open');

		    			$('.lasso--loading').remove();
						$('#lasso--tour__slides').hide().fadeIn()

						$('#lasso--tour__slides').unslider({
							dots: true,
							delay:7000
						});

					});
				</script>
				<div class="lasso--modal__inner">

					<?php 
            echo self::tour_slides();
            ?>

					<div class="lasso--postsettings__footer">

						<div class="lasso--postsettings__option">
							<label for="hide_tour" class="checkbox-control checkbox">
					        	<input type="checkbox" id="hide_tour" name="hide_tour" <?php 
            checked($tour_hidden, 1);
            ?>
>
					        	<span class="control-indicator"></span>
								<?php 
            _e('Don\'t show this again', 'lasso');
            ?>
					        </label>
						</div>

						<input type="submit" value="<?php 
            _e('Okay, got it!', 'lasso');
            ?>
" data-nonce="<?php 
            echo $nonce;
            ?>
" >
					</div>

				</div>

			</div>
			<div id="lasso--modal__overlay"></div>
			<?php 
        }
    }
/**
 * function wpfep_default_tab_content()
 * outputs the fields for a tab inside a tab
 * this function is only used if a specific callback is not declared when filtering wpfep_tabs
 * @param (array) $tab is the array of tab args
 */
function wpfep_default_tab_content($tab)
{
    /**
     * @hook wpfep_before_tab_fields
     * fires before the fields of the tab are outputted
     * @param (array) $tab the array of tab args.
     * @param (int) $current_user_id the user if of the current user to add things targetted to a specific user only.
     */
    do_action('wpfep_before_tab_fields', $tab, get_current_user_id());
    /**
     * build an array of fields to output
     * @hook - wpfep_profile_fields
     * each field should added with as an arrray with the following elements
     * id - used for the input name and id attributes - should also be the user meta key
     * label - used for the inputs label
     * desc - the description to go with the input
     * type - the type of input to render - valid are email, text, select, checkbox, textarea, wysiwyg
     * @param (integer) current user id - this can be used to add fields to certain users only
     */
    $fields = apply_filters('wpfep_fields_' . $tab['id'], array(), get_current_user_ID());
    /* check we have some fields */
    if (!empty($fields)) {
        /* output a wrapper div and form opener */
        ?>
		
			<div class="wpfep-fields">
				
				<?php 
        /* start a counter */
        $counter = 1;
        /* get the total number of fields in the array */
        $total_fields = count($fields);
        /* lets loop through our fields array */
        foreach ($fields as $field) {
            /* set a base counting class */
            $count_class = ' wpfep-' . $field['type'] . '-field wpfep-field-' . $counter;
            /* build our counter class - check if the counter is 1 */
            if ($counter == 1) {
                /* this is the first field element */
                $counting_class = $count_class . ' first';
                /* is the counter equal to the total number of fields */
            } elseif ($counter == $total_fields) {
                /* this is the last field element */
                $counting_class = $count_class . ' last';
                /* if not first or last */
            } else {
                /* set to base count class only */
                $counting_class = $count_class;
            }
            /* build a var for classes to add to the wrapper */
            $classes = empty($field['classes']) ? '' : ' ' . $field['classes'];
            /* build ful classe array */
            $classes = $counting_class . $classes;
            /* output the field */
            wpfep_field($field, $classes, $tab['id'], get_current_user_id());
            /* increment the counter */
            $counter++;
        }
        // end for each field
        /* output a closing wrapper div */
        ?>
			
			</div>
		
		<?php 
    }
    // end if have fields
    /**
     * @hook wpfep_after_tab_fields
     * fires after the fields of the tab are outputted
     * @param (array) $tab the array of tab args.
     * @param (int) $current_user_id the user if of the current user to add things targetted to a specific user only.
     */
    do_action('wpfep_after_tab_fields', $tab, get_current_user_id());
}
    function avfr_submit_box($groups = 0)
    {
        $public_can_vote = avfr_get_option('avfr_public_voting', 'avfr_settings_main');
        $userid = $public_can_vote && !is_user_logged_in() ? 1 : get_current_user_ID();
        $exluded = '';
        if (is_user_logged_in() || 'on' == $public_can_vote) {
            $allgroups = get_terms('groups', array('hide_empty' => 0));
            foreach ($allgroups as $exclude) {
                if ('on' === get_term_meta($exclude->term_id, 'avfr_new_disabled', true)) {
                    $exluded[] = $exclude->term_id;
                }
            }
            $args = array('show_option_all' => '', 'show_option_none' => '', 'option_none_value' => '-1', 'orderby' => 'Name', 'order' => 'ASC', 'hide_empty' => 0, 'include' => $groups, 'exclude' => $exluded, 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'group', 'class' => 'featureroup', 'taxonomy' => 'groups', 'hide_if_empty' => false, 'value_field' => 'name');
            ?>

			<div class="avfr-modal" id="avfr-modal" aria-hidden="true" tabindex="-1">
				<a href="#close" type="button" class="close" id="avfr-close" aria-hidden="true"></a>
				<div class="avfr-modal-dialog ">
				    <div class="avfr-modal-content">
				    	<div class="avfr-modal-header">
				    	<a href="#close" type="button" class="modal-close" id="avfr-close">
							<span aria-hidden="true">&times;</span>
						</a>
				    		<h3 class="avfr-modal-title"><?php 
            _e('Submit feature', 'feature-request');
            ?>
</h3>
				    	</div>
				    	<div class="avfr-modal-body">

							<form id="avfr-entry-form" method="post" enctype="multipart/form-data">
								<div id="avfr-form-group" class="form-input-group">
								<label for="avfr-title">
									<?php 
            _e('Submit feature for:', 'feature-request');
            ?>
								</label>
								<?php 
            if (!empty($groups) && count(explode(',', $groups)) == 1) {
                $group_name = get_term($groups, 'groups');
                echo $group_name->name;
                echo "<input name='group' type='hidden' value=" . $group_name->slug . ">";
            } elseif (empty($groups)) {
                $groups = get_terms('groups', array('hide_empty' => 0));
                if (count($groups) == 1) {
                    echo $groups[0]->name;
                    echo "<input name='group' type='hidden' value=" . $groups[0]->slug . ">";
                } else {
                    wp_dropdown_categories($args);
                }
            } else {
                ?>
 <span class="triangle-down"> <?php 
                wp_dropdown_categories($args);
            }
            ?>
</span></div>
								
								<script type="text/javascript">
								jQuery(document).ready(function($){

								    $('#tags-data-list')
								        .textext({
								            plugins : 'tags autocomplete'
								        })
								        .bind('getSuggestions', function(e, data)
								        {
								        var list =  [<?php 
            $avfr_modal_tag = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'fields' => 'all', 'childless' => false, 'pad_counts' => false, 'cache_domain' => 'core');
            $terms = get_terms('featureTags', $avfr_modal_tag);
            foreach ($terms as $term) {
                echo "'" . $term->slug . "',";
            }
            ?>
  ],
								                textext = $(e.target).textext()[0],
								                query = (data ? data.query : '') || ''
								                ;

								            $(this).trigger(
								                'setSuggestions',
								                { result : textext.itemManager().filter(list, query) }
								            );
								        })
								        ;
								    });
								</script>

								<?php 
            do_action('avfr_inside_form_top');
            if (!is_user_logged_in()) {
                ?>
									<div id="avfr-form-email">
										<label for="avfr-entryform_email">
											<?php 
                apply_filters('avfr_form_Email', _e('Email', 'feature-request'));
                ?>
										</label>
									<input id="avfr-entry-form-email" type="text" name="avfr-email" value="" placeholder="Email"></div>
								<?php 
            }
            ?>
								
								<div id="avfr-form-title" class="form-input-group">
									<label for="avfr-entryform-title">
										<?php 
            apply_filters('avfr_form_title', _e('Title', 'feature-request'));
            ?>
									</label>
									<input id="avfr-entryform-title" type="text" name="avfr-title" value="" placeholder="My Awesome Submission">
								</div>

								<div id="avfr-form-desc" class="form-input-group">
									<label for="avfr-entryform-description">
										<?php 
            apply_filters('avfr_form_description', _e('Description', 'feature-request'));
            ?>
									</label>
									<textarea id="avfr-entryform-description" name="avfr-description" value="" placeholder="<?php 
            _e('Make the description meaningful!', 'feature-request');
            ?>
"></textarea>		
  								</div>

  								<div id="avfr-form-tags" class="form-input-group">
	  								<label for="tags-data-list">
	  									<?php 
            apply_filters('avfr_form_title', _e('Feature tags:', 'feature-request'));
            ?>
	  								</label>
								<textarea name="avfr-tags" id="tags-data-list" rows="1"></textarea>
								</div>

  								<?php 
            $disable_upload = avfr_get_option('avfr_disable_upload', 'avfr_settings_fetures');
            ?>
  								<?php 
            if ('on' != $disable_upload) {
                ?>

  								<div id="avfr-form-upload" class="form-input-group">
  								  	<p class="avfr-upload-tip">
  										<?php 
                echo avfr_get_option('avfr_echo_type_size', 'avfr_settings_features');
                ?>
  										
  									</p>
  									<label for="avfr-upload-form">
  										<?php 
                apply_filters('avfr_form_upload', _e('Select file to upload:', 'feature-request'));
                ?>
  									</label>
  									<input id="avfr-upload-form" type="file"  name='avfr-upload'>
  								</div>

								<?php 
            }
            ?>

								<?php 
            if ('on' != avfr_get_option('avfr_disable_captcha', 'avfr_settings_main')) {
                ?>
								<div id="avfr-form-captcha" class="form-input-group">
								      <label for="captcha">
								      	<?php 
                _e('Captcha', 'feature-request');
                ?>
								      </label>
								      <input id="captcha" type="text" name="captcha" value="" maxlength="4" size="40" />
								      <img id="imgCaptcha" src="<?php 
                echo AVFR_URL;
                ?>
/public/includes/create-image.php" />
								      <img id='reload' src="<?php 
                echo AVFR_URL;
                ?>
/public/assets/image/refresh.png" alt="Refresh" >
								</div>
								<?php 
            }
            ?>
 
																	
								<?php 
            do_action('avfr_inside_form_bottom');
            ?>
								
								<input type="hidden" name="action" value="process_entry">
								<input type="hidden" name="nonce" value="<?php 
            echo wp_create_nonce('avfr-entry-nonce');
            ?>
"/>

								<div class="avfr-modal-footer">
									<input id="avfr-btn" class="avfr-button" type="submit" value="<?php 
            apply_filters('avfr_submit_label', _e('Submit', 'feature-request'));
            ?>
">
									<div id="avfr-entry-form-results"><p></p></div>
								</div>
							</form>

						</div>
					</div>
				</div>
			</div>

		<?php 
        } else {
            ?>
					<div class="avfr-modal" id="avfr-modal" aria-hidden="true" tabindex="-1">
						<a href="#close" type="button" class="close" id="avfr-close" aria-hidden="true"></a>
						<div class="avfr-modal-dialog ">
							<div class="avfr-modal-content">
								<div class="avfr-modal-body">
									<p>
										<?php 
            _e('Please', 'feature-request');
            ?>
 <a href="<?php 
            echo wp_login_url(home_url());
            ?>
"><?php 
            _e('login', 'feature-request');
            ?>
</a> <?php 
            _e('or', 'feature-request');
            ?>
 <a href="<?php 
            echo wp_registration_url();
            ?>
"><?php 
            _e('register', 'feature-request');
            ?>
</a><?php 
            _e('to submit new feature request.', 'feature-request');
            ?>
										<a href="#close" type="button" class="modal-close" id="avfr-close"><span aria-hidden="true">&times;</span></a>
									</p>
								</div>
							</div>
						</div>
					</div>
				<?php 
        }
    }
示例#19
0
    /**
     * Replicates WP's native recent comments dashboard widget.
     *
     * @package BuddyPress Docs
     * @since 1.1.8
     */
    function wp_dashboard_recent_comments()
    {
        global $wpdb, $bp;
        if (current_user_can('edit_posts')) {
            $allowed_states = array('0', '1');
        } else {
            $allowed_states = array('1');
        }
        // Select all comment types and filter out spam later for better query performance.
        $comments = array();
        $start = 0;
        $widgets = get_option('dashboard_widget_options');
        $total_items = isset($widgets['dashboard_recent_comments']) && isset($widgets['dashboard_recent_comments']['items']) ? absint($widgets['dashboard_recent_comments']['items']) : 5;
        while (count($comments) < $total_items && ($possible = $wpdb->get_results("SELECT c.*, p.post_type AS comment_post_post_type FROM {$wpdb->comments} c LEFT JOIN {$wpdb->posts} p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT {$start}, 50"))) {
            foreach ($possible as $comment) {
                if (count($comments) >= $total_items) {
                    break;
                }
                // Is the user allowed to read this doc?
                if ($bp->bp_docs->post_type_name == $comment->comment_post_post_type && !bp_docs_user_can('read', get_current_user_ID(), $comment->comment_post_ID)) {
                    continue;
                }
                if (in_array($comment->comment_approved, $allowed_states) && current_user_can('read_post', $comment->comment_post_ID)) {
                    $comments[] = $comment;
                }
            }
            $start = $start + 50;
        }
        if ($comments) {
            ?>

			<div id="the-comment-list" class="list:comment">
	<?php 
            foreach ($comments as $comment) {
                _wp_dashboard_recent_comments_row($comment);
            }
            ?>

			</div>

	<?php 
            if (current_user_can('edit_posts')) {
                ?>
				<?php 
                _get_list_table('WP_Comments_List_Table')->views();
                ?>
	<?php 
            }
            wp_comment_reply(-1, false, 'dashboard', false);
            wp_comment_trashnotice();
        } else {
            ?>

		<p><?php 
            _e('No comments yet.');
            ?>
</p>

	<?php 
        }
        // $comments;
    }
示例#20
0
    /**
     *	Show teh votes and vote form within a shortcode
     * 	@since version 1.1
     */
    function idea_factory_sc($atts, $content = null)
    {
        $defaults = array('hide_submit' => 'off', 'hide_voting' => 'off', 'hide_votes' => 'off');
        $atts = shortcode_atts($defaults, $atts);
        $postid = get_the_ID();
        $show_submit = 'on' !== $atts['hide_submit'];
        $show_voting = 'on' !== $atts['hide_voting'];
        $show_votes = 'on' !== $atts['hide_votes'];
        ob_start();
        do_action('idea_factory_sc_layout_before', $postid);
        ?>
<div class="idea-factory--wrap"><?php 
        do_action('idea_factory_sc_layout_before_entries', $postid);
        if ($show_submit) {
            echo idea_factory_submit_header();
        }
        ?>

			<section class="idea-factory--layout-main">
				<?php 
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $args = array('post_type' => 'ideas', 'meta_key' => '_idea_votes', 'orderby' => 'meta_value_num', 'paged' => $paged);
        $q = new WP_Query(apply_filters('idea_factory_query_args', $args));
        $max = $q->max_num_pages;
        wp_localize_script('idea-factory-script', 'idea_factory', idea_factory_localized_args($max, $paged));
        if ($q->have_posts()) {
            while ($q->have_posts()) {
                $q->the_post();
                // setup some vars
                $id = get_the_ID();
                if (is_user_logged_in()) {
                    $has_voted = get_user_meta(get_current_user_ID(), '_idea' . $id . '_has_voted', true);
                } elseif ($public_can_vote) {
                    $has_voted = idea_factory_has_public_voted($id);
                } else {
                    $has_voted = false;
                }
                $total_votes = idea_factory_get_votes($id);
                $status = idea_factory_get_status($id);
                $status_class = $status ? sprintf('idea-factory--entry__%s', $status) : false;
                $public_can_vote = idea_factory_get_option('if_public_voting', 'if_settings_main');
                ?>
						<section class="idea-factory--entry-wrap <?php 
                echo sanitize_html_class($status_class);
                ?>
 <?php 
                echo $has_voted ? 'idea-factory--hasvoted' : false;
                ?>
">

							<?php 
                do_action('idea_factory_sc_entry_wrap_top', $postid);
                ?>

							<div class="idea-factory--controls">

								<?php 
                if (idea_factory_is_voting_active($id) && $show_voting) {
                    echo idea_factory_vote_controls($id);
                }
                if ($total_votes && $show_votes) {
                    ?>
									<div class="idea-factory--totals">
										<?php 
                    if (1 == $total_votes) {
                        printf('<span class="idea-factory--totals_label">' . apply_filters('idea_factory_vote', __('%s vote', 'idea-factory')) . '</span>', '<span class="idea-factory--totals_num">1</span>');
                    } elseif (!empty($total_votes)) {
                        printf('<span class="idea-factory--totals_label">' . apply_filters('idea_factory_votes', __('%s votes', 'idea-factory')) . '</span>', '<span class="idea-factory--totals_num">' . (int) $total_votes . '</span>');
                    }
                    ?>
									</div>
								<?php 
                }
                echo idea_factory_vote_status($id);
                ?>

							</div>

							<div class="idea-factory--entry">

								<?php 
                the_title('<h2>', '</h2>');
                the_content();
                ?>

							</div>

							<?php 
                do_action('idea_factory_sc_entry_wrap_bottom', $postid);
                ?>

						</section>

						<?php 
            }
        } else {
            apply_filters('idea_factory_no_ideas', _e('No ideas found. Why not submit one?', 'idea-factory'));
        }
        wp_reset_query();
        ?>
			</section>

			<?php 
        do_action('idea_factory_sc_layout_after_entries', $postid);
        ?>

		</div>

		<?php 
        if ($show_submit) {
            echo idea_factory_submit_modal();
        }
        do_action('idea_factory_sc_layout_after', $postid);
        return ob_get_clean();
    }
示例#21
0
/**
 * Generate the language setting dropdown list.
 *
 * @since 0.0.1
 */
function vp_lang_dropdown()
{
    $default_code = WPLANG;
    if (empty($default_code)) {
        $default_code = 'en_US';
    }
    $option = get_user_meta(get_current_user_ID(), 'v2press_my_language', true);
    $langs = array('en_US' => 'English', 'zh_CN' => '简体中文');
    $output = '<select name="vp_user_lang" id="vp_user_lang">';
    foreach ($langs as $code => $name) {
        $output .= '<option value="' . $code . '"';
        if (!empty($option) && $code == $option) {
            $output .= ' selected="selected"';
        }
        if (empty($option) && $code == $default_code) {
            $output .= ' selected="selected"';
        }
        $output .= '>' . $name . '</option>';
    }
    $output .= '</select>';
    echo $output;
}
示例#22
0
文件: shop.php 项目: KL-Kim/my-theme
$kt_other = !empty($kt_shop_meta['other']) ? $kt_shop_meta['other'] : '';
?>

    <header class="entry-header">
		<?php 
if (has_post_thumbnail()) {
    // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail('large');
}
?>
	    <div class="bookmark-box">
    		<?php 
if (is_user_logged_in()) {
    ?>
    			<?php 
    $current_user_id = get_current_user_ID();
    ?>
    			<?php 
    $bookmarks = get_user_meta($current_user_id, '_kt_user_bookmark', FALSE);
    ?>
	    			<?php 
    if (!empty($bookmarks) && in_array($post->ID, $bookmarks)) {
        ?>
	    				<button id="bookmark" class="bookmarked" rel="<?php 
        echo $post->ID;
        ?>
"></button>
	    			<?php 
    } else {
        ?>
	    				<button id="bookmark" class="" rel="<?php 
    function avfr_user_votes_sc($atts)
    {
        global $avfr_db;
        $show_total = "on" !== $atts['hide_total'];
        $show_remaining = "on" !== $atts['hide_remaining'];
        $defaults = array('groups' => '', 'total' => 'on', 'remaining' => 'on');
        $atts = shortcode_atts($defaults, $atts);
        // Get limit for users from option
        $limit_time = avfr_get_option('avfr_votes_limitation_time', 'avfr_settings_main');
        //Get user ID
        $userid = get_current_user_ID();
        $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 0;
        //Calculate votes
        $fun = 'avfr_total_votes_' . $limit_time;
        $args = array('include' => $atts['groups']);
        $terms = get_terms('groups', $args);
        ?>
		<div class="user-votes-shortcode">

			<p><?php 
        _e('Your voting status in current ', 'feature-request');
        echo strtolower($limit_time);
        ?>
</p>
			<?php 
        foreach ($terms as $term) {
            ${'user_total_voted' . $term->slug} = $avfr_db->{$fun}($ip, $userid, '', $term->slug);
            ${'user_vote_limit' . $term->slug} = get_term_meta($term->term_id, 'avfr_total_votes', true);
            ${'remaining_votes' . $term->slug} = ${'user_vote_limit' . $term->slug} - ${'user_total_voted' . $term->slug};
            echo "<p class='avfr-sc-term'>" . $term->name . "</p>";
            if ($show_total) {
                _e('Total Votes: ', 'feature-request');
                echo ${'user_total_voted' . $term->slug} . "<br>";
            }
            if ($show_remaining) {
                _e('Remaining Votes: ', 'feature-request');
                echo ${'remaining_votes' . $term->slug} . "<br>";
            }
        }
        ?>
		</div>
		<?php 
    }
/**
*	Determines if a user has completed teh user info
*
*	@param $user_id int id of the user
*	@since 1.0
*	@return bool
*/
function fo_user_info_completed($user_id = 0)
{
    if (empty($user_id)) {
        $user_id = get_current_user_ID();
    }
    $status = get_user_meta($user_id, 'user_info_completed', true);
    return $status ? true : false;
}
示例#25
0
	<div class="idea-factory--wrap">

		<?php 
echo idea_factory_submit_header();
do_action('idea_factory_before_entries');
?>

		<section class="idea-factory--layout-main">
			<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        // setup some vars
        $id = get_the_ID();
        if (is_user_logged_in()) {
            $has_voted = get_user_meta(get_current_user_ID(), '_idea' . $id . '_has_voted', true);
        } elseif ($public_can_vote) {
            $has_voted = idea_factory_has_public_voted($id);
        }
        $total_votes = idea_factory_get_votes($id);
        $status = idea_factory_get_status($id);
        $status_class = $status ? sprintf('idea-factory--entry__%s', $status) : false;
        ?>
					<section class="idea-factory--entry-wrap <?php 
        echo sanitize_html_class($status_class);
        ?>
 <?php 
        echo $has_voted ? 'idea-factory--hasvoted' : false;
        ?>
">
示例#26
0
/**
 * Template Name: Start Course Page
 */
// COURSE STATUS :
// 0 : NOT STARTED
// 1: STARTED
// 2 : SUBMITTED
// > 2 : EVALUATED
// VERSION 1.8.4 NEW COURSE STATUSES
// 1 : START COURSE
// 2 : CONTINUE COURSE
// 3 : FINISH COURSE : COURSE UNDER EVALUATION
// 4 : COURSE EVALUATED
do_action('wplms_before_start_course');
get_header('buddypress');
do_action('wplms_start_course', get_the_ID(), get_current_user_ID());
$user_id = get_current_user_id();
if (isset($_POST['course_id'])) {
    $course_id = $_POST['course_id'];
    $coursetaken = get_user_meta($user_id, $course_id, true);
} else {
    if (isset($_COOKIE['course'])) {
        $course_id = $_COOKIE['course'];
        $coursetaken = 1;
    }
}
if (!isset($course_id) || !is_numeric($course_id)) {
    wp_die(__('INCORRECT COURSE VALUE. CONTACT ADMIN', 'vibe'));
}
$course_curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false));
$unit_id = wplms_get_course_unfinished_unit($course_id);
示例#27
0
 function vibe_show_user_id_column_content($value, $column_name, $user_id)
 {
     if ('user_status' == $column_name) {
         $user = get_userdata($user_id);
         $current_userId = get_current_user_ID();
         $last_activity = get_user_meta($user_id, 'last_activity', true);
         $threshold = apply_filters('wplms_login_threshold', 1800);
         $difference = time() - strtotime($last_activity) - $threshold;
         if ($difference <= 0 || $current_userId == $user_id) {
             return '<span class="user_online" title="' . __('Last Logged in on ', 'vibe') . $last_activity . '"> ' . __('Online', 'vibe') . '</span>';
         } else {
             return '<span class="user_offline" title="' . __('Last Logged in on ', 'vibe') . $last_activity . '"> ' . __('Offline', 'vibe') . '</span>';
         }
     }
     if ('user_id' == $column_name) {
         return $user_id;
     }
     return $value;
 }
示例#28
0
function tinr2v_shortcode($atts, $content)
{
    if (!is_null($content)) {
        if (!is_user_logged_in()) {
            $content = '<div class="bg-lr2v contextual"><i class="fa fa-comment"></i>' . __('此处内容需要登录并 <span class="user-login">发表评论</span> 才可见', 'tinection') . '</div>';
        } else {
            global $post;
            $user_id = get_current_user_ID();
            if ($user_id != $post->post_author && !user_can($user_id, 'edit_others_posts')) {
                $comments = get_comments(array('status' => 'approve', 'user_id' => get_current_user_ID(), 'post_id' => $post->ID, 'count' => true));
                if (!$comments) {
                    $content = '<div class="bg-lr2v contextual"><i class="fa fa-comment"></i>' . __('此处内容需要登录并 <a href="#comments">发表评论</a> 才可见', 'tinection') . '</div>';
                }
            }
        }
    }
    return $content;
}
 function process_submission()
 {
     if (!is_user_logged_in()) {
         return;
     }
     if (isset($_POST['action']) && 'process_submission' == $_POST['action']) {
         if (wp_verify_nonce($_POST['nonce'], 'process-submission')) {
             $user_id = get_current_user_ID();
             $user_data = get_user_by('ID', $user_id);
             $data = array('email' => $user_data->user_email, 'title' => isset($_POST['post_title']) ? $_POST['post_title'] : false, 'content' => isset($_POST['post_content']) ? $_POST['post_content'] : false, 'age' => isset($_POST['hike_age']) ? sanitize_text_field($_POST['hike_age']) : false, 'difficulty' => isset($_POST['hike_difficulty']) ? sanitize_text_field($_POST['hike_difficulty']) : false, 'rating' => isset($_POST['hike_rating']) ? sanitize_text_field($_POST['hike_rating']) : false, 'city' => isset($_POST['hike_city']) ? sanitize_text_field($_POST['hike_city']) : false, 'state' => isset($_POST['hike_state']) ? sanitize_text_field($_POST['hike_state']) : false, 'length' => isset($_POST['hike_length']) ? sanitize_text_field($_POST['hike_length']) : false, 'time' => isset($_POST['hike_time']) ? sanitize_text_field($_POST['hike_time']) : false, 'gps_coords' => isset($_POST['hike_gps_coords']) ? sanitize_text_field($_POST['hike_gps_coords']) : false, 'location_desc' => isset($_POST['hike_description']) ? sanitize_text_field($_POST['hike_description']) : false);
             $args = array('post_title' => wp_strip_all_tags($data['title']), 'post_content' => self::fo_sanitize_content($data['content']), 'post_status' => 'draft', 'post_type' => 'hikes');
             $post_id = wp_insert_post($args);
             if (is_wp_error($post_id)) {
                 wp_send_json_error();
             } else {
                 // Categories
                 wp_set_object_terms(absint($post_id), $data['age'], 'hike_ages', true);
                 wp_set_object_terms(absint($post_id), $data['difficulty'], 'hike_difficulty', true);
                 wp_set_object_terms(absint($post_id), $data['rating'], 'hike_rating', true);
                 // set state
                 $parent = wp_set_object_terms(absint($post_id), $data['state'], 'hike_location', true);
                 // set city
                 // @todo there's some weird bug where the slug is coming out as city-state instead of just city
                 $child = wp_insert_term($data['city'], 'hike_location', array('parent' => $parent[0], 'slug' => strtolower($data['city'])));
                 // Post Meta
                 update_post_meta($post_id, '_hike_length', $data['length']);
                 update_post_meta($post_id, '_hike_time', $data['time']);
                 update_post_meta($post_id, '_hike_location', $data['gps_coords']);
                 update_post_meta($post_id, '_hike_location_desc', $data['location_desc']);
                 // Images
                 if ($_FILES) {
                     $files = $_FILES['post_images'];
                     foreach ($files['name'] as $key => $value) {
                         if ($files['name'][$key]) {
                             $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]);
                             $_FILES = array('post_images' => $file);
                             foreach ($_FILES as $file => $array) {
                                 if (getimagesize($array['tmp_name'])) {
                                     $newupload = self::insert_attachment($file, $post_id);
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('hike_submitted', $user_id, $data);
             wp_send_json_success();
         } else {
             wp_send_json_error();
         }
     } else {
         wp_send_json_error();
     }
 }
    ?>

		 	<!-- Nav tabs -->
		  	<ul class="nav nav-tabs" role="tablist">
		    	<li role="presentation" class="active">
			    	<a href="#bookmarks" aria-controls="bookmarks" role="tab" data-toggle="tab">
			    		<i class="fo-icon fo-icon-heart"></i>
			    		Favorites
			    	</a>
		    	</li>
		  	</ul>

			<div class="tab-content">
			    <div role="tabpanel" class="tab-pane fade in active" id="bookmarks">
			    	<?php 
    $bookmarks = function_exists('fo_get_users_bookmarks') ? fo_get_users_bookmarks(get_current_user_ID()) : false;
    if ($bookmarks) {
        ?>

							<div id="bookmark-controls">
								<a href="#" id="manage-bookmarks" class="btn btn-primary btn-xs"><i class="fo-icon fo-icon-edit"></i>Edit</a>
								<a href="#" id="delete-bookmarks" class="hide btn btn-danger btn-xs">Delete</a>
								<a href="#" id="cancel-bookmarks" class="hide btn btn-warning btn-xs"><i class="fo-icon fo-icon-close"></i></a>
							</div>

							<?php 
        echo '<ul class="bookmarks-list">';
        foreach ((array) $bookmarks as $bookmark) {
            $id = $bookmark->post_id;
            $post = get_post($id);
            ?>