Last active
August 29, 2015 14:12
-
-
Save bhwebworks/aaad37bc43e5914119f8 to your computer and use it in GitHub Desktop.
Add an "Add another lesson to this course" link to Sensei Edit Course admin page by modifying the course_lessons_meta_box_content function. Found in classes/class-woothemes-sensei-course.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* course_lessons_meta_box_content function. | |
* | |
* @access public | |
* @return void | |
*/ | |
public function course_lessons_meta_box_content () { | |
global $post; | |
// Setup Lesson Meta Data | |
$select_lesson_prerequisite = 0; | |
if ( 0 < $post->ID ) { $select_course_prerequisite = get_post_meta( $post->ID, '_lesson_course', true ); } | |
// Setup Lesson Query | |
$posts_array = array(); | |
if ( 0 < $post->ID ) { | |
$posts_array = $this->course_lessons( $post->ID, 'any' ); | |
} // End If Statement | |
$html = ''; | |
$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; | |
if ( count( $posts_array ) > 0 ) { | |
foreach ($posts_array as $post_item){ | |
$html .= '<p>'."\n"; | |
$html .= $post_item->post_title."\n"; | |
$html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action" target="_blank">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>' . "\n"; | |
$html .= '</p>'."\n"; | |
} // End For Loop | |
// BHWW - added this new lesson link under existing lessons | |
if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; } | |
$html .= '<p>'."\n"; | |
$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id ) . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '" target="_blank">' . __( 'Add another lesson to this course.', 'woothemes-sensei' ) . '</a>' . "\n"; | |
$html .= '</p>'."\n"; | |
} else { | |
$course_id = ''; | |
if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; } | |
$html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n"; | |
$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id ) . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '" target="_blank">' . __( 'Add a lesson now.', 'woothemes-sensei' ) . '</a>' . "\n"; | |
$html .= '</p>'."\n"; | |
} // End If Statement | |
echo $html; | |
} // End course_lessons_meta_box_content() | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* course_lessons_meta_box_content function. | |
* | |
* @access public | |
* @return void | |
*/ | |
public function course_lessons_meta_box_content () { | |
global $post; | |
// Setup Lesson Meta Data | |
$select_lesson_prerequisite = 0; | |
if ( 0 < $post->ID ) { $select_course_prerequisite = get_post_meta( $post->ID, '_lesson_course', true ); } | |
// Setup Lesson Query | |
$posts_array = array(); | |
if ( 0 < $post->ID ) { | |
$posts_array = $this->course_lessons( $post->ID, 'any' ); | |
} // End If Statement | |
$html = ''; | |
$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; | |
if ( count( $posts_array ) > 0 ) { | |
foreach ($posts_array as $post_item){ | |
$html .= '<p>'."\n"; | |
$html .= $post_item->post_title."\n"; | |
$html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>'; | |
$html .= '</p>'."\n"; | |
} // End For Loop | |
} else { | |
$course_id = ''; | |
if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; } | |
$html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n"; | |
$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id ) . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">' . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n"; | |
$html .= '</p>'."\n"; | |
} // End If Statement | |
echo $html; | |
} // End course_lessons_meta_box_content() | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment