/** * @deprecated 3.4.0 * @see WP_Theme::get_allowed_on_site() */ function wpmu_get_blog_allowedthemes($blog_id = 0) { _deprecated_function(__FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()'); return array_map('intval', WP_Theme::get_allowed_on_site($blog_id)); }
/** * Returns an array of WP_Theme objects based on the arguments. * * Despite advances over get_themes(), this function is quite expensive, and grows * linearly with additional themes. Stick to wp_get_theme() if possible. * * @since 3.4.0 * * @param array $args The search arguments. Optional. * - errors mixed True to return themes with errors, false to return themes without errors, null * to return all themes. Defaults to false. * - allowed mixed (Multisite) True to return only allowed themes for a site. False to return only * disallowed themes for a site. 'site' to return only site-allowed themes. 'network' * to return only network-allowed themes. Null to return all themes. Defaults to null. * - blog_id int (Multisite) The blog ID used to calculate which themes are allowed. Defaults to 0, * synonymous for the current blog. * @return Array of WP_Theme objects. */ function wp_get_themes($args = array()) { global $wp_theme_directories; $defaults = array('errors' => false, 'allowed' => null, 'blog_id' => 0); $args = wp_parse_args($args, $defaults); $theme_directories = search_theme_directories(); if (count($wp_theme_directories) > 1) { // Make sure the current theme wins out, in case search_theme_directories() picks the wrong // one in the case of a conflict. (Normally, last registered theme root wins.) $current_theme = get_stylesheet(); if (isset($theme_directories[$current_theme])) { $root_of_current_theme = get_raw_theme_root($current_theme); if (!in_array($root_of_current_theme, $wp_theme_directories)) { $root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme; } $theme_directories[$current_theme]['theme_root'] = $root_of_current_theme; } } if (empty($theme_directories)) { return array(); } if (is_multisite() && null !== $args['allowed']) { $allowed = $args['allowed']; if ('network' === $allowed) { $theme_directories = array_intersect_key($theme_directories, WP_Theme::get_allowed_on_network()); } elseif ('site' === $allowed) { $theme_directories = array_intersect_key($theme_directories, WP_Theme::get_allowed_on_site($args['blog_id'])); } elseif ($allowed) { $theme_directories = array_intersect_key($theme_directories, WP_Theme::get_allowed($args['blog_id'])); } else { $theme_directories = array_diff_key($theme_directories, WP_Theme::get_allowed($args['blog_id'])); } } $themes = array(); static $_themes = array(); foreach ($theme_directories as $theme => $theme_root) { // XTEC ************ AFEGIT - Hide reactor at the theme selector // 2014.08.29 @sarjona if ($theme == 'reactor') { break; } //************ FI if (isset($_themes[$theme_root['theme_root'] . '/' . $theme])) { $themes[$theme] = $_themes[$theme_root['theme_root'] . '/' . $theme]; } else { $themes[$theme] = $_themes[$theme_root['theme_root'] . '/' . $theme] = new WP_Theme($theme, $theme_root['theme_root']); } } if (null !== $args['errors']) { foreach ($themes as $theme => $wp_theme) { if ($wp_theme->errors() != $args['errors']) { unset($themes[$theme]); } } } return $themes; }
/** * Utility function to get a list of allowed/active theme for the site. * * @since 1.0.0 * @see * * @param int $blog_id only used if multisite * @return array of allowed themes */ function snapshot_utility_get_blog_active_themes($blog_id=0) { // Get All themes in the system. $themes_all = wp_get_themes(); /* The get_themes returns an unusable array. So we need to rework it to be able to compare to the array returned from allowedthemes */ foreach($themes_all as $themes_all_key => $themes_all_set) { unset($themes_all[$themes_all_key]); $themes_all[$themes_all_set['Stylesheet']] = $themes_all_set['Name']; } if (is_multisite()) { //$allowed_themes = wpmu_get_blog_allowedthemes( $blog_id ); $allowed_themes = WP_Theme::get_allowed_on_site( $blog_id ); $themes_blog = get_blog_option( $blog_id, 'allowedthemes' ); if (!$themes_blog) $themes_blog = array(); //$site_allowed_themes = get_site_allowed_themes(); $site_allowed_themes = WP_Theme::get_allowed_on_network(); if (!$site_allowed_themes) $site_allowed_themes = array(); $themes_blog = array_merge($themes_blog, $site_allowed_themes); if ((isset($themes_blog)) && (isset($themes_all))) { foreach($themes_all as $themes_all_key => $themes_all_name) { if (!isset($themes_blog[$themes_all_key])) unset($themes_all[$themes_all_key]); } //echo "themes_all<pre>"; print_r($themes_all); echo "</pre>"; asort($themes_all); return $themes_all; } } else { return $themes_all; } }
function bp_groupblog_management_page() { global $wpdb; // only allow site admins to come here. if (is_super_admin() == false) { wp_die(__('You do not have permission to access this page.', 'groupblog')); } // process form submission if (isset($_POST['action']) && $_POST['action'] == 'update') { bp_groupblog_update_defaults(); $updated = true; } else { $updated = false; } // make sure we're using latest data $opt = get_site_option('bp_groupblog_blog_defaults_options'); ?> <?php if ($updated) { ?> <div id="message" class="updated fade"> <p><?php _e('Options saved.', 'groupblog'); ?> </p> </div> <?php } ?> <div class="wrap" style="position: relative"> <h2><?php _e('BuddyPress GroupBlog Settings', 'groupblog'); ?> </h2> <form name="bp-groupblog-setup" id="bp-groupblog-setup" action="" method="post"> <div id="tabctnr"> <ul class="tabnav"> <li><a href="#groupblog_default_theme"><?php _e('Theme', 'groupblog'); ?> </a></li> <li><a href="#groupblog_landing_page"><?php _e('Redirect', 'groupblog'); ?> </a></li> <li><a href="#groupblog_template_layout"><?php _e('Layout', 'groupblog'); ?> </a></li> <li><a href="#groupblog_default_blog_settings"><?php _e('Defaults', 'groupblog'); ?> </a></li> <li><a href="#groupblog_validation_settings"><?php _e('Validation', 'groupblog'); ?> </a></li> <li><a href="#groupblog_about"><?php _e('About', 'groupblog'); ?> </a></li> </ul> <div id='groupblog_default_theme'> <?php $current_groupblog_theme = ''; // get all themes if (function_exists('wp_get_themes')) { // get theme data the WP3.4 way... $themes = wp_get_themes(false, 'network', 0); $ct = wp_get_theme(); $allowed_themes = WP_Theme::get_allowed_on_network(); $blog_allowed_themes = WP_Theme::get_allowed_on_site(); } else { // pre WP3.4 functions $themes = get_themes(); $ct = current_theme_info(); $allowed_themes = get_site_allowed_themes(); $blog_allowed_themes = wpmu_get_blog_allowedthemes(); } if ($allowed_themes == false) { $allowed_themes = array(); } if (is_array($blog_allowed_themes)) { $allowed_themes = array_merge($allowed_themes, $blog_allowed_themes); } if ($wpdb->blogid != 1) { unset($allowed_themes['h3']); } if (isset($allowed_themes[esc_html($ct->stylesheet)]) == false) { $allowed_themes[esc_html($ct->stylesheet)] = true; } reset($themes); foreach ($themes as $key => $theme) { if (isset($allowed_themes[esc_html($theme['Stylesheet'])]) == false) { unset($themes[$key]); } } reset($themes); // get the names of the themes & sort them /* Note: pre-WP3.4 the keys are the theme names. In 3.4, the keys are folder names Fortunately, the magic methods of the object retain backwards compatibility and allow array-style access to work */ $theme_names = array_keys($themes); natcasesort($theme_names); ?> <h3><?php _e('Default Theme', 'groupblog'); ?> </h3> <div id="select-theme"> <label for="theme"><?php _e('Select the default theme for new groupblogs:', 'groupblog'); ?> </label> <select id="theme" name="theme" size="1"> <optgroup label="<?php echo esc_attr(__('GroupBlog Themes:', 'groupblog')); ?> "> <?php $groupblog_themes_options = ''; foreach ($theme_names as $theme_name) { if (in_array('groupblog', (array) $themes[$theme_name]['Tags'])) { $template = $themes[$theme_name]['Template']; $stylesheet = $themes[$theme_name]['Stylesheet']; $title = $themes[$theme_name]['Title']; $selected = ""; if ($opt['theme'] == $template . "|" . $stylesheet) { $selected = "selected = 'selected' "; $current_groupblog_theme = $theme_name; } $groupblog_themes_options .= '<option value="' . $template . "|" . $stylesheet . '"' . $selected . '>' . $title . "</option>"; } } if (!empty($groupblog_themes_options)) { echo $groupblog_themes_options; } else { echo '<option value="" disabled="disabled">' . __('No groupblog-enabled themes available', 'groupblog') . '</option>'; } ?> </optgroup> <optgroup label="<?php echo esc_attr(__('Regular Themes:', 'groupblog')); ?> "> <?php $non_groupblog_themes_options = ''; foreach ($theme_names as $theme_name) { if (!in_array('groupblog', (array) $themes[$theme_name]['Tags'])) { $template = $themes[$theme_name]['Template']; $stylesheet = $themes[$theme_name]['Stylesheet']; $title = $themes[$theme_name]['Title']; $selected = ""; if ($opt['theme'] == $template . "|" . $stylesheet) { $selected = "selected = 'selected' "; $current_groupblog_theme = $theme_name; } $non_groupblog_themes_options .= '<option value="' . $template . "|" . $stylesheet . '"' . $selected . '>' . $title . "</option>"; } } if (!empty($non_groupblog_themes_options)) { echo $non_groupblog_themes_options; } else { echo '<option value="" disabled="disabled">' . __('No regular themes available', 'groupblog') . '</option>'; } ?> </optgroup> <option value="" <?php selected($current_groupblog_theme, ''); ?> ><?php _e('- None selected -', 'groupblog'); ?> </option> </select> </div> <?php if (!empty($current_groupblog_theme)) { ?> <div id="current-theme"> <?php if (isset($themes[$current_groupblog_theme]['Screenshot'])) { ?> <img src="<?php echo $themes[$current_groupblog_theme]['Theme Root URI'] . '/' . $themes[$current_groupblog_theme]['Stylesheet'] . '/' . $themes[$current_groupblog_theme]['Screenshot']; ?> " alt="<?php _e('Current theme preview'); ?> " /> <?php } ?> <div class="alt" id="current-theme-info"> <h4><?php /* translators: 1: theme title, 2: theme version, 3: theme author */ printf(__('%1$s %2$s by %3$s'), $themes[$current_groupblog_theme]['Title'], $themes[$current_groupblog_theme]['Version'], $themes[$current_groupblog_theme]['Author']); ?> </h4> <p class="theme-description"><?php /*print_r ($themes[$current_groupblog_theme]);*/ echo $themes[$current_groupblog_theme]['Description']; ?> </p> </div> </div> <?php } ?> <div class="clear"></div> </div> <div id='groupblog_landing_page'> <h3><?php _e('Default Landing Page', 'groupblog'); ?> </h3> <p><?php _e('The page that is linked to from the "Blog" tab of the Group navigation. Selecting "Disabled" will use the buddypress template included in the plugin, no redirect will take place. The "Home Page" setting will create a redirect to the blog front page. The "Template Page" setting will create a redirect to the blog template page, additionally when using this setting you can choose a specific page template layout in the next tab.', 'groupblog'); ?> </p> <table class="form-table"> <tbody> <tr> <th><?php _e('Redirect Enabled to:', 'groupblog'); ?> </th> <td> <label><input class="info-off" name="bp_groupblog_redirect_blog" id="bp_groupblog_redirect_blog" value="0" type="radio" <?php if ($opt['redirectblog'] == 0) { echo 'checked="checked"'; } ?> > <?php _e('Disabled', 'groupblog'); ?> </label> </td> </tr> <tr> <th></th> <td> <label><input class="info-off" name="bp_groupblog_redirect_blog" id="bp_groupblog_redirect_blog" value="1" type="radio" <?php if ($opt['redirectblog'] == 1) { echo 'checked="checked"'; } ?> > <?php _e('Home Page', 'groupblog'); ?> </label> </td> <tr> <th></th> <td> <label><input class="info-on" name="bp_groupblog_redirect_blog" id="bp_groupblog_redirect_blog" value="2" type="radio" <?php if ($opt['redirectblog'] == 2) { echo 'checked="checked"'; } ?> > <?php _e('Page Template Title: ', 'groupblog'); ?> </label> <input name="bp_groupblog_page_title" id="bp_groupblog_page_title" value="<?php echo $opt['pagetitle']; ?> " size="10" type="text" /> <span class="notice" id="redirect_notice" style="display:none;"> <?php _e('All existing Group Blogs will be automatically updated on each change.', 'groupblog'); ?> </span> <p class="info"><?php _e('The "Template Page" option will create a page on group blogs and links to a template file within your theme. Don\'t worry about the name you choose, we\'ll make sure your page finds it way to the template file. For custom themes make sure to <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates">create</a> this template file manually.', 'groupblog'); ?> </p> </td> </tr> <tr> <th><?php _e('Redirect Group Home:', 'groupblog'); ?> </th> <td> <label for="deep_group_integration"><input name="deep_group_integration" type="checkbox" id="deep_group_integration" value="1" <?php if ($opt['deep_group_integration'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Yes, redirect Group Home to Blog Home', 'groupblog'); ?> </label><p><?php _e('This option will take control of the GROUP home page and redirects it to the BLOG home page. This will enable posting from the group Home using P2 instead of the BuddyPress form.', 'groupblog'); ?> </p> </td> </tr> </tbody> </table> </div> <div id='groupblog_template_layout'> <?php if ($opt['theme'] == 'p2|p2-buddypress') { ?> <h3><?php _e('Template Page Layout', 'groupblog'); ?> </h3> <p class="disabled"><?php _e('Please select the option "Template Page" on the Redirect tab in order to choose a layout.', 'groupblog'); ?> </p> <p class="enabled"><?php _e('Please select a Layout which you would like to use for your Group Blog. Additionally, incombination with "Redirect Group Home" setting you can set this as your Group Home page.', 'groupblog'); ?> </p> <table class="enabled" id="availablethemes" cellspacing="0" cellpadding="0"> <tbody> <tr class="alt"> <td class="available-theme top left"> <?php echo '<img src="' . WP_PLUGIN_URL . '/bp-groupblog/inc/i/screenshot-mag.png">'; ?> <div class="clear"></div> <input name="page_template_layout" id="page_template_layout" value="magazine" type="radio" <?php if ($opt['page_template_layout'] == 'magazine') { echo 'checked="checked"'; } ?> /><h3 style="display:inline;"> <?php _e('Magazine', 'groupblog'); ?> </h3> <p class="description"><?php _e('Balanced template for groups with diverse postings.', 'groupblog'); ?> </p> </td> <td class="available-theme top"> <?php echo '<img src="' . WP_PLUGIN_URL . '/bp-groupblog/inc/i/screenshot-micro.png">'; ?> <div class="clear"></div> <input name="page_template_layout" id="page_template_layout" value="microblog" type="radio" <?php if ($opt['page_template_layout'] == 'microblog') { echo 'checked="checked"'; } ?> /><h3 style="display:inline;"> <?php _e('Microblog', 'groupblog'); ?> </h3> <p class="description"><?php _e('Great for simple listing of posts in a chronological order.', 'groupblog'); ?> </p> </td> </tr> </tbody> </table> <table class="form-table enabled"> <tbody> <tr> <th><?php _e('Group admin layout control:', 'groupblog'); ?> </th> <td> <label for="group_admin_layout"><input name="group_admin_layout" type="checkbox" id="group_admin_layout" value="1" <?php if ($opt['group_admin_layout'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Allow group admins to select the layout for their group themselves.', 'groupblog'); ?> </label> </td> </tr> </tbody> </table> <?php } else { ?> <h3><?php _e('Template Page Layout', 'groupblog'); ?> </h3> <p><?php _e('Layout options are only available for the "P2 BuddyPress" Theme. Please select the "P2 Buddypress" theme on the "Theme" tab in order to choose a layout. Additionally the Redirect option needs to be set to "Template Page".', 'groupblog'); ?> </p> <?php } ?> </div> <div id='groupblog_default_blog_settings'> <h3><?php _e('Default Blog Settings', 'groupblog'); ?> </h3> <table class="form-table"> <tbody> <tr valign="top"> <th><?php _e('Default Post Category:', 'groupblog'); ?> </th> <td> <input name="default_cat_name" type="text" id="default_cat_name" size="30" value="<?php echo $opt['default_cat_name']; ?> " /> <?php _e('(Overwrites "Uncategorized")', 'groupblog'); ?> </td> </tr> <tr valign="top"> <th><?php _e('Default Link Category:', 'groupblog'); ?> </th> <td> <input name="default_link_cat" type="text" id="default_link_cat" size="30" value="<?php echo $opt['default_link_cat']; ?> " /> <?php _e('(Overwrites "Blogroll")', 'groupblog'); ?> </td> </tr> <tr> <th><?php _e('Set First Post to Draft', 'groupblog'); ?> </th> <td> <label for="delete_first_post"> <input name="delete_first_post" type="checkbox" id="delete_first_post" value="1" <?php if ($opt['delete_first_post'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Yes', 'groupblog'); ?> <?php _e('(Default Post "Hello World")', 'groupblog'); ?> </label> </td> </tr> <tr> <th><?php _e('Delete Initial Comment', 'groupblog'); ?> </th> <td> <label for="delete_first_comment"> <input name="delete_first_comment" type="checkbox" id="delete_first_comment" value="1" <?php if ($opt['delete_first_comment'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Yes', 'groupblog'); ?> </label> </td> </tr> <tr> <th><?php _e('Delete Blogroll Links', 'groupblog'); ?> </th> <td> <label for="delete_blogroll_links"> <input name="delete_blogroll_links" type="checkbox" id="delete_blogroll_links" value="1" <?php if ($opt['delete_blogroll_links'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Yes', 'groupblog'); ?> </label> </td> </tr> </tbody> </table> </div> <div id='groupblog_validation_settings'> <h3><?php _e('Validation Settings', 'groupblog'); ?> </h3> <div><?php _e('Change the default WordPress blog validation settings.', 'groupblog'); ?> </div> <table class="form-table"> <tbody> <tr> <th><?php _e('Allow:', 'groupblog'); ?> </th> <td> <label for="bp_groupblog_allowdashes"> <input name="bp_groupblog_allowdashes" type="checkbox" id="bp_groupblog_allowdashes" value="1" <?php if ($opt['allowdashes'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Dashes', 'groupblog'); ?> <?php _e('(Default: Not Allowed)', 'groupblog'); ?> </label> </td> </tr> <tr> <th></th> <td> <label for="bp_groupblog_allowunderscores"> <input name="bp_groupblog_allowunderscores" type="checkbox" id="bp_groupblog_allowunderscores" value="1" <?php if ($opt['allowunderscores'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('Underscores', 'groupblog'); ?> <?php _e('(Default: Not Allowed)', 'groupblog'); ?> </label> </td> </tr> <tr> <th></th> <td> <label for="bp_groupblog_allownumeric"> <input name="bp_groupblog_allownumeric" type="checkbox" id="bp_groupblog_allownumeric" value="1" <?php if ($opt['allownumeric'] == 1) { echo 'checked="checked"'; } ?> /> <?php _e('All Numeric Names', 'groupblog'); ?> <?php _e('(Default: Not Allowed)', 'groupblog'); ?> </label> </td> </tr> <tr> <th><?php _e('Minimum Length:', 'groupblog'); ?> </th> <td> <input name="bp_groupblog_minlength" style="width: 10%;" id="bp_groupblog_minlenth" value="<?php echo $opt['minlength']; ?> " size="10" type="text" /> <?php _e('(Default: 4 Characters)', 'groupblog'); ?> </td> </tr> </tbody> </table> </div> <div id='groupblog_about'> <h3><?php _e('About This PLugin', 'groupblog'); ?> </h3> <div> <span class="indent"><strong><?php _e('Authors', 'groupblog'); ?> </strong></span> <span><a href="http://oomsonline.com">Marius Ooms</a> & <a href="http://blevins.nl">Rodney Blevins</a></span> </div> <div> <span class="indent"><strong><?php _e('Donate', 'groupblog'); ?> </strong></span> <span><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7374704"><?php _e('PayPal', 'groupblog'); ?> </a></span> </div> <div> <span class="indent"><strong><?php _e('Support', 'groupblog'); ?> </strong></span> <span><a href="http://buddypress.org/forums/"><?php _e('BuddyPress Forums', 'groupblog'); ?> </a> | <a href="http://wordpress.org/tags/bp-groupblog?forum_id=10"><?php _e('WordPress Forums', 'groupblog'); ?> </a></span> </div> <div> <span class="indent"><strong><?php _e('Trac', 'groupblog'); ?> </strong></span> <span><a href="http://plugins.trac.wordpress.org/log/bp-groupblog"><?php _e('Revision Log', 'groupblog'); ?> </a> | <a href="http://plugins.trac.wordpress.org/browser/bp-groupblog/"><?php _e('Trac Browser', 'groupblog'); ?> </a></span> </div> <div> <span class="indent"><strong><?php _e('Rate', 'groupblog'); ?> </strong></span> <span><a href="http://wordpress.org/extend/plugins/bp-groupblog/"><?php _e('Let everyone know! Only if you like it :)', 'groupblog'); ?> </a></span> </div> <hr /> <div> <span class="indent"><strong><?php _e('Acknowledgement', 'groupblog'); ?> </strong></span> <span><?php _e('Thanks goes out to the following people:', 'groupblog'); ?> </span> <ul id="acknowledge"> <li><a href="http://buddypress.org/developers/apeatling/">Andy Peatling</a></li> <li>Thijs Huijssoon</li> <li><a href="http://deannaschneider.wordpress.com/">Deanna Schneider</a></li> <li><a href="http://buddypress.org/developers/boonebgorges/">Boone Gorges</a></li> <li><a href="http://wordpress.org/support/profile/5499080">Luiz Armesto</a></li> <li><a href="http://buddypress.org/developers/burtadsit/">Burt Adsit</a></li> </ul> </div> </div> </div> <p class="submit"> <input type="hidden" name="action" value="update" /> <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes', 'groupblog'); ?> " /> </p> </form> </div> <?php }