Skip to content

Commit

Permalink
Added inline docs for all changed to the production admin screens.
Browse files Browse the repository at this point in the history
  • Loading branch information
slimndap committed Mar 22, 2016
1 parent a870374 commit f5e315f
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 43 deletions.
2 changes: 2 additions & 0 deletions functions/extensions/wpt_extensions_promo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class WPT_Extensions_Promo {

function __construct() {
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_row_meta' ), 10, 2 );

// Add the 'extensions' submenu with priority 40 to move it below the 'settings' submenu.
add_action( 'admin_menu', array( $this, 'add_menu' ), 40 );
}

Expand Down
27 changes: 17 additions & 10 deletions functions/wpt_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function __construct() {
* appears above the seasons menu.
* @since 0.15
*/
add_action( 'admin_menu', array($this, 'add_admin_menu' ), 5);

add_action( 'admin_menu', array($this, 'add_theater_menu' ), 5);
add_action( 'admin_menu', array($this, 'add_settings_menu' ), 30);

add_action( 'add_meta_boxes', array($this, 'add_meta_boxes'));
add_action( 'quick_edit_custom_box', array($this,'quick_edit_custom_box'), 10, 2 );

Expand Down Expand Up @@ -170,7 +170,14 @@ function admin_init() {
}
}

public function add_admin_menu() {
/**
* Adds a 'Theater' admin menu.
*
* @since 0.?
* @since 0.15 No longer adds the 'Settings' submenu.
* @see WPT_Admin::add_settings_menu().
*/
function add_theater_menu() {
add_menu_page(
__('Theater','wp_theatre'),
__('Theater','wp_theatre'),
Expand All @@ -182,7 +189,13 @@ public function add_admin_menu() {
);
}

public function add_settings_menu() {
/**
* Adds a 'Settings' submenu to the 'Theater' menu.
*
* @since 0.15
* @see WPT_Admin::add_theater_menu().
*/
function add_settings_menu() {
add_submenu_page(
'theater-events',
__('Theater','wp_theatre').' '.__('Settings'),
Expand Down Expand Up @@ -225,12 +238,6 @@ function add_meta_boxes() {
);
}

public function productions_admin_html() {
$list_table = new WPT_Production_Admin_List_Table();
$list_table->prepare_items();
$list_table->display();
}

/**
* Show a meta box with display settings for a production.
* http://codex.wordpress.org/Function_Reference/add_meta_box
Expand Down
15 changes: 10 additions & 5 deletions functions/wpt_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function city( $args = array() ) {
* Returns value of a custom field.
* Fallback to production is custom field doesn't exist for event.
*
* @since 0.8.3
* @since 0.8.3
* @since 0.15 Fixed an error when no production is set for the event.
*
* @param string $field
* @param array $args {
Expand Down Expand Up @@ -616,9 +617,12 @@ public function prices_summary_html() {
*
* Returns the production of the event as a WPT_Production object.
*
* @since 0.4
* @since 0.4
* @since 0.15 Removed local caching of event production.
* Return <false> if no production is set.
*
* @return WPT_Production Production.
* @return WPT_Production The production.
* Returns <false> if no production is set.
*/
function production() {
$production_id = get_post_meta( $this->ID,WPT_Production::post_type_name, true );
Expand Down Expand Up @@ -1035,9 +1039,10 @@ public function tickets_url_html() {
*
* The title is taken from the parent production, since event don't have titles.
*
* @since ?.?
* @since 0.10.10 Fixed the name of the 'wpt_event_title'-filter.
* @since ?.?
* @since 0.10.10 Fixed the name of the 'wpt_event_title'-filter.
* Closes #114.
* @since 0.15 Fixed an error when no production is set for the event.
*
* @param array $args {
* @type bool $html Return HTML? Default <false>.
Expand Down
7 changes: 5 additions & 2 deletions functions/wpt_event_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function __construct() {
*
* @since 0.11
* @since 0.13 Moved from WPT_Event_Editor to WPT_Event_Admin.
* @return void
* @since 0.15 Renamed title of metabox from 'Event' to 'Event date'.
*/
public function add_event_editor_meta_box() {
add_meta_box(
Expand All @@ -40,6 +40,8 @@ public function add_event_editor_meta_box() {
*
* @since 0.11
* @since 0.13 Moved from WPT_Event_Editor to WPT_Event_Admin.
* @since 0.15 Renamed production field label from 'Production' to 'Event'.
*
* @param array $fields The currently defined fields for the event editor.
* @param int $event_id The event that being edited.
* @return array The fields, with a production field added at the beginning.
Expand Down Expand Up @@ -138,8 +140,9 @@ public function get_control_production_html($field, $event_id) {
* Outputs the contents of the Publish meta box.
*
* @since 0.13
* @since 0.15 Renamed button label from 'Update Event' to 'Update Event Date'.
*
* @param int $event The event ID.
* @return void
*/
public function publish_meta_box($event) {
$html = '';
Expand Down
8 changes: 7 additions & 1 deletion functions/wpt_event_editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function __construct() {
/**
* Adds the event editor meta box to the production admin page.
*
* @since 0.11
* @since 0.11
* @since 0.15 Renamed metabox title from 'Events' to 'Dates'.
*/
public function add_events_meta_box() {
add_meta_box(
Expand Down Expand Up @@ -699,6 +700,8 @@ public function get_listing_html( $production_id ) {
* Gets the HTML for a single event in a listing.
*
* @since 0.11
* @since 0.15 Replaced 'venue + city' with 'location'.
*
* @access private
* @param WPT_Event $event The event.
* @return string The HTML.
Expand Down Expand Up @@ -826,6 +829,9 @@ public function get_prices($field, $event_id) {
* Gets the HTML to create a new event for a production.
*
* @since 0.11.5
* @since 0.15 Renamed add new label from 'Add a new event' to 'Add a new date'.
* Renamed save label from 'Save event' to 'Save date'.
*
* @param int $production_id The production.
* @return string The HTML.
*/
Expand Down
2 changes: 2 additions & 0 deletions functions/wpt_event_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected function get_default() {
* Gets the value for a field from an event.
*
* @since 0.12.1
* @since 0.15 Fixed an error when no production is set for the event.
*
* @access protected
* @param string $field The field.
* @param array $args Arguments for the field (optional).
Expand Down
30 changes: 11 additions & 19 deletions functions/wpt_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,18 +632,6 @@ function get_months( $filters = array() ) {
return $months;
}

function get_productions_by_keyword($keyword, $status = array('publish') ) {
global $wp_theatre;
$productions_args = array(
's' => $keyword,
'status' => $status,
);
$productions = $wp_theatre->productions->get($productions_args);
$production_ids = wp_list_pluck( $productions, 'ID' );

return $production_ids;
}

/**
* Gets all years that have events.
*
Expand Down Expand Up @@ -710,6 +698,7 @@ function last() {
* @since 0.13 Added support for multiple productions.
* @since 0.13.1 'Start' and 'end' filter explicitly set to 'NUMERIC'.
* Fixes #168.
* @since 0.15 Added support for 's' (keyword search).
*
* @return array Events.
*/
Expand Down Expand Up @@ -816,7 +805,12 @@ public function get( $filters = array() ) {
}

if($filters['s']) {
$productions_by_keyword = $this->get_productions_by_keyword($filters['s'], $filters['status']);
$productions_by_keyword_args = array(
's' => $filters['s'],
'status' => $filters['status'],
);
$productions_by_keyword = $wp_theatre->productions->get($productions_by_keyword_args);

$args['meta_query'][] = array(
'key' => WPT_Production::post_type_name,
'value' => $productions_by_keyword,
Expand Down Expand Up @@ -876,14 +870,12 @@ public function get( $filters = array() ) {
$posts = array();

/*
* Don't try to retrieve productions if the 'post_in' argument is an empty array.
* This can happen when the date filter doesn't match any productions.
*
* This is different from the way that WP_Query handles an empty 'post__in' argument.
* Don't try to retrieve events if the 's' argument (keyword search) is used,
* but no productions match the search.
*/
if (
empty($filters['s']) || // True when 'post__in', 'start', 'end' and 'upcoming' filters are not used.
! empty($productions_by_keyword) // True when the date filter resulted in matching productions.
empty($filters['s']) || // True when the 's' filter is not used.
! empty($productions_by_keyword) // True when the 's' filter resulted in matching productions.
) {
$posts = get_posts( $args );
}
Expand Down
1 change: 1 addition & 0 deletions functions/wpt_productions.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ public function get_seasons() {
* @since 0.13 Support for 'start' and 'end'.
* @since 0.14.2 Fixed a conflict when using 'start' and 'post__not_in' together.
* See #183.
* @since 0.15 Added support for 's' (keyword search).
*
* @param array $args {
* string $order. See WP_Query.
Expand Down
1 change: 1 addition & 0 deletions functions/wpt_productions_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function add_submenu() {
public function page_html() {

$list_table = new WPT_Productions_List_Table();
$list_table->process_bulk_actions();

ob_start();

Expand Down
7 changes: 1 addition & 6 deletions functions/wpt_productions_list_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function __construct() {
'plural' => 'productions',
'ajax' => false,
)
);

$this->process_bulk_actions();
);
}

/**
Expand Down Expand Up @@ -225,9 +223,6 @@ function prepare_items() {
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, $hidden, $sortable );

// Process bulk actions.
//$this->process_bulk_actions();

$production_args = array();

$production_args['status'] = 'any';
Expand Down
1 change: 1 addition & 0 deletions functions/wpt_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public function register_event_meta() {
* @since ?.?
* @since 0.12 Slug is dynamic.
* Archive is disabled.
* @since 0.15 Renamed post type title from 'Production' to 'Event'.
*
* @see WPT_Production_Permalink::get_permalink() The production permalink.
*
Expand Down

0 comments on commit f5e315f

Please sign in to comment.