0

I have a custom page that uses the Cleverness To-Do List plugin to display multiple posts on a page. My site has multiple editors, and if a post is currently being edited on the custom page (not the dashboard) by another editor, I want that post (in the form of a <tr>) to be highlighted. Can someone point me in the direction of how to accomplish this in the context of my custom page's structure?

The site structure looks like this when you're editing a post:

*.com/blog/to-do-list/?action=edit-todo&id=1190

The PHP used to display the list:

/**
 * Display the to-do list with checkboxes
 */
public function display( $complete = 0 ) {
    extract( shortcode_atts( array(
        'title'      => '',
        'priority'   => 0,
        'assigned'   => 0,
        'deadline'   => 0,
        'progress'   => 0,
        'category'   => 0,
        'addedby'    => 0,
        'date'       => 0,
        'todoid'     => '',
        'editlink'   => 0
    ), $this->atts ) );
    global $current_user;
    get_currentuserinfo();
    $this->add_script = true;
    $layout = 'list';
    $this->list = '';

    list( $this->url, $this->action ) = CTDL_Lib::set_variables();

    /** @var $title string */
    if ( $title != '') {
        $this->list .= '<h2>'.esc_html( $title ).'</h2>';
        }

    // get to-do items
    /** @var $todoid int */
    if ( $todoid != '' ) {

        $post = CTDL_Lib::get_todo( $todoid );
        if ( $post ) {
            $id = $post->ID;
            list( $the_priority, $assign_meta, $deadline_meta, $completed_meta, $progress_meta ) = CTDL_Lib::get_todo_meta( $id );

            if ( CTDL_Loader::$settings['list_view'] == 2 ) {
                $completed = ( $todoid != '' && get_post_meta( $id, '_user_'.$current_user->ID.'_status', true ) == 1 ? 1 : 0 );
            } else {
                $completed = ( $todoid != '' && get_post_meta( $id, '_status', true ) == 1 ? 1 : 0 );
            }

            $this->show_checkbox( $id, $completed, $layout, ' single' );
            $this->show_todo_text( $post->post_content, 'list' );
            /** @var $priority int */
            if ( $priority == 1 ) $this->show_priority( $the_priority );
            /** @var $progress int */
            if ( $progress == 1 ) $this->show_progress( $progress_meta );
            /** @var $assigned int */
            if ( $assigned == 1 ) $this->show_assigned( $assign_meta );
            /** @var $addedby int */
            if ( $addedby == 1 ) $this->show_addedby( get_the_author() );
            /** @var $deadline int */
            if ( $deadline == 1 ) $this->show_deadline( $deadline_meta );
            /** @var $date int */
            if ( $date == 1 ) $this->show_date_added( get_the_date(), get_the_date( CTDL_Loader::$settings['date_format'] ) );
            $this->list .= do_action( 'ctdl_list_items' );
            /** @var $editlink int */
            if ( $editlink == 1 ) $this->show_edit_link( $id );
        } else {
            /* if there are no to-do items, display this message */
            $this->list .= '<p>'.apply_filters( 'ctdl_no_items', esc_html__( 'No items to do.', 'cleverness-to-do-list' ) ).'</p>';
        }

    } else {

        /** @var $category mixed */
        $this->loop_through_todos( 0, $category );

    }

    wp_reset_postdata();
}

PHP used to create the <tr>:

/**
 * Creates the HTML for the To-Do List Table Headings
 * @param $completed
 */
