workflow_pages == '' ) { // First run. $this->workflow_pages = 'admin'; }; echo '

' . esc_html__( "Gravity Flow can be accessed from both the front end of your site and from the built-in WordPress admin pages (Workflow menu). If you want to use your site styles, or if you want to use the one-click approval links, then you'll need to add some pages to your site.", 'gravityflow' ) . '

'; echo '

' . sprintf( esc_html__( 'Would you like to create custom inbox, status, and submit pages now? The pages will contain the %s[gravityflow] shortcode%s enabling assignees to interact with the workflow from the front end of the site.', 'gravityflow' ), '', '' ) . '

'; ?>
workflow_pages == 'custom' ) { $settings = gravity_flow()->get_app_settings(); $settings['inbox_page'] = $this->create_page( 'inbox' ); $settings['status_page'] = $this->create_page( 'status' ); $settings['submit_page'] = $this->create_page( 'submit' ); gravity_flow()->update_app_settings( $settings ); } } /** * Creates a new page containing the gravityflow shortcode for the specified page type. * * @param string $page The page type: inbox, status, or submit. * * @return int|string|WP_Error */ public function create_page( $page ) { $post = array( 'post_title' => $this->get_page_title( $page ), 'post_content' => sprintf( '[gravityflow page="%s"]', $page ), 'post_excerpt' => $this->get_page_title( $page ), 'post_status' => 'publish', 'post_type' => 'page', ); $post_id = wp_insert_post( $post ); return $post_id ? $post_id : ''; } /** * Return page title for the specified page type. * * @param string $page The page type: inbox, status, or submit. * * @return string */ public function get_page_title( $page ) { $titles = array( 'inbox' => esc_html__( 'Workflow Inbox', 'gravityflow' ), 'status' => esc_html__( 'Workflow Status', 'gravityflow' ), 'submit' => esc_html__( 'Submit a Workflow Form', 'gravityflow' ), ); return $titles[ $page ]; } }