'; $story_metabox .= ''; // start Product select box $story_metabox .= $this->meta_select_box( 'Associated Product', 'agilepress_story[product]', $agilepress_product, $products, null); // end select box $story_metabox .= ''; // start Status select box $story_status = array( ['post_name' => 'isepic', 'post_title' => 'Is Epic'], ['post_name' => 'isstory', 'post_title' => 'Is Story'], ['post_name' => 'sendtosprint', 'post_title' => 'Send to Sprint'], ['post_name' => 'iscomplete', 'post_title' => 'Completed'], ); $story_metabox .= $this->meta_select_box( 'Story Status', 'agilepress_story[story_status]', $agilepress_status, null, $story_status); // end select box $story_metabox .= ''; // start Parent Epic select box $epics = $wpdb->get_results( "select p.ID, p.post_title, p.post_name from " . $wpdb->posts . " p, " . $wpdb->postmeta . " m " . "where p.post_type = 'agilepress-stories' and p.post_status = 'publish' " . "and m.post_ID = p.ID and m.meta_key = '_agilepress_story_data' and m.meta_value like '%epic%'" . "order by post_name"); $story_metabox .= $this->meta_select_box( 'Parent Epic', 'agilepress_story[parent_epic]', $agilepress_parent_epic, $epics, null); // end select box $story_metabox .= ''; // start Sprint select box $story_metabox .= $this->meta_select_box( 'Associated Sprint', 'agilepress_story[story_sprint]', $agilepress_sprint, $sprints, null); // end select box $story_metabox .= ''; //display the meta box shortcode legend section if ($use_shortcodes) { $story_metabox .= '
'; $story_metabox .= '' .__( 'Shortcode Legend', 'agilepress' ).''; $story_metabox .= '' .__( '(These shortcodes all you to show AgilePress datapoints in posts and pages as needed.)', 'agilepress' ).''; $story_metabox .= '
'; $story_metabox .= '' .__( 'Product', 'agilepress' ) .':[agilepress-data type=story value=' . esc_html($story_post_name) . ' show=product]'; $story_metabox .= '' .__( 'Status', 'agilepress' ) .':[agilepress-data type=story value=' . esc_html($story_post_name) . ' show=story_status]'; $story_metabox .= '' .__( 'Parent Epic', 'agilepress' ) .':[agilepress-data type=story value=' . esc_html($story_post_name) . ' show=parent_epic]'; $story_metabox .= '' .__( 'Associated Sprint', 'agilepress' ) .':[agilepress-data type=story value=' . esc_html($story_post_name) . ' show=story_sprint]'; } $story_metabox .= ''; return $story_metabox; } /** * This method constructs the metabox for the Product CPT. * * @param array $agilepress_meta Custom post metadata * @return string $product_metabox Formatted (HTML/CSS/JavaScript) metabox panel * * @uses \wordpress\wp_nonce_field() * * @see https://developer.wordpress.org/reference/functions/wp_nonce_field/ * * @author Vinland Media, LLC. * @package AgilePress * @subpackage AgilePress\admin */ public function build_product_meta_box($agilepress_meta) { $product_post_id = get_the_ID(); $product_post_name = get_post_field('post_name', $product_post_id); $agilepress_version = (!empty($agilepress_meta['version'])) ? $agilepress_meta['version'] : ''; $agilepress_target = (!empty($agilepress_meta['target'])) ? $agilepress_meta['target'] : ''; $agilepress_phase = (!empty($agilepress_meta['phase'])) ? $agilepress_meta['phase'] : ''; //nonce field for security wp_nonce_field( 'product-meta-box-save', 'agilepress' ); // meta box form $product_metabox = ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; // start phase select box $product_development_phase = array( ['post_name' => 'pre-alpha', 'post_title' => 'Pre-Alpha'], ['post_name' => 'alpha', 'post_title' => 'Alpha'], ['post_name' => 'closed-beta', 'post_title' => 'Closed Beta'], ['post_name' => 'open-beta', 'post_title' => 'Open Beta'], ['post_name' => 'release-candidate', 'post_title' => 'Release Candidate'], ['post_name' => 'release-to-web', 'post_title' => 'Release to Web/MFG'], ['post_name' => 'general-availability', 'post_title' => 'General Availability'], ); $product_metabox .= $this->meta_select_box( 'In-Progress Version Status', 'agilepress_product[phase]', $agilepress_phase, null, $product_development_phase); // end select box //display the meta box shortcode legend section $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= ''; $product_metabox .= '
' .__('Current Version', 'agilepress').':is_disabled() . '>
' .__('Target Version', 'agilepress').':is_disabled() . '>

