32 | | /** |
33 | | * Outputs the markup for the bb-forums-admin panel |
34 | | */ |
35 | | function bp_forums_bbpress_admin() { |
36 | | |
37 | | // The text and URL of the Site Wide Forums button differs depending on whether bbPress |
38 | | // is running |
39 | | if ( is_plugin_active( 'bbpress/bbpress.php' ) ) { |
40 | | // The bbPress admin page will always be on the root blog. switch_to_blog() will |
41 | | // pass through if we're already there. |
42 | | switch_to_blog( bp_get_root_blog_id() ); |
43 | | $button_url = admin_url( add_query_arg( array( 'page' => 'bbpress' ), 'options-general.php' ) ); |
44 | | restore_current_blog(); |
45 | | |
46 | | $button_text = __( 'Configure Site Wide Forums', 'buddypress' ); |
47 | | } else { |
48 | | $button_url = bp_get_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); |
49 | | $button_text = __( 'Install Site Wide Forums', 'buddypress' ); |
50 | | } |
51 | | |
52 | | $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?> |
53 | | |
54 | | <div class="wrap"> |
55 | | <?php screen_icon( 'buddypress' ); ?> |
56 | | |
57 | | <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Forums', 'buddypress' ) ); ?></h2> |
58 | | |
59 | | <?php if ( isset( $_POST['submit'] ) ) : ?> |
60 | | |
61 | | <div id="message" class="updated fade"> |
62 | | <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p> |
63 | | </div> |
64 | | |
65 | | <?php endif; ?> |
66 | | |
67 | | <?php |
68 | | |
69 | | if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) : |
70 | | |
71 | | // Delete the bb-config.php location option |
72 | | bp_delete_option( 'bb-config-location' ); |
73 | | |
74 | | // Now delete the bb-config.php file |
75 | | @unlink( ABSPATH . 'bb-config.php' ); |
76 | | |
77 | | // show the updated wizard |
78 | | bp_forums_bbpress_install_wizard(); |
79 | | |
80 | | else : ?> |
81 | | |
82 | | <div style="width: 45%; float: left; margin-top: 20px;"> |
83 | | <h3><?php _e( '(Installed)', 'buddypress' ); ?> <?php _e( 'Forums for Groups', 'buddypress' ) ?></h3> |
84 | | |
85 | | <p><?php _e( 'Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.' , 'buddypress' ); ?></p> |
86 | | <p class="description"><?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?></p> |
87 | | |
88 | | <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> |
89 | | <ul class="description" style="list-style: square; margin-left: 30px;"> |
90 | | <li><?php _e( 'Group Integration', 'buddypress' ); ?></p></li> |
91 | | <li><?php _e( 'Member Profile Integration', 'buddypress' ); ?></p></li> |
92 | | <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> |
93 | | <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> |
94 | | </ul> |
95 | | |
96 | | <div> |
97 | | <a class="button button-primary confirm" href="<?php echo $action ?>"><?php _e( 'Uninstall Group Forums', 'buddypress' ) ?></a> |
98 | | </div> |
99 | | </div> |
100 | | |
101 | | <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;"> |
102 | | <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3> |
103 | | <p><?php _e( 'Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress' ) ?></p> |
104 | | <p class="description"><?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?></p> |
105 | | |
106 | | <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> |
107 | | <ul class="description" style="list-style: square; margin-left: 30px;"> |
108 | | <li><?php _e( 'Central Discussion Area', 'buddypress' ); ?></p></li> |
109 | | <li><?php _e( 'Forum Plugins Available', 'buddypress' ); ?></p></li> |
110 | | <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> |
111 | | <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> |
112 | | </ul> |
113 | | |
114 | | <div> |
115 | | <a class="button thickbox button-primary" href="<?php echo esc_attr( $button_url ) ?>"><?php echo esc_html( $button_text ) ?></a> |
116 | | </div> |
117 | | </div> |
118 | | |
119 | | <?php endif; ?> |
120 | | |
121 | | <p class="clear description"><?php printf( __( 'Need help deciding between Group Forums and Site Wide Forums? Visit <a href="%s">the BuddyPress codex</a> for more information.', 'buddypress' ), 'http://codex.buddypress.org/getting-started/installing-group-and-sitewide-forums/' ) ?></p> |
122 | | </div> |
123 | | <?php |
124 | | } |
125 | | |
126 | | function bp_forums_bbpress_install_wizard() { |
127 | | $post_url = bp_get_admin_url( 'admin.php?page=bb-forums-setup' ); |
128 | | $bbpress_plugin_is_active = false; |
129 | | |
130 | | $step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : ''; |
131 | | |
132 | | // The text and URL of the Site Wide Forums button differs depending on whether bbPress |
133 | | // is running |
134 | | if ( is_plugin_active( 'bbpress/bbpress.php' ) ) { |
135 | | $bbpress_plugin_is_active = true; |
136 | | |
137 | | // The bbPress admin page will always be on the root blog. switch_to_blog() will |
138 | | // pass through if we're already there. |
139 | | switch_to_blog( bp_get_root_blog_id() ); |
140 | | $button_url = admin_url( add_query_arg( array( 'page' => 'bbpress' ), 'options-general.php' ) ); |
141 | | restore_current_blog(); |
142 | | |
143 | | $button_text = __( 'Configure Site Wide Forums', 'buddypress' ); |
144 | | } else { |
145 | | $button_url = bp_get_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); |
146 | | $button_text = __( 'Install Site Wide Forums', 'buddypress' ); |
147 | | } |
148 | | |
149 | | switch( $step ) { |
150 | | case 'existing': |
151 | | if ( isset( $_REQUEST['doinstall'] ) && ( 1 == (int) $_REQUEST['doinstall'] ) ) { |
152 | | if ( !bp_forums_configure_existing_install() ) { |
153 | | _e( 'The bb-config.php file was not found at that location, please try again.', 'buddypress' ); |
154 | | } else { |
155 | | ?> |
156 | | <h3><?php _e( 'Forums were set up correctly using your existing bbPress install!', 'buddypress' ) ?></h3> |
157 | | <p><?php _e( 'BuddyPress will now use its internal copy of bbPress to run the forums on your site. If you wish, you can remove your old bbPress installation files, as long as you keep the bb-config.php file in the same location.', 'buddypress' ) ?></p><?php |
158 | | } |
159 | | } else { ?> |
160 | | |
161 | | <form action="" method="post"> |
162 | | <h3><?php _e( 'Existing bbPress Installation', 'buddypress' ) ?></h3> |
163 | | <p><?php _e( "BuddyPress can make use of your existing bbPress install. Just provide the location of your <code>bb-config.php</code> file, and BuddyPress will do the rest.", 'buddypress' ) ?></p> |
164 | | <p><label><code>bb-config.php</code> file location:</label><br /><input style="width: 50%" type="text" name="bbconfigloc" id="bbconfigloc" value="<?php echo str_replace( 'buddypress', '', $_SERVER['DOCUMENT_ROOT'] ) ?>" /></p> |
165 | | <p><input type="submit" class="button-primary" value="<?php _e( 'Complete Installation', 'buddypress' ) ?>" /></p> |
166 | | <input type="hidden" name="step" value="existing" /> |
167 | | <input type="hidden" name="doinstall" value="1" /> |
168 | | <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?> |
169 | | </form> |
170 | | |
171 | | <?php |
172 | | } |
173 | | break; |
174 | | |
175 | | case 'new': |
176 | | if ( isset( $_REQUEST['doinstall'] ) && 1 == (int)$_REQUEST['doinstall'] ) { |
177 | | $result = bp_forums_bbpress_install(); |
178 | | |
179 | | switch ( $result ) { |
180 | | case 1: |
181 | | _e( '<p>All done! Configuration settings have been saved to the file <code>bb-config.php</code> in the root of your WordPress install.</p>', 'buddypress' ); |
182 | | break; |
183 | | default: |
184 | | // Just write the contents to screen |
185 | | _e( '<p>A configuration file could not be created. No problem, but you will need to save the text shown below into a file named <code>bb-config.php</code> in the root directory of your WordPress installation before you can start using the forum functionality.</p>', 'buddypress' ); ?> |
186 | | |
187 | | <textarea style="display:block; margin-top: 30px; width: 80%;" rows="50"><?php echo htmlspecialchars( $result ); ?></textarea> |
188 | | |
189 | | <?php |
190 | | break; |
191 | | } |
192 | | } else { ?> |
193 | | |
194 | | <h3><?php _e( 'New bbPress Installation', 'buddypress' ) ?></h3> |
195 | | <p><?php _e( "You've decided to set up a new installation of bbPress for forum management in BuddyPress. This is very simple and is usually just a one click |
196 | | process. When you're ready, hit the link below.", 'buddypress' ) ?></p> |
197 | | <p><a class="button-primary" href="<?php echo wp_nonce_url( $post_url . '&step=new&doinstall=1', 'bp_forums_new_install_init' ) ?>"><?php _e( 'Complete Installation', 'buddypress' ) ?></a></p> |
198 | | |
199 | | <?php |
200 | | } |
201 | | break; |
202 | | |
203 | | default: |
204 | | if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?> |
205 | | |
206 | | <div id="message" class="error"> |
207 | | <p><?php printf( __( 'bbPress files were not found. To install the forums component you must download a copy of bbPress and make sure it is in the folder: "%s"', 'buddypress' ), 'wp-content/plugins/buddypress/bp-forums/bbpress/' ) ?></p> |
208 | | </div> |
209 | | |
210 | | <?php } else { |
211 | | |
212 | | // Include the plugin install |
213 | | |
214 | | add_thickbox(); |
215 | | wp_enqueue_script( 'plugin-install' ); |
216 | | wp_admin_css( 'plugin-install' ); |
217 | | ?> |
218 | | |
219 | | <div style="width: 45%; float: left; margin-top: 20px;"> |
220 | | <h3><?php _e( 'Forums for Groups', 'buddypress' ) ?></h3> |
221 | | |
222 | | <p><?php _e( 'Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.' , 'buddypress' ); ?></p> |
223 | | <p class="description"><?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?></p> |
224 | | |
225 | | <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> |
226 | | <ul class="description" style="list-style: square; margin-left: 30px;"> |
227 | | <li><?php _e( 'Group Integration', 'buddypress' ); ?></p></li> |
228 | | <li><?php _e( 'Member Profile Integration', 'buddypress' ); ?></p></li> |
229 | | <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> |
230 | | <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> |
231 | | </ul> |
232 | | |
233 | | <div> |
234 | | <a class="button button-primary" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Install Group Forums', 'buddypress' ) ?></a> |
235 | | <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use Existing Installation', 'buddypress' ) ?></a> |
236 | | </div> |
237 | | </div> |
238 | | |
239 | | <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;"> |
240 | | <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3> |
241 | | <p><?php _e( 'Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress' ) ?></p> |
242 | | <p class="description"><?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?></p> |
243 | | |
244 | | <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> |
245 | | <ul class="description" style="list-style: square; margin-left: 30px;"> |
246 | | <li><?php _e( 'Central Discussion Area', 'buddypress' ); ?></p></li> |
247 | | <li><?php _e( 'Forum Plugins Available', 'buddypress' ); ?></p></li> |
248 | | <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> |
249 | | <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> |
250 | | </ul> |
251 | | <div> |
252 | | <a class="button button-primary <?php if ( ! $bbpress_plugin_is_active ) { echo esc_attr( 'thickbox' ); }?>" href="<?php echo esc_attr( $button_url ) ?>"><?php echo esc_html( $button_text ) ?></a> |
253 | | </div> |
254 | | </div> |
255 | | |
256 | | <?php } |
257 | | break; |
258 | | } |
259 | | } |
260 | | |