PluginProbe
Edit Flow / 0.9.2
Edit Flow v0.9.2
0.11.1 0.11.0 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.8 0.8.1 0.8.2 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 trunk 0.1.5 0.10.0 0.10.1 0.10.2 All 44 releases
← All changes | modules/dashboard/dashboard.php +43 -11 0.8.2 → 0.9.2 View file →
@@ -115,11 +115,17 @@
115 115
116 116 wp_enqueue_style( 'edit-flow-dashboard-css', $this->module_url . 'lib/dashboard.css', false, EDIT_FLOW_VERSION, 'all' );
117 117
118 118 // Set up Post Status widget but, first, check to see if it's enabled
119 - if ( $this->module->options->post_status_widget == 'on')
120 - wp_add_dashboard_widget( 'post_status_widget', __( 'Unpublished Content', 'edit-flow' ), array( $this, 'post_status_widget' ) );
119 + if ( $this->module->options->post_status_widget == 'on' ) {
121 120
121 + $status_widget_post_types = apply_filters( 'ef_dashboard_psw_post_types', $this->get_all_post_types() );
122 +
123 + foreach ( $status_widget_post_types as $post_type => $label ) {
124 + $this->add_dashboard_status_widget( $post_type );
125 + }
126 + }
127 +
122 128 // Set up the Notepad widget if it's enabled
123 129 if ( 'on' == $this->module->options->notepad_widget )
124 130 wp_add_dashboard_widget( 'notepad_widget', __( 'Notepad', 'edit-flow' ), array( $this->widgets->notepad_widget, 'notepad_widget' ) );
125 131
@@ -127,18 +133,44 @@
127 133 if ( $this->module->options->my_posts_widget == 'on' && $this->module_enabled( 'notifications' ) )
128 134 wp_add_dashboard_widget( 'myposts_widget', __( 'Posts I\'m Following', 'edit-flow' ), array( $this, 'myposts_widget' ) );
129 135
130 136 }
137 +
138 + /**
139 + * Dynamically add a "Unpublished Content" post status widget for any post type
140 + *
141 + * @param $post_type_slug
142 + */
143 + public function add_dashboard_status_widget( $post_type_slug ) {
144 +
145 + $post_type_labels = get_post_type_labels( get_post_type_object( $post_type_slug ) );
146 +
147 + if ( $post_type_slug !== 'post' ) {
148 + $widget_id = 'post_status_widget_' . $post_type_slug;
149 + $widget_title = sprintf( esc_html__( 'Unpublished Content: %s', 'edit-flow' ), $post_type_labels->name );
150 + } else {
151 + $widget_id = 'post_status_widget';
152 + $widget_title = __( 'Unpublished Content', 'edit-flow' );
153 + }
154 +
155 + $widget_title = apply_filters( 'ef_dashboard_psw_title', $widget_title, $post_type_slug );
156 + $args = array(
157 + 'post_type' => $post_type_slug,
158 + 'labels' => $post_type_labels,
159 + );
160 +
161 + wp_add_dashboard_widget( $widget_id, $widget_title, array( $this, 'post_status_widget' ), NULL, $args );
162 + }
131 163
132 164 /**
133 165 * Creates Post Status widget
134 166 * Display an at-a-glance view of post counts for all (post|custom) statuses in the system
135 - *
136 - * @todo Support custom post types
137 167 */
138 - function post_status_widget () {
139 - global $edit_flow;
140 -
168 + function post_status_widget( $unused, $args ) {
169 +
170 + $labels = $args['args']['labels'];
171 + $post_type = $args['args']['post_type'];
172 +
141 173 $statuses = $this->get_post_statuses();
142 174 $statuses[] = (object)array(
143 175 'name' => __( 'Scheduled', 'edit-flow' ),
144 176 'description' => '',
@@ -149,16 +181,16 @@
149 181 if ( $this->module_enabled( 'custom_status' ) )
150 182 $edit_custom_status_url = add_query_arg( 'page', 'ef-custom-status-settings', get_admin_url( null, 'admin.php' ) );
151 183
152 184 ?>
153 - <p class="sub"><?php _e('Posts at a Glance', 'edit-flow') ?></p>
185 + <p class="sub ef-psw-title"><?php printf( esc_html__('%s at a Glance', 'edit-flow'), $labels->name ) ?></p>
154 186
155 - <div class="table">
187 + <div class="table ef-psw-content">
156 188 <table>
157 189 <tbody>
158 - <?php $post_count = wp_count_posts( 'post' ); ?>
190 + <?php $post_count = wp_count_posts( $post_type ); ?>
159 191 <?php foreach($statuses as $status) : ?>
160 - <?php $filter_link = $this->filter_posts_link( $status->slug ); ?>
192 + <?php $filter_link = $this->filter_posts_link( $status->slug, $post_type ); ?>
161 193 <tr>
162 194 <td class="b">
163 195 <a href="<?php echo esc_url( $filter_link ); ?>">
164 196 <?php