' .__( 'Shortcode Legend', 'agilepress' ).'
' .__( '(These shortcodes all you to show AgilePress datapoints in posts and pages as needed.)', 'agilepress' ).'

' .__( 'Version', 'agilepress' ).':[agilepress-data type=product value=' . esc_html($product_post_name) . ' show=version]
' .__( 'Target', 'agilepress' ).':[agilepress-data type=product value=' . esc_html($product_post_name) . ' show=target]
' .__( 'Phase', 'agilepress' ).':[agilepress-data type=product value=' . esc_html($product_post_name) . ' show=phase]
'; return $product_metabox; } /** * This method constructs the metabox for the Task CPT. * * @param array $agilepress_meta Custom post metadata * @param object $products Query results of Products search * @param object $sprints Query results of Sprints search * @param object $stories Query results of Stories search * @param boolean $use_shortcodes Whether or not to show shortcode help * @return string $task_metabox Formatted (HTML/CSS/JavaScript) metabox panel * * @global $wpdb * * @uses \vinlandmedia\agilepress\AgilePress_Meta::meta_select_box() * @uses \wordpress\get_users() * @uses \wordpress\selected() * @uses \wordpress\wp_nonce_field() * * @see https://developer.wordpress.org/reference/classes/wpdb/ * @see https://developer.wordpress.org/reference/functions/get_users/ * @see https://developer.wordpress.org/reference/functions/selected/ * @see https://developer.wordpress.org/reference/functions/wp_nonce_field/ * * @author Vinland Media, LLC. * @package AgilePress * @subpackage AgilePress\admin */ public function build_task_meta_box($agilepress_meta, $products, $sprints, $stories, $use_shortcodes) { $task_post_id = get_the_ID(); $task_post_name = get_post_field('post_name', $task_post_id); $agilepress_product = ( ! empty( $agilepress_meta['product'] ) ) ? $agilepress_meta['product'] : ''; $agilepress_sprint = ( ! empty( $agilepress_meta['sprint'] ) ) ? $agilepress_meta['sprint'] : ''; $agilepress_task_status = ( ! empty( $agilepress_meta['task_status'] ) ) ? $agilepress_meta['task_status'] : ''; $agilepress_parent_story = ( ! empty( $agilepress_meta['parent_story'] ) ) ? $agilepress_meta['parent_story'] : ''; $agilepress_task_assignee = ( ! empty( $agilepress_meta['task_assignee'] ) ) ? $agilepress_meta['task_assignee'] : ''; $agilepress_priority = ( ! empty( $agilepress_meta['task_priority'] ) ) ? $agilepress_meta['task_priority'] : ''; //nonce field for security wp_nonce_field( 'task-meta-box-save', 'agilepress' ); // display meta box form $task_metabox = ''; $task_metabox .= ''; // start Product select box $task_metabox .= $this->meta_select_box( 'Associated Product', 'agilepress_task[product]', $agilepress_product, $products, null); // end select box $task_metabox .= ''; // start Sprint select box $task_metabox .= $this->meta_select_box( 'Associated Sprint', 'agilepress_task[sprint]', $agilepress_sprint, $sprints, null); // end select box $task_metabox .= ''; // start Parent Story select box $task_metabox .= $this->meta_select_box( 'Parent Story', 'agilepress_task[parent_story]', $agilepress_parent_story, $stories, null); // end select box $task_metabox .= ''; // start Status select box $task_status = array( ['post_name' => 'sendtosprint', 'post_title' => 'Project Backlog Items'], ['post_name' => 'todo', 'post_title' => 'To-Do'], ['post_name' => 'inprogress', 'post_title' => 'In Progress'], ['post_name' => 'intesting', 'post_title' => 'In Testing'], ['post_name' => 'done', 'post_title' => 'Done'], ); $task_metabox .= $this->meta_select_box( 'Task Status', 'agilepress_task[task_status]', $agilepress_task_status, null, $task_status); // end select box $task_metabox .= ''; $args = array( 'role__in' => array( 'agilepress_admin', 'agilepress_developer', ), ); $ap_users = get_users($args); $task_metabox .= ''; $task_metabox .= ''; // start Status select box $task_priority = array( ['post_name' => '4', 'post_title' => 'Critical'], ['post_name' => '3', 'post_title' => 'Major'], ['post_name' => '2', 'post_title' => 'Normal'], ['post_name' => '1', 'post_title' => 'Minor'], ['post_name' => '0', 'post_title' => 'Trivial'], ); $task_metabox .= $this->meta_select_box( 'Task Priority', 'agilepress_task[task_priority]', $agilepress_priority, null, $task_priority); // end select box //display the meta box shortcode legend section if ($use_shortcodes) { $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; $task_metabox .= ''; } $task_metabox .= '
' .__('Assignee', 'agilepress').':