public function show_table_headings( $completed = 0 ) {
    extract( shortcode_atts( array(
        'priority'   => 0,
        'assigned'   => 0,
        'deadline'   => 0,
        'progress'   => 0,
        'categories' => 0,
        'addedby'    => 0,
        'date'       => 0,
        'editlink'   => 1
    ), $this->atts ) );

    $this->list .= '<thead><tr>';
    $this->list .= '<th id="checkbox-col" class="sorter-false filter-false"></th>';
    $this->list .= '<th id="item-col" data-placeholder="Enter search term">'.apply_filters( 'ctdl_heading_item', esc_html__( 'Item', 'cleverness-to-do-list' ) ).'</th>';
    /** @var $priority int */
    if ( $priority == 1 ) $this->list .= '<th id="priority-col">'.apply_filters( 'ctdl_heading_priority', esc_html__( 'Priority', 'cleverness-to-do-list' ) ).'</th>';
    /** @var $progress int */
    if ( $progress == 1 && CTDL_Loader::$settings['show_progress'] == 1 ) $this->list .= '<th id="progress-col">'.apply_filters( 'ctdl_heading_progress', esc_html__( 'Progress', 'cleverness-to-do-list' ) ).'</th>';
    /** @var $categories int */
    if ( $categories == 1 && CTDL_Loader::$settings['categories'] == 1 ) $this->list .= '<th id="category-col" class="filter-select" data-placeholder="Filter">'.apply_filters(
        'ctdl_heading_category', esc_html__( 'Expeditor',
        'cleverness-to-do-list' ) ).'</th>';
    if ( CTDL_PP ) $this->list .= '<th id="planner-col">'.apply_filters( 'ctdl_heading_planner', esc_html__( 'Post Planner', 'cleverness-to-do-list' ) ).'</th>';
    /** @var $assigned int */
    if ( $assigned == 1 && ( CTDL_Loader::$settings['assign'] == 0 && ( CTDL_Loader::$settings['list_view'] != 0 && CTDL_Loader::$settings['show_only_assigned'] == 0
            && ( current_user_can( CTDL_Loader::$settings['view_all_assigned_capability'] ) ) ) || ( CTDL_Loader::$settings['list_view'] != 0 && CTDL_Loader::$settings['show_only_assigned'] == 1 )
            && CTDL_Loader::$settings['assign'] == 0 ) ) $this->list .= '<th id="assigned-col" class="filter-select" data-placeholder="Filter">'.apply_filters( 'ctdl_heading_assigned',
        esc_html__( 'Assigned to', 'cleverness-to-do-list' ) ).'</th>';
    /** @var $addedby int */
    if ( $addedby == 1 && CTDL_Loader::$settings['list_view'] == 1 && CTDL_Loader::$settings['todo_author'] == 0 )
        $this->list .= '<th id="added-col">'.apply_filters( 'ctdl_heading_added_by', esc_html__( 'Added By', 'cleverness-to-do-list' ) ).'</th>';
    /** @var $deadline int */
    if ( $deadline == 1  && CTDL_Loader::$settings['show_deadline'] == 1 ) $this->list .= '<th id="deadline-col" data-placeholder="mm/dd/yyyy">'.apply_filters( 'ctdl_heading_deadline',
        esc_html__( 'Deadline',
        'cleverness-to-do-list' ) ).'</th>';
    /** @var $date int */
    if ( $date == 1 && CTDL_Loader::$settings['show_date_added'] == 1 ) $this->list .= '<th id="date-col" class="filter-false">'.apply_filters( 'ctdl_heading_date_added', esc_html__( 'Date added',
        'cleverness-to-do-list' ) ).'</th>';
    if ( $completed == 1 && CTDL_Loader::$settings['show_completed_date'] == 1 ) $this->list .= '<th id="completed-col">'.apply_filters( 'ctdl_heading_completed', esc_html__( 'Completed', 'cleverness-to-do-list' ) ).'</th>';
    $this->list .= do_action( 'ctdl_table_headings' );
    /** @var $editlink int */
    if ( $editlink == 1 && current_user_can( CTDL_Loader::$settings['edit_capability'] ) || CTDL_Loader::$settings['list_view'] == 0 )
        $this->list .= '<th id="action-col" class="sorter-false action filter-false">'.apply_filters( 'ctdl_heading_action', esc_html__( 'Action', 'cleverness-to-do-list' ) ).'</th>';
    $this->list .= '</tr></thead>';
}
  • Where is the <tr> you mention created? – s_ha_dum Jun 21 '13 at 16:43
  • @s_ha_dum: Edited the OP to include the PHP used to create the <tr>. – eclipsis Jun 21 '13 at 16:49
  • Do you have an accessible URL? – s_ha_dum Jun 21 '13 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.