/** * Output the BPT admin page */ function bp_tpack_theme_menu() { if (!empty($_GET['finish'])) { update_option('bp_tpack_configured', 1); } if (!empty($_GET['reset'])) { delete_option('bp_tpack_configured'); } if (!file_exists(get_query_template('bp-tpack', array('activity', 'blogs', 'forums', 'groups', 'members', 'registration')))) { $step = 1; if (!empty($_GET['move'])) { $step = 2; $error = false; /* Attempt to move the directories */ if (!bp_tpack_move_templates()) { $error = true; } } /* Make sure we reset if template files have been deleted. */ delete_option('bp_tpack_configured'); } else { $step = 3; } if (!empty($_POST['bp_tpack_save'])) { /* Save options */ if (!empty($_POST['bp_tpack_disable_css'])) { update_option('bp_tpack_disable_css', 1); } else { delete_option('bp_tpack_disable_css'); } if (!empty($_POST['bp_tpack_disable_js'])) { update_option('bp_tpack_disable_js', 1); } else { delete_option('bp_tpack_disable_js'); } } if (!(int) get_option('bp_tpack_configured')) { ?> <div class="wrap"> <h2><?php _e('Making Your Theme BuddyPress Compatible', 'bp-tpack'); ?> </h2> <p><?php _e('Adding support for BuddyPress to your existing WordPress theme is a straightforward process. Follow the setup instructions on this page.', 'bp-tpack'); ?> </p> <?php switch ($step) { case 1: ?> <h2><?php _e('Step One: Moving template files automatically', 'bp-tpack'); ?> </h2> <p><?php _e('BuddyPress needs some extra template files in order to display its pages correctly. This plugin will attempt to automatically move the necessary files into your current theme.', 'bp-tpack'); ?> </p> <p><?php _e('Click the button below to start the process.', 'bp-tpack'); ?> </p> <p><a class="button" href="?page=bp-tpack-options&move=1"><?php _e('Move Template Files', 'bp-tpack'); ?> </a></p> <?php break; ?> <?php case 2: ?> <?php if ($error) { ?> <h2><?php _e('Step Two: Moving templates manually', 'bp-tpack'); ?> </h2> <p><?php _e("<strong>Moving templates failed.</strong> There was an error when trying to move the templates automatically. This probably means that we don't have the correct permissions. That's all right - it just means you'll have to move the template files manually.", 'bp-tpack'); ?> </p> <p><?php _e('You will need to connect to your WordPress files using FTP. When you are connected browse to the following directory:', 'bp-tpack'); ?> <p> <p><code><?php echo BP_PLUGIN_DIR . '/bp-themes/bp-default/'; ?> </code></p> <p><?php _e('In this directory you will find six folders (/activity/, /blogs/, /forums/, /groups/, /members/, /registration/). If you want to use all of the features of BuddyPress then you must move these six directories to the following folder:', 'bp-tpack'); ?> </p> <p><code><?php echo get_stylesheet_directory() . '/'; ?> </code></p> <p><?php _e("If you decide that you don't want to use a feature of BuddyPress, then you can actually ignore the template folders for these features. For example, if you don't want to use the groups and forums features, you can simply avoid copying the /groups/ and /forums/ template folders to your active theme. (If you're not sure what to do, just copy all six folders over to your theme directory.)", 'bp-tpack'); ?> </p> <p><?php _e('Once you have correctly copied the folders into your active theme, please use the button below to move onto step three.', 'bp-tpack'); ?> </p> <p><a href="?page=bp-tpack-options" class="button"><?php _e("I've finished moving template folders", 'bp-tpack'); ?> </a></p> <?php } else { ?> <h2><?php _e('Templates moved successfully!', 'bp-tpack'); ?> </h2> <p><?php _e('Great news! BuddyPress templates are now in the correct position in your theme, which means that we can skip Step Two: Moving Templates Manually, and move directly to Step Three. Cool!', 'bp-tpack'); ?> </p> <p><a class="button" href="?page=bp-tpack-options"><?php _e('Continue to Step Three', 'bp-tpack'); ?> </a></p> <?php } ?> <?php break; ?> <?php case 3: ?> <h2><?php _e('Step Three: Tweaking your layout', 'bp-tpack'); ?> </h2> <p><?php printf(__('Now that the template files are in the correct location, <a href="%s" target="_blank">check out your site</a>. (You can come back to the current page at any time, by visiting Dashboard > Appearance > BP Compatibility.) You should see a BuddyPress admin bar at the top of the page. Try visiting some of the links in the "My Account" menu. If everything has gone right up to this point, you should be able to see your BuddyPress content.', 'bp-tpack'), get_bloginfo('url')); ?> </p> <p><?php _e('If you find that the pages are not quite aligned correctly, or the content is overlapping the sidebar, you may need to tweak the template HTML. Please follow the "fixing alignment" instructions below. If the content in your pages is aligned to your satisfaction, then you can skip to the "Finishing Up" section at the bottom of this page.', 'bp-tpack'); ?> </p> <h3><?php _e('Fixing Alignment', 'bp-tpack'); ?> </h3> <p><?php _e('By default BuddyPress templates use this HTML structure:', 'bp-tpack'); ?> </p> <p><pre><code style="display: block; width: 40%; padding-left: 15px;"> [HEADER] <div id="container"> <div id="content"> [PAGE CONTENT] </div> <div id="sidebar"> [SIDEBAR CONTENT] </div> </div> [FOOTER] </code></pre></p> <p><?php _e("If BuddyPress pages are not aligned correctly, then you may need to modify some of the templates to match your theme's HTML structure. The best way to do this is to access your theme's files, via FTP, at:", 'bp-tpack'); ?> </p> <p><code><?php echo get_stylesheet_directory() . '/'; ?> </code></p> <p><?php _e('Open up the <code>page.php</code> file (if this does not exist, use <code>index.php</code>). Make note of the HTML template structure of the file, specifically the <code><div></code> tags that surround the content and sidebar.', 'bp-tpack'); ?> </p> <p><?php _e('You will need to change the HTML structure in the BuddyPress templates that you copied into your theme to match the structure in your <code>page.php</code> or <code>index.php</code> file.', 'bp-tpack'); ?> </p> <?php if (version_compare(BP_VERSION, '1.3') > 0) { ?> <p><?php _e("There are two methods for making the necessary template changes.", 'bp-tpack'); ?> </p> <ol> <li> <?php _e("The first method is to locate the following templates (leave out any folders that you didn't copy over in Step Two):", 'bp-tpack'); ?> <?php } else { ?> <p><?php _e('The files that you need to edit are as follows (leave out any folders you have not copied over in step two):', 'bp-tpack'); ?> </p> <?php } ?> <ul style="list-style: disc; margin-left: 40px;"> <li><code><?php echo '/activity/index.php'; ?> </code></li> <li><code><?php echo '/blogs/index.php'; ?> </code></li> <li><code><?php echo '/forums/index.php'; ?> </code></li> <li><code><?php echo '/groups/index.php'; ?> </code></li> <li><code><?php echo '/groups/create.php'; ?> </code></li> <li><code><?php echo '/groups/single/home.php'; ?> </code></li> <li><code><?php echo '/groups/single/plugins.php'; ?> </code></li> <li><code><?php echo '/members/index.php'; ?> </code></li> <li><code><?php echo '/members/single/home.php'; ?> </code></li> <li><code><?php echo '/members/single/plugins.php'; ?> </code></li> <li><code><?php echo '/members/single/settings/delete-account.php'; ?> </code></li> <li><code><?php echo '/members/single/settings/notifications.php'; ?> </code></li> <li><code><?php echo '/members/single/settings/general.php'; ?> </code></li> <li><code><?php echo '/registration/register.php'; ?> </code></li> <li><code><?php echo '/registration/activate.php'; ?> </code></li> <?php if (is_multisite()) { ?> <li><code><?php echo '/blogs/create.php'; ?> </code></li> <?php } ?> </ul> <?php if (version_compare(BP_VERSION, '1.3') > 0) { ?> </li> <li> <p><?php _e("Alternatively, you may find it easier to make copies of your theme's <code>header.php</code>, <code>sidebar.php</code> and <code>footer.php</code> and rename them to <code>header-buddypress.php</code>, <code>sidebar-buddypress.php</code>, and <code>footer-buddypress.php</code>.", 'bp-tpack'); ?> </p> <p><?php _e("Then you can alter the structure of these new template files (<code>header-buddypress.php</code>, <code>sidebar-buddypress.php</code>, and <code>footer-buddypress.php</code>) to resemble your theme's <code>page.php</code> (or <code>index.php</code>).", 'bp-tpack'); ?> </p> </li> </ol> <?php } ?> <p><?php _e('Once you are done matching up the HTML structure of your theme in these template files, please take another look through your site. You should find that BuddyPress pages now fit inside the content structure of your theme.', 'bp-tpack'); ?> </p> <h3><?php _e('Finishing Up', 'bp-tpack'); ?> </h3> <p><?php _e("You're now all done with the conversion process. Your WordPress theme will now happily provide BuddyPress compatibility support. Once you hit the finish button you will be presented with a new permanent theme options page, which will allow you to tweak some settings.", 'bp-tpack'); ?> </p> <p><a href="?page=bp-tpack-options&finish=1" class="button-primary"><?php _e('Finish', 'bp-tpack'); ?> </a></p> <p> </p> <?php break; ?> <?php } ?> </div> <?php } else { // The theme steps have been completed, just show the permanent page ?> <div class="wrap"> <h2><?php _e('BuddyPress Theme Compatibility', 'bp-tpack'); ?> </h2> <?php if (!empty($_GET['finish'])) { ?> <div id="message"> <p><strong><?php _e('Congratulations, you have completed the BuddyPress theme compatibility setup procedure!', 'bp-tpack'); ?> </strong></p> </div> <?php } ?> <form action="" name="bp-tpack-settings" method="post" style="width: 60%; float: left; margin-right: 3%;"> <p><strong><input type="checkbox" name="bp_tpack_disable_css" value="1"<?php if ((int) get_option('bp_tpack_disable_css')) { ?> checked="checked"<?php } ?> /> <?php _e('Disable BP Template Pack CSS', 'bp-tpack'); ?> </strong></p> <p> <small style="display: block; margin-left:18px; font-size: 11px"><?php _e("The BuddyPress template pack comes with basic wireframe CSS styles that will format the layout of BuddyPress pages. You can extend upon these styles in your theme's CSS file, or simply turn them off and build your own styles.", 'bp-tpack'); ?> </small> </p> <p style="margin-top: 20px;"><strong><input type="checkbox" name="bp_tpack_disable_js" value="1"<?php if ((int) get_option('bp_tpack_disable_js')) { ?> checked="checked"<?php } ?> /> <?php _e('Disable BP Template Pack JS / AJAX', 'bp-tpack'); ?> </strong></p> <small style="display: block; margin-left:18px; font-size: 11px"><?php _e('The BuddyPress template pack will automatically integrate the BuddyPress default theme javascript and AJAX functionality into your theme. You can switch this off, however the experience will be somewhat degraded.', 'bp-tpack'); ?> </small> <p class="submit"> <input type="submit" name="bp_tpack_save" value="<?php _e('Save Settings', 'bp-tpack'); ?> " class="button" /> </p> </form> <div style="float: left; width: 37%;"> <?php /* In BP 1.5+, we remove the "BuddyPress is ready" message dynamically */ ?> <?php if (version_compare(BP_VERSION, '1.3') <= 0) { ?> <p style="line-height: 180%; border: 1px solid #eee; background: #fff; padding: 5px 10px;"><?php _e('<strong>NOTE:</strong> To remove the "BuddyPress is ready" message you will need to add a "buddypress" tag to your theme. You can do this by editing the <code>style.css</code> file of your active theme and adding the tag to the "Tags:" line in the comment header.', 'bp-tpack'); ?> </p> <?php } ?> <h4><?php _e('Navigation Links', 'bp-tpack'); ?> </h4> <p><?php _e('You may want to add new navigation tabs or links to your theme to link to BuddyPress directory pages. The default set of links are:', 'bp-tpack'); ?> </p> <ul> <?php if (bp_is_active('activity')) { ?> <li><?php _e('Activity', 'bp-tpack'); ?> : <a href="<?php echo get_option('home') . '/' . bp_get_root_slug(BP_ACTIVITY_SLUG) . '/'; ?> "><?php echo get_option('home') . '/' . BP_ACTIVITY_SLUG . '/'; ?> </a></li> <?php } ?> <li><?php _e('Members', 'bp-tpack'); ?> : <a href="<?php echo get_option('home') . '/' . bp_get_root_slug(BP_MEMBERS_SLUG) . '/'; ?> "><?php echo get_option('home') . '/' . BP_MEMBERS_SLUG . '/'; ?> </a></li> <?php if (bp_is_active('groups')) { ?> <li><?php _e('Groups', 'bp-tpack'); ?> : <a href="<?php echo get_option('home') . '/' . bp_get_root_slug(BP_GROUPS_SLUG) . '/'; ?> "><?php echo get_option('home') . '/' . BP_GROUPS_SLUG . '/'; ?> </a></li> <?php } ?> <?php if (bp_is_active('forums')) { ?> <li><?php _e('Forums', 'bp-tpack'); ?> : <a href="<?php echo get_option('home') . '/' . bp_get_root_slug(BP_FORUMS_SLUG) . '/'; ?> "><?php echo get_option('home') . '/' . BP_FORUMS_SLUG . '/'; ?> </a></li> <?php } ?> <li><?php _e('Register', 'bp-tpack'); ?> : <a href="<?php echo get_option('home') . '/' . bp_get_root_slug(BP_REGISTER_SLUG) . '/'; ?> "><?php echo get_option('home') . '/' . BP_REGISTER_SLUG . '/'; ?> </a> <?php _e('(registration must be enabled)', 'bp-tpack'); ?> </li> <?php if (is_multisite() && bp_is_active('blogs')) { ?> <li><?php _e('Blogs', 'bp-tpack'); ?> : <a href="<?php echo get_option('home') . '/' . bp_get_root_slug(BP_BLOGS_SLUG) . '/'; ?> "><?php echo get_option('home') . '/' . BP_BLOGS_SLUG . '/'; ?> </a></li> <?php } ?> </ul> <h4><?php _e('Reset Setup', 'bp-tpack'); ?> </h4> <p><?php _e("If you would like to run through the setup process again please use the reset button (you will start at step three if you haven't removed the template files):", 'bp-tpack'); ?> </p> <p><a class="button" href="?page=bp-tpack-options&reset=1"><?php _e('Reset', 'bp-tpack'); ?> </a></p> </div> <?php } }
function bp_tpack_theme_menu() { $theme_dir = WP_CONTENT_DIR . '/themes/' . get_option('stylesheet') . '/'; if (!empty($_GET['finish'])) { update_option('bp_tpack_configured', 1); } if (!empty($_GET['reset'])) { delete_option('bp_tpack_configured'); } if (!file_exists($theme_dir . 'activity') && !file_exists($theme_dir . 'blogs') && !file_exists($theme_dir . 'forums') && !file_exists($theme_dir . 'groups') && !file_exists($theme_dir . 'members') && !file_exists($theme_dir . 'registration')) { $step = 1; if (!empty($_GET['move'])) { $step = 2; $error = false; /* Attempt to move the directories */ if (!bp_tpack_move_templates()) { $error = true; } } /* Make sure we reset if template files have been deleted. */ delete_option('bp_tpack_configured'); } else { $step = 3; } if (!empty($_POST['bp_tpack_save'])) { /* Save options */ if (!empty($_POST['bp_tpack_disable_css'])) { update_option('bp_tpack_disable_css', 1); } else { delete_option('bp_tpack_disable_css'); } if (!empty($_POST['bp_tpack_disable_js'])) { update_option('bp_tpack_disable_js', 1); } else { delete_option('bp_tpack_disable_js'); } } if (!(int) get_option('bp_tpack_configured')) { ?> <div class="wrap"> <h2>Making Your Theme BuddyPress Compatible</h2> <p>Adding support for BuddyPress to your existing WordPress theme is a straightforward process. Follow the setup instructions on this page.</p> <?php switch ($step) { case 1: ?> <h2>Step One</h2> <p>BuddyPress needs some extra template files in order to display its pages correctly. This plugin will attempt to move the necessary files into your current theme. Click the button below to start the process.</p> <p><a class="button" href="?page=bp-tpack-options&move=1">Move Template Files</a></p> <?php break; ?> <?php case 2: ?> <h2>Step Two</h2> <?php if ($error) { ?> <p><strong>Moving templates failed.</strong> There was an error when trying to move the templates automatically. This probably means that we don't have the correct permissions. That's all right - it just means you'll have to move the template files manually.</p> <p>You will need to connect to your WordPress files using FTP. When you are connected browse to the following directory:<p> <p><code><?php echo dirname(__FILE__) . '/templates/'; ?> </code></p> <p>In this directory you will find six folders. If you want to use all of the features of BuddyPress then you must move all six directories to the following folder:</p> <p><code><?php echo $theme_dir; ?> </code></p> <p>If you decide that you don't want to use a feature of BuddyPress then you can actually ignore the template folders for these features. For example, if you don't want to use the groups and forums features, you can simply not copy the /groups/ and /forums/ template folders to your active theme. (If you're not sure what to do, just copy all six folders over to your theme directory.)</p> <p>Once you have correctly copied the folders into your active theme, please use the button below to move onto step three.</p> <p><a href="?page=bp-tpack-options" class="button">I've finished moving template folders</a></p> <?php } else { ?> <p><strong>Templates moved successfully!</strong> Great news! BuddyPress templates are now in the correct position in your theme, which means you can skip step two and <a href="?page=bp-tpack-options">move on to step three</a>.</p> <?php } ?> <?php break; ?> <?php case 3: ?> <h2>Step Three</h2> <p>Now that the template files are in the correct location, click through your site (you can come back to this page at any point). You should see a BuddyPress admin bar at the top of the page. Try visiting some of the links in the "My Account" menu. You should find that BuddyPress pages now work and are displayed.</p> <p>If you find that the pages are not quite aligned correctly, or the content is overlapping the sidebar, you will need to tweak the template HTML. Please follow the "fixing alignment" instructions below. If the content in your pages is aligned in the correct place then you can skip to the "Finishing Up" section at the bottom of this page.</p> <h3>Fixing Alignment</h3> <p>By default BuddyPress templates use this HTML structure:</p> <p><pre><code style="display: block; width: 40%; padding-left: 15px;"> [HEADER] <div id="container"> <div id="content"> [PAGE CONTENT] </div> <div id="sidebar"> [SIDEBAR CONTENT] </div> </div> [FOOTER] </code></pre></p> <p>If BuddyPress pages are not aligned correctly, then you will need to modify some of the templates to match your theme's HTML structure. The best way to do this is to FTP to your theme's files at:</p> <p><code><?php echo $theme_dir; ?> </code></p> <p>Then open up the <code>page.php</code> file (if this does not exist use <code>index.php</code>). Make note of the HTML template structure of the file, specifically the <code><div></code> tags that surround the content and sidebar.</p> <p>You will need to change the HTML structure in the BuddyPress templates that you copied into your theme to match the structure in your <code>page.php</code> or <code>index.php</code> file. The files that you need to edit are as follows (leave out any folders you have not copied over in step two):</p> <ul style="list-style: disc; margin-left: 40px;"> <li><?php echo '/activity/index.php'; ?> </li> <li><?php echo '/blogs/index.php'; ?> </li> <li><?php echo '/forums/index.php'; ?> </li> <li><?php echo '/groups/index.php'; ?> </li> <li><?php echo '/groups/create.php'; ?> </li> <li><?php echo '/groups/single/home.php'; ?> </li> <li><?php echo '/groups/single/plugins.php'; ?> </li> <li><?php echo '/members/index.php'; ?> </li> <li><?php echo '/members/single/home.php'; ?> </li> <li><?php echo '/members/single/plugins.php'; ?> </li> <li><?php echo '/registration/register.php'; ?> </li> <?php if (is_multisite()) { ?> <li><?php echo '/blogs/create.php'; ?> </li> <li><?php echo '/registration/activate.php'; ?> </li> <?php } ?> </ul> <p>Once you are done matching up the HTML structure of your theme in these template files, please take another look through your site. You should find that BuddyPress pages now fit inside the content structure of your theme.</p> <h3>Finishing Up</h3> <p>You're now all done with the conversion process. Your WordPress theme will now happily provide BuddyPress compatibility support. Once you hit the finish button you will be presented with a new permanent theme options page allowing you to tweak some settings.</p> <p><a href="?page=bp-tpack-options&finish=1" class="button-primary">Finish</a></p> <p> </p> <?php break; ?> <?php } ?> </div> <?php } else { // The theme steps have been completed, just show the permanent page ?> <div class="wrap"> <h2>BuddyPress Theme Compatibility</h2> <?php if (!empty($_GET['finish'])) { ?> <div id="message"> <p><strong>Congratulations, you have completed the BuddyPress theme compatibility setup procedure!</strong></p> </div> <?php } ?> <form action="" name="bp-tpack-settings" method="post" style="width: 60%; float: left; margin-right: 3%;"> <p><strong><input type="checkbox" name="bp_tpack_disable_css" value="1"<?php if ((int) get_option('bp_tpack_disable_css')) { ?> checked="checked"<?php } ?> /> Disable BP Template Pack CSS</strong></p> <p> <small style="display: block; margin-left:18px; font-size: 11px">The BuddyPress template pack comes with basic wireframe CSS styles that will format the layout of BuddyPress pages. You can extend upon these styles in your theme's CSS file, or simply turn them off and build your own styles.</small> </p> <p style="margin-top: 20px;"><strong><input type="checkbox" name="bp_tpack_disable_js" value="1"<?php if ((int) get_option('bp_tpack_disable_js')) { ?> checked="checked"<?php } ?> /> Disable BP Template Pack JS / AJAX</strong></p> <small style="display: block; margin-left:18px; font-size: 11px">The BuddyPress template pack will automatically integrate the BuddyPress default theme javascript and AJAX functionality into your theme. You can switch this off, however the experience will be somewhat degraded.</small> <p class="submit"> <input type="submit" name="bp_tpack_save" value="Save Settings" class="button" /> </p> </form> <div style="float: left; width: 37%;"> <p style="line-height: 180%; border: 1px solid #eee; background: #fff; padding: 5px 10px;"><strong>NOTE:</strong> To remove the "BuddyPress is ready" message you will need to add a "buddypress" tag to your theme. You can do this by editing the <code>style.css</code> file of your active theme and adding the tag to the "Tags:" line in the comment header.</p> <h4>Navigation Links</h4> <p>You may want to add new navigation tabs or links to your theme to link to BuddyPress directory pages. The default set of links are:</p> <ul> <li>Activity: <a href="<?php echo get_option('home') . '/' . BP_ACTIVITY_SLUG . '/'; ?> "><?php echo get_option('home') . '/' . BP_ACTIVITY_SLUG . '/'; ?> </a></li> <li>Members: <a href="<?php echo get_option('home') . '/' . BP_MEMBERS_SLUG . '/'; ?> "><?php echo get_option('home') . '/' . BP_MEMBERS_SLUG . '/'; ?> </a></li> <li>Groups: <a href="<?php echo get_option('home') . '/' . BP_GROUPS_SLUG . '/'; ?> "><?php echo get_option('home') . '/' . BP_GROUPS_SLUG . '/'; ?> </a></li> <li>Forums: <a href="<?php echo get_option('home') . '/' . BP_FORUMS_SLUG . '/'; ?> "><?php echo get_option('home') . '/' . BP_FORUMS_SLUG . '/'; ?> </a></li> <li>Register: <a href="<?php echo get_option('home') . '/' . BP_REGISTER_SLUG . '/'; ?> "><?php echo get_option('home') . '/' . BP_REGISTER_SLUG . '/'; ?> </a> (registration must be enabled)</li> <?php if (is_multisite()) { ?> <li>Blogs: <a href="<?php echo get_option('home') . '/' . BP_BLOGS_SLUG . '/'; ?> "><?php echo get_option('home') . '/' . BP_BLOGS_SLUG . '/'; ?> </a></li> <?php } ?> </ul> <h4>Reset Setup</h4> <p>If you would like to run through the setup process again please use the reset button (you will start at step three if you haven't removed the template files):</p> <p><a class="button" href="?page=bp-tpack-options&reset=1">Reset</a></p> </div> <?php } }