' .__( 'Shortcode Legend', 'agilepress' ).'
' .__( '(These shortcodes all you to show AgilePress datapoints in posts and pages as needed.)', 'agilepress' ).'

' .__( 'Product', 'agilepress' ) .':[agilepress-data type=task value=' . esc_html($task_post_name) . ' show=product]
' .__( 'Sprint', 'agilepress' ).':[agilepress-data type=task value=' . esc_html($task_post_name) . ' show=sprint]
' .__( 'Parent Story', 'agilepress' ).':[agilepress-data type=task value=' . esc_html($task_post_name) . ' show=parent_story]
' .__( 'Task Status', 'agilepress' ).':[agilepress-data type=task value=' . esc_html($task_post_name) . ' show=task_status]
' .__( 'Assignee', 'agilepress' ).':[agilepress-data type=task value=' . esc_html($task_post_name) . ' show=task_assignee]
' .__( 'Task Priority', 'agilepress' ).':[agilepress-data type=task value=' . esc_html($task_post_name) . ' show=task_priority]
'; return $task_metabox; } /** * This method constructs the metabox for the Sprint CPT. * * @param array $agilepress_meta Custom post metadata * @param object $products Query results of Products search * @return string $sprint_metabox Formatted (HTML/CSS/JavaScript) metabox panel * * @uses \vinlandmedia\agilepress\AgilePress_Meta::meta_select_box() * @uses \wordpress\wp_nonce_field() * * @see https://developer.wordpress.org/reference/functions/wp_nonce_field/ * * @author Vinland Media, LLC. * @package AgilePress * @subpackage AgilePress\admin */ public function build_sprint_meta_box($agilepress_meta, $products) { $sprint_post_id = get_the_ID(); $sprint_post_name = get_post_field('post_name', $sprint_post_id); $agilepress_product = ( ! empty( $agilepress_meta['product'] ) ) ? $agilepress_meta['product'] : ''; $agilepress_start_date = ( ! empty( $agilepress_meta['start_date'] ) ) ? $agilepress_meta['start_date'] : ''; $agilepress_end_date = ( ! empty( $agilepress_meta['end_date'] ) ) ? $agilepress_meta['end_date'] : ''; $agilepress_status = ( ! empty( $agilepress_meta['status'] ) ) ? $agilepress_meta['status'] : ''; $agilepress_target = ( ! empty( $agilepress_meta['backlog_target'] ) ) ? $agilepress_meta['backlog_target'] : ''; //nonce field for security wp_nonce_field( 'sprint-meta-box-save', 'agilepress' ); // display meta box form $sprint_metabox = ''; $sprint_metabox .= ''; // start Product select box $sprint_metabox .= $this->meta_select_box( 'Product', 'agilepress_sprint[product]', $agilepress_product, $products, null); // end select box $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; // start Backlog Target select box $sprint_status = array( ['post_name' => 'planned', 'post_title' => 'Planned'], ['post_name' => 'in-progress', 'post_title' => 'In Progress'], ['post_name' => 'completed', 'post_title' => 'Completed'], ); $sprint_metabox .= $this->meta_select_box( 'Sprint Status', 'agilepress_sprint[status]', $agilepress_status, null, $sprint_status); // end select box $sprint_metabox .= ''; // start Backlog Target select box $backlog_target_status = array( ['post_name' => 'yes', 'post_title' => 'Yes'], ['post_name' => 'no', 'post_title' => 'No'] ); $sprint_metabox .= $this->meta_select_box( 'Backlog Target (Y/N)', 'agilepress_sprint[backlog_target]', $agilepress_target, null, $backlog_target_status); // end select box $sprint_metabox .= ''; //display the meta box shortcode legend section $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= ''; $sprint_metabox .= '
' .__('Start Date', 'agilepress').':is_disabled() . '>
' .__('End Date', 'agilepress').':is_disabled() . '>

' .__( 'Shortcode Legend', 'agilepress' ).'
' .__( '(These shortcodes all you to show AgilePress datapoints in posts and pages as needed.)', 'agilepress' ).'

' .__( 'Product', 'agilepress' ) .':[agilepress-data type=sprint value=' . esc_html($sprint_post_name) . ' show=product]
' .__( 'Start Date', 'agilepress' ).':[agilepress-data type=sprint value=' . esc_html($sprint_post_name) . ' show=start_date]
' .__( 'End Date', 'agilepress' ).':[agilepress-data type=sprint value=' . esc_html($sprint_post_name) . ' show=end_date]
' .__( 'Status', 'agilepress' ).':[agilepress-data type=sprint value=' . esc_html($sprint_post_name) . ' show=status]
' .__( 'Backlog Target', 'agilepress' ).':[agilepress-data type=sprint value=' . esc_html($sprint_post_name) . ' show=backlog_target]
'; return $sprint_metabox; } /** * This method constructs the metabox for attachments. * * @param array $agilepress_meta Custom post metadata * @return string $attachment_metabox Formatted (HTML/CSS/JavaScript) metabox panel * * @uses \wordpress\wp_nonce_field() * * @author Vinland Media, LLC. * @package AgilePress * @subpackage AgilePress\admin */ public function build_attachment_meta_box($agilepress_meta, $from_modal = false) { //nonce field for security wp_nonce_field('attachment-meta-box-save', 'agilepress'); // meta box form $attachment_metabox = ''; if (!$from_modal) { $attachment_metabox .= ''; $attachment_metabox .= ''; $attachment_metabox .= ''; } if ((isset($agilepress_meta) && (!empty($agilepress_meta)))) { foreach ($agilepress_meta as $my_attachment) { $agilepress_file = (!empty($my_attachment['file'])) ? $my_attachment['file'] : ''; $agilepress_url = (!empty($my_attachment['url'])) ? $my_attachment['url'] : ''; $agilepress_type = (!empty($my_attachment['type'])) ? $my_attachment['type'] : ''; $agilepress_error = (!empty($my_attachment['error'])) ? $my_attachment['error'] : ''; $file_array = explode('/', $agilepress_file); $uploaded_filename = end($file_array); if ((isset($agilepress_file)) && (!empty($agilepress_file))) { $attachment_metabox .= ''; $attachment_metabox .= ''; if (!$from_modal) { $attachment_metabox .= ''; } $attachment_metabox .= ''; $attachment_metabox .= ''; } } } $attachment_metabox .= '
' .__('Attachment', 'agilepress').':
' . esc_html($uploaded_filename) . ''; $attachment_metabox .= '
'; return $attachment_metabox; } /** * Because there are numerous HTML select boxes involved in the AgilePress * CPT metaboxes, we use this method to generate them all. * * Send either $dataset or $static_values but never both. If the former * ($dataset) is not null, it will be used; if the former is null, the method * will look for the presense of the latter ($static_values). * * @param string $title Title of Select Element * @param string $html_name The name to be used for HTML to identify element * @param string $current_value The currently-stored value for this element * @param object $dataset The data to be used for the select box (if from DB) * @param array $static_values The data to be used (if hard-coded) * @return string $select_box Formatted (HTML/CSS/JavaScript) select box * * @uses \wordpress\selected() * * @see https://developer.wordpress.org/reference/functions/selected * * @author Vinland Media, LLC. * @package AgilePress * @subpackage AgilePress\admin */ private function meta_select_box($title = null, $html_name = null, $current_value = null, $dataset = null, $static_values = null) { $select_box = '' .__($title, 'agilepress').':'; $select_box .= 'is_disabled() . '>'; return $select_box; } private function is_disabled() { if (!user_can(wp_get_current_user(), 'transition_tasks')) { return 'disabled'; } else { return null; } } }