/**
  * Verify access to the current content.
  *
  * Related:
  * A reference of available BuddyPress template tags
  * https://codex.buddypress.org/developer/template-tag-reference/
  *
  * @since  1.0.0
  *
  * @param int $id The content post ID to verify access.
  * @return bool|null True if has access, false otherwise.
  *     Null means: Rule not relevant for current page.
  */
 public function has_access($id, $admin_has_access = true)
 {
     global $bp;
     $has_access = null;
     if (!function_exists('bp_current_component')) {
         return null;
     }
     if (is_buddypress()) {
         // Check if access to *all* BuddyPress pages is restricted
         $has_access = parent::has_access(MS_Addon_BuddyPress_Rule::PROTECT_ALL, $admin_has_access);
     }
     if ($has_access) {
         // General BuddyPress access is either *allowed* or *not denied*
         $component = bp_current_component();
         if (!empty($component)) {
             if ('members' == $component || bp_is_user()) {
                 // Member listing or member profile access.
                 $has_access = parent::has_access(MS_Addon_BuddyPress_Rule::PROTECT_MEMBERS, $admin_has_access);
             } elseif ('messages' == $component) {
                 // Private messaging direct access.
                 if ('compose' == $bp->current_action) {
                     $has_access = parent::has_access(MS_Addon_BuddyPress_Rule::PROTECT_PRIVATE_MSG, $admin_has_access);
                 }
             } elseif ('messages' == $component) {
                 // Don't modify, handled by MS_Addon_Buddypress_Rule_Group
             } else {
                 // Other BP pages can be handled by other rules.
                 $has_access = null;
             }
         }
     }
     return apply_filters('ms_rule_buddypress_has_access', $has_access, $id, $this);
 }
Beispiel #2
0
 /**
  * Add class when it's not a BuddyPress page
  *
  * @since 1.0.0
  */
 function wff_base_wordpress_page($classes)
 {
     if (!is_buddypress() && !is_front_page()) {
         // *append* class to the array
         $classes[] = 'wordpress-page';
     }
     // return it!
     return $classes;
 }
 /**
  * Checks if template has BP cell and add filters.
  * 
  * @param type $layout_id
  * @param type $args
  * @return type
  */
 function has_cell($layout_id, $args)
 {
     $layout_settings = WPDD_Layouts::get_layout_settings($layout_id, true);
     $layout_instance = new WPDD_json2layout();
     $layout = $layout_instance->json_decode(wp_json_encode($layout_settings));
     if ($layout->has_cell_of_type('buddypress') && is_buddypress()) {
         // Do something
     }
     return $layout_id;
 }
function myfossil_plugins_nav_below_fix($nav_below)
{
    if (class_exists('bbPress') && is_bbpress()) {
        return;
    }
    if (class_exists('BuddyPress') && is_buddypress()) {
        return;
    }
    return $nav_below;
}
function firmasite_buddypress_wpadminbar_fix()
{
    if (is_buddypress() && is_admin_bar_showing()) {
        ?>
	<script>
	jQuery(document).ready(function() {
		jQuery("body").addClass("admin-bar");
	});
	</script>
	<?php 
    }
}
 /**
  * Get sidebar settings based on the page type
  *
  * @return array
  */
 public function sidebar_options()
 {
     if (is_home()) {
         $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('blog_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('blog_archive_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position'));
     } elseif (function_exists('is_bbpress') && is_bbpress()) {
         $sidebars = array('global' => Avada()->settings->get('bbpress_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position'));
         if (bbp_is_forum_archive() || bbp_is_topic_archive() || bbp_is_user_home() || bbp_is_search()) {
             $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position'));
         }
     } elseif (function_exists('is_buddypress') && is_buddypress()) {
         $sidebars = array('global' => Avada()->settings->get('bbpress_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position'));
     } elseif (class_exists('WooCommerce') && (is_product() || is_shop())) {
         $sidebars = array('global' => Avada()->settings->get('woo_global_sidebar'), 'sidebar_1' => Avada()->settings->get('woo_sidebar'), 'sidebar_2' => Avada()->settings->get('woo_sidebar_2'), 'position' => Avada()->settings->get('woo_sidebar_position'));
     } elseif (class_exists('WooCommerce') && (is_product_category() || is_product_tag())) {
         $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('woocommerce_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('woocommerce_archive_sidebar_2'), 'position' => Avada()->settings->get('woo_sidebar_position'));
     } elseif (is_page()) {
         $sidebars = array('global' => Avada()->settings->get('pages_global_sidebar'), 'sidebar_1' => Avada()->settings->get('pages_sidebar'), 'sidebar_2' => Avada()->settings->get('pages_sidebar_2'), 'position' => Avada()->settings->get('default_sidebar_pos'));
     } elseif (is_single()) {
         $sidebars = array('global' => Avada()->settings->get('posts_global_sidebar'), 'sidebar_1' => Avada()->settings->get('posts_sidebar'), 'sidebar_2' => Avada()->settings->get('posts_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position'));
         if (is_singular('avada_portfolio')) {
             $sidebars = array('global' => Avada()->settings->get('portfolio_global_sidebar'), 'sidebar_1' => Avada()->settings->get('portfolio_sidebar'), 'sidebar_2' => Avada()->settings->get('portfolio_sidebar_2'), 'position' => Avada()->settings->get('portfolio_sidebar_position'));
         } else {
             if (is_singular('tribe_events') || is_singular('tribe_organizer') || is_singular('tribe_venue')) {
                 $sidebars = array('global' => Avada()->settings->get('ec_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ec_sidebar'), 'sidebar_2' => Avada()->settings->get('ec_sidebar_2'), 'position' => Avada()->settings->get('ec_sidebar_pos'));
             }
         }
         if (is_singular('tribe_organizer') || is_singular('tribe_venue')) {
             $sidebars['global'] = 1;
         }
     } elseif (is_archive()) {
         $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('blog_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('blog_archive_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position'));
         if (is_post_type_archive('avada_portfolio') || is_tax('portfolio_category') || is_tax('portfolio_skills') || is_tax('portfolio_tags')) {
             $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('portfolio_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('portfolio_archive_sidebar_2'), 'position' => Avada()->settings->get('portfolio_sidebar_position'));
         }
     } elseif (is_search()) {
         $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('search_sidebar'), 'sidebar_2' => Avada()->settings->get('search_sidebar_2'), 'position' => Avada()->settings->get('search_sidebar_position'));
     } else {
         $sidebars = array('global' => Avada()->settings->get('pages_global_sidebar'), 'sidebar_1' => Avada()->settings->get('pages_sidebar'), 'sidebar_2' => Avada()->settings->get('pages_sidebar_2'), 'position' => Avada()->settings->get('default_sidebar_pos'));
     }
     if (class_exists('Tribe__Events__Main') && is_events_archive()) {
         $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('ec_sidebar'), 'sidebar_2' => Avada()->settings->get('ec_sidebar_2'), 'position' => Avada()->settings->get('ec_sidebar_pos'));
     }
     // Remove sidebars from the certain woocommerce pages
     if (class_exists('WooCommerce')) {
         if (is_cart() || is_checkout() || is_account_page() || get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))) {
             $sidebars = array();
         }
     }
     return $sidebars;
 }
/**
 * Add the secondary BuddyPress area to the my-account menu.
 *
 * @since BuddyPress (1.6.0)
 *
 * @global WP_Admin_Bar $wp_admin_bar
 */
function bp_admin_bar_my_account_root()
{
    global $wp_admin_bar;
    // Bail if this is an ajax request
    if (!bp_use_wp_admin_bar() || defined('DOING_AJAX')) {
        return;
    }
    // Only add menu for logged in user
    if (is_user_logged_in()) {
        // Add secondary parent item for all BuddyPress components
        $wp_admin_bar->add_menu(array('parent' => 'my-account', 'id' => 'my-account-buddypress', 'title' => __('My Account', 'buddypress'), 'group' => true, 'meta' => array('class' => 'ab-sub-secondary')));
        // Remove 'Edit' post link as it's not applicable to BP
        // Remove when https://core.trac.wordpress.org/ticket/29538 is addressed
        if (is_buddypress()) {
            $wp_admin_bar->remove_node('edit');
        }
    }
}
/**
 * Get the redirect link
 * 
 * @package BuddyForms
 * @since 0.3 beta
 */
function bf_members_get_redirect_link($id = false)
{
    global $bp, $buddyforms;
    if (!$id) {
        return false;
    }
    if (!is_buddypress()) {
        return false;
    }
    $link = '';
    if (isset($buddyforms) && is_array($buddyforms)) {
        foreach ($buddyforms as $key => $buddyform) {
            if (isset($buddyform['attached_page'])) {
                $attached_page_id = $buddyform['attached_page'];
            }
            if (isset($buddyform['profiles_integration']) && isset($attached_page_id) && $attached_page_id == $id) {
                // $link = bp_loggedin_user_domain() .$buddyform['slug'].'/';
                $link = bp_loggedin_user_domain() . $bp->current_component . '/';
                // fixed for child sub nav tab
                if (isset($bp->unfiltered_uri[1])) {
                    if ($bp->unfiltered_uri[1] == 'create') {
                        if ($bp->unfiltered_uri[2]) {
                            $link = bp_loggedin_user_domain() . $buddyform['slug'] . '/create/' . $bp->unfiltered_uri[2];
                        } else {
                            $link = bp_loggedin_user_domain() . $buddyform['slug'] . '/create/';
                        }
                    }
                    if ($bp->unfiltered_uri[1] == 'edit') {
                        $link = bp_loggedin_user_domain() . $buddyform['slug'] . '/edit/' . $bp->unfiltered_uri[2] . '/' . $bp->unfiltered_uri[3];
                    }
                    if ($bp->unfiltered_uri[1] == 'revision') {
                        $link = bp_loggedin_user_domain() . $buddyform['slug'] . '/revision/' . $bp->unfiltered_uri[2] . '/' . $bp->unfiltered_uri[3] . '/' . $bp->unfiltered_uri[4];
                    }
                    if ($bp->unfiltered_uri[1] == 'page') {
                        $link = bp_loggedin_user_domain() . $buddyform['slug'] . '/page/' . $bp->unfiltered_uri[2] . '/' . $bp->unfiltered_uri[3];
                    }
                }
            }
        }
    }
    return apply_filters('bf_members_get_redirect_link', $link);
}
/**
 * Customizes the post CSS class according to BuddyPress content.
 *
 * Hooked to the 'post_class' filter.
 *
 * @since 2.1.0
 *
 * @param array $wp_classes The post classes coming from WordPress.
 * @return array
 */
function bp_get_the_post_class($wp_classes = array())
{
    // Don't do anything if we're not on a BP page.
    if (!is_buddypress()) {
        return $wp_classes;
    }
    $bp_classes = array();
    if (bp_is_user() || bp_is_single_activity()) {
        $bp_classes[] = 'bp_members';
    } elseif (bp_is_group()) {
        $bp_classes[] = 'bp_group';
    } elseif (bp_is_activity_component()) {
        $bp_classes[] = 'bp_activity';
    } elseif (bp_is_blogs_component()) {
        $bp_classes[] = 'bp_blogs';
    } elseif (bp_is_register_page()) {
        $bp_classes[] = 'bp_register';
    } elseif (bp_is_activation_page()) {
        $bp_classes[] = 'bp_activate';
    } elseif (bp_is_forums_component() && bp_is_directory()) {
        $bp_classes[] = 'bp_forum';
    }
    if (empty($bp_classes)) {
        return $wp_classes;
    }
    // Emulate post type css class.
    foreach ($bp_classes as $bp_class) {
        $bp_classes[] = "type-{$bp_class}";
    }
    // Okay let's merge!
    return array_unique(array_merge($bp_classes, $wp_classes));
}
/**
 * Force comments_status to 'closed' for BuddyPress post types.
 *
 * @since 1.7.0
 *
 * @param bool $open    True if open, false if closed.
 * @param int  $post_id ID of the post to check.
 *
 * @return bool True if open, false if closed.
 */
function bp_comments_open($open, $post_id = 0)
{
    $retval = is_buddypress() ? false : $open;
    /**
     * Filters whether or not to force comments_status to closed for BuddyPress post types.
     *
     * @since 1.7.0
     *
     * @param bool $retval  Whether or not we are on a BuddyPress post type.
     * @param bool $open    True if comments open, false if closed.
     * @param int  $post_id Post ID for the checked post.
     */
    return apply_filters('bp_force_comment_status', $retval, $open, $post_id);
}
 function mfn_sidebar_classes($has_both = false)
 {
     $classes = false;
     $both = false;
     if (mfn_ID()) {
         if (get_post_type() == 'page' && mfn_opts_get('single-page-layout')) {
             // Theme Options | Single - Page
             $layout = mfn_opts_get('single-page-layout');
         } elseif (get_post_type() == 'post' && is_single() && mfn_opts_get('single-layout')) {
             // Theme Options | Single - Post
             $layout = mfn_opts_get('single-layout');
         } elseif (get_post_type() == 'portfolio' && is_single() && mfn_opts_get('single-portfolio-layout')) {
             // Theme Options | Single - Portfolio
             $layout = mfn_opts_get('single-portfolio-layout');
         } else {
             // Post Meta
             $layout = get_post_meta(mfn_ID(), 'mfn-post-layout', true);
         }
         switch ($layout) {
             case 'left-sidebar':
                 $classes = ' with_aside aside_left';
                 break;
             case 'right-sidebar':
                 $classes = ' with_aside aside_right';
                 break;
             case 'both-sidebars':
                 $classes = ' with_aside aside_both';
                 $both = true;
                 break;
         }
         // demo
         if ($_GET && key_exists('mfn-s', $_GET)) {
             if ($_GET['mfn-s']) {
                 $classes = ' with_aside aside_right';
             } else {
                 $classes = false;
             }
         }
     }
     // WooCommerce
     if (function_exists('is_woocommerce')) {
         if (is_woocommerce()) {
             if ($layout == 'both-sidebars') {
                 // Only one sidebar for shop
                 $classes = ' with_aside aside_right';
             } elseif (!$layout) {
                 // BeTheme version < 6.4 | DO NOT DELETE
                 if (is_active_sidebar('shop')) {
                     $classes = ' with_aside aside_right';
                 }
             }
         }
         if (is_product() && mfn_opts_get('shop-sidebar') == 'shop') {
             $classes = false;
         }
     }
     // bbPress
     if (function_exists('is_bbpress') && is_bbpress() && is_active_sidebar('forum')) {
         $classes = ' with_aside aside_right';
     }
     // BuddyPress
     if (function_exists('is_buddypress') && is_buddypress() && is_active_sidebar('buddy')) {
         $classes = ' with_aside aside_right';
     }
     // Events Calendar
     if (function_exists('tribe_is_month') && is_active_sidebar('events')) {
         if (tribe_is_month() || tribe_is_day() || tribe_is_event() || tribe_is_event_query() || tribe_is_venue()) {
             $classes = ' with_aside aside_right';
         }
     }
     // check if has both sidebars
     if ($has_both) {
         return $both;
     }
     // Page Template: Blank Page, Under Construction
     if (is_page_template('template-blank.php') || is_page_template('under-construction.php')) {
         $classes = false;
     }
     return $classes;
 }
/**
 * Get the layout for the current page
 */
function generate_get_layout()
{
    // Get current post
    global $post;
    // Get Customizer options
    $generate_settings = wp_parse_args(get_option('generate_settings', array()), generate_get_defaults());
    // Set up the layout variable for pages
    $layout = $generate_settings['layout_setting'];
    // Get the individual page/post sidebar metabox value
    $layout_meta = isset($post) ? get_post_meta($post->ID, '_generate-sidebar-layout-meta', true) : '';
    // Set up BuddyPress variable
    $buddypress = false;
    if (function_exists('is_buddypress')) {
        $buddypress = is_buddypress() ? true : false;
    }
    // If we're on the single post page
    // And if we're not on a BuddyPress page - fixes a bug where BP thinks is_single() is true
    if (is_single() && !$buddypress) {
        $layout = null;
        $layout = $generate_settings['single_layout_setting'];
    }
    // If the metabox is set, use it instead of the global settings
    if ('' !== $layout_meta && false !== $layout_meta) {
        $layout = $layout_meta;
    }
    // If we're on the blog, archive, attachment etc..
    if (is_home() || is_archive() || is_search() || is_attachment() || is_tax()) {
        $layout = null;
        $layout = $generate_settings['blog_layout_setting'];
    }
    // Finally, return the layout
    return apply_filters('generate_sidebar_layout', $layout);
}
Beispiel #13
0
<?php

if (barcelona_get_option('sidebar_position') == 'none') {
    return;
}
$barcelona_sidebar = barcelona_get_option('default_sidebar');
if (function_exists('buddypress') && is_buddypress()) {
    $barcelona_sidebar = 'barcelona-buddypress-sidebar';
} else {
    if (function_exists('bbpress') && is_bbpress()) {
        $barcelona_sidebar = 'barcelona-bbpress-sidebar';
    }
}
?>
<aside id="sidebar" class="<?php 
echo esc_attr(barcelona_sidebar_class());
?>
">

	<div class="sidebar-inner">

		<?php 
dynamic_sidebar($barcelona_sidebar);
?>

	</div><!-- .sidebar-inner -->

</aside>
/**
 * Load a specific template file with fallback support.
 *
 * Example:
 *   bp_core_load_template( 'members/index' );
 * Loads:
 *   wp-content/themes/[activated_theme]/members/index.php
 *
 * @param array $templates Array of templates to attempt to load.
 */
function bp_core_load_template($templates)
{
    global $wp_query;
    // Reset the post.
    bp_theme_compat_reset_post(array('ID' => 0, 'is_404' => true, 'post_status' => 'publish'));
    // Set theme compat to false since the reset post function automatically sets
    // theme compat to true.
    bp_set_theme_compat_active(false);
    // Fetch each template and add the php suffix.
    $filtered_templates = array();
    foreach ((array) $templates as $template) {
        $filtered_templates[] = $template . '.php';
    }
    // Only perform template lookup for bp-default themes.
    if (!bp_use_theme_compat_with_current_theme()) {
        $template = locate_template((array) $filtered_templates, false);
        // Theme compat doesn't require a template lookup.
    } else {
        $template = '';
    }
    /**
     * Filters the template locations.
     *
     * Allows plugins to alter where the template files are located.
     *
     * @since 1.1.0
     *
     * @param string $template           Located template path.
     * @param array  $filtered_templates Array of templates to attempt to load.
     */
    $located_template = apply_filters('bp_located_template', $template, $filtered_templates);
    if (!empty($located_template)) {
        // Template was located, lets set this as a valid page and not a 404.
        status_header(200);
        $wp_query->is_page = true;
        $wp_query->is_singular = true;
        $wp_query->is_404 = false;
        /**
         * Fires before the loading of a located template file.
         *
         * @since 1.6.0
         *
         * @param string $located_template Template found to be loaded.
         */
        do_action('bp_core_pre_load_template', $located_template);
        /**
         * Filters the selected template right before loading.
         *
         * @since 1.1.0
         *
         * @param string $located_template Template found to be loaded.
         */
        load_template(apply_filters('bp_load_template', $located_template));
        /**
         * Fires after the loading of a located template file.
         *
         * @since 1.6.0
         *
         * @param string $located_template Template found that was loaded.
         */
        do_action('bp_core_post_load_template', $located_template);
        // Kill any other output after this.
        exit;
        // No template found, so setup theme compatibility.
        // @todo Some other 404 handling if theme compat doesn't kick in.
    } else {
        // We know where we are, so reset important $wp_query bits here early.
        // The rest will be done by bp_theme_compat_reset_post() later.
        if (is_buddypress()) {
            status_header(200);
            $wp_query->is_page = true;
            $wp_query->is_singular = true;
            $wp_query->is_404 = false;
        }
        /**
         * Fires if there are no found templates to load and theme compat is needed.
         *
         * @since 1.7.0
         */
        do_action('bp_setup_theme_compat');
    }
}
function social_warfare_buttons($array = array())
{
    // Setup the default Array parameters
    if (!isset($array['where'])) {
        $array['where'] = 'default';
    }
    if (!isset($array['echo'])) {
        $array['echo'] = true;
    }
    if (!isset($array['content'])) {
        $array['content'] = false;
    }
    // Get the options...or create them if they don't exist
    if (isset($array['post_id'])) {
        $postID = $array['post_id'];
    } else {
        $postID = get_the_ID();
    }
    $options = swp_get_user_options();
    // Check to see if display location was specifically defined for this post
    $specWhere = get_post_meta($postID, 'nc_postLocation', true);
    if (!$specWhere) {
        $specWhere = 'default';
    }
    if ($array['where'] == 'default') {
        // If we are on a single page or post
        if (is_singular() && !is_home() && !is_archive()) {
            // Make sure this is the main loop
            //if( get_permalink( $postID ) == swp_get_current_url() ) :
            // Check if a specific display value has not been set for this specific post
            if ($specWhere == 'default' || $specWhere == '') {
                $postType = get_post_type($postID);
                if (isset($options['location_' . $postType])) {
                    $array['where'] = $options['location_' . $postType];
                } else {
                    $array['where'] = 'none';
                }
            } else {
                $array['where'] = $specWhere;
            }
            // If it's not the main loop
            //else:
            //	$array['where'] = 'none';
            //endif;
            // If we are on an archive or home page
        } else {
            $array['where'] = $options['locationSite'];
        }
    }
    // Disable the buttons on Buddy Press pages
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $array['content'];
        // Disable the buttons if the location is set to "None / Manual"
    } elseif ($array['where'] == 'none' && !isset($array['devs'])) {
        return $array['content'];
        // Disable the button if we're not in the loop, unless there is no content which means the function was called by a developer.
    } elseif ((!is_main_query() || !in_the_loop()) && !isset($array['devs'])) {
        return $array['content'];
        // Don't do anything if we're in the admin section
    } elseif (is_admin()) {
        return $array['content'];
        // If all the checks pass, let's make us some buttons!
    } else {
        // Set the options for the horizontal floating bar
        $postType = get_post_type($postID);
        $spec_float_where = get_post_meta($postID, 'nc_floatLocation', true);
        if (isset($array['float']) && $array['float'] == 'ignore') {
            $floatOption = 'float_ignore';
        } elseif ($spec_float_where == 'off' && $options['buttonFloat'] != 'float_ignore') {
            $floatOption = 'floatNone';
        } elseif ($options['float'] && is_singular() && $options['float_location_' . $postType] == 'on') {
            $floatOption = 'float' . ucfirst($options['floatOption']);
        } else {
            $floatOption = 'floatNone';
        }
        // Disable the plugin on feeds, search results, and non-published content
        if (!is_feed() && !is_search() && get_post_status($postID) == 'publish') {
            // Acquire the social stats from the networks
            if (isset($array['url'])) {
                $buttonsArray['url'] = $array['url'];
            } else {
                $buttonsArray['url'] = get_permalink($postID);
            }
            // Fetch the share counts
            $buttonsArray['shares'] = get_social_warfare_shares($postID);
            // Pass the swp_options into the array so we can pass it into the filter
            $buttonsArray['options'] = $options;
            // Customize which buttosn we're going to display
            if (isset($array['buttons'])) {
                // Fetch the global names and keys
                $swp_options = array();
                $swp_available_options = apply_filters('swp_options', $swp_options);
                $available_buttons = $swp_available_options['options']['swp_display']['buttons']['content'];
                // Split the comma separated list into an array
                $button_set_array = explode(',', $array['buttons']);
                // Match the names in the list to their appropriate system-wide keys
                foreach ($button_set_array as $button) {
                    // Trim the network name in case of white space
                    $button = trim($button);
                    // Convert the names to their systme-wide keys
                    if (recursive_array_search($button, $available_buttons)) {
                        $key = recursive_array_search($button, $available_buttons);
                        // Store the result in the array that gets passed to the HTML generator
                        $buttonsArray['buttons'][$key] = $button;
                        // Declare a default share count of zero. This will be overriden later
                        if (!isset($buttonsArray['shares'][$key])) {
                            $buttonsArray['shares'][$key] = 0;
                        }
                    }
                }
                // Manually turn the total shares on or off
                if (array_search('Total', $button_set_array)) {
                    $buttonsArray['buttons']['totes'] = 'Total';
                }
            }
            // Setup the buttons array to pass into the 'swp_network_buttons' hook
            $buttonsArray['count'] = 0;
            $buttonsArray['totes'] = 0;
            if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes'] && !isset($array['buttons']) || isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
            }
            $buttonsArray['resource'] = array();
            $buttonsArray['postID'] = $postID;
            // Disable the subtitles plugin to avoid letting them inject their subtitle into our share titles
            if (is_plugin_active('subtitles/subtitles.php') && class_exists('Subtitles')) {
                remove_filter('the_title', array(Subtitles::getinstance(), 'the_subtitle'), 10, 2);
            }
            // This array will contain the HTML for all of the individual buttons
            $buttonsArray = apply_filters('swp_network_buttons', $buttonsArray);
            // Create the social panel
            $assets = '<div class="nc_socialPanel swp_' . $options['visualTheme'] . ' swp_d_' . $options['dColorSet'] . ' swp_i_' . $options['iColorSet'] . ' swp_o_' . $options['oColorSet'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-scale="' . $options['buttonSize'] . '" data-align="' . $options['buttonFloat'] . '">';
            // Setup the total shares count if it's on the left
            if ($options['totes'] && $options['swTotesFormat'] == 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($array['buttons']) || $options['swTotesFormat'] == 'totesAltLeft' && isset($array['buttons']) && isset($array['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
                $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
                $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
                $assets .= '</div>';
            }
            // Sort the buttons according to the user's preferences
            if (isset($buttonsArray) && isset($buttonsArray['buttons'])) {
                foreach ($buttonsArray['buttons'] as $key => $value) {
                    if (isset($buttonsArray['resource'][$key])) {
                        $assets .= $buttonsArray['resource'][$key];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'manual') {
                foreach ($options['newOrderOfIcons'] as $key => $value) {
                    if (isset($buttonsArray['resource'][$key])) {
                        $assets .= $buttonsArray['resource'][$key];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'dynamic') {
                arsort($buttonsArray['shares']);
                foreach ($buttonsArray['shares'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            }
            // Create the Total Shares Box if it's on the right
            if ($options['totes'] && $options['swTotesFormat'] != 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($buttonsArray['buttons']) || $options['swTotesFormat'] != 'totesAltLeft' && isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
                if ($options['swTotesFormat'] == 'totes') {
                    $assets .= '<div class="nc_tweetContainer totes" data-id="' . $buttonsArray['count'] . '" >';
                    $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
                    $assets .= '</div>';
                } else {
                    $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
                    $assets .= '<span class="swp_count"><span class="swp_label">' . __('Shares', 'social-warfare') . '</span> ' . swp_kilomega($buttonsArray['totes']) . '</span>';
                    $assets .= '</div>';
                }
            }
            // Close the Social Panel
            $assets .= '</div>';
            // Reset the cache timestamp if needed
            if (swp_is_cache_fresh($postID) == false) {
                delete_post_meta($postID, 'swp_cache_timestamp');
                update_post_meta($postID, 'swp_cache_timestamp', floor(date('U') / 60 / 60));
            }
            if (isset($array['genesis'])) {
                if ($array['where'] == 'below' && $array['genesis'] == 'below') {
                    return $assets;
                } elseif ($array['where'] == 'above' && $array['genesis'] == 'above') {
                    return $assets;
                } elseif ($array['where'] == 'both') {
                    return $assets;
                } elseif ($array['where'] == 'none') {
                    return false;
                }
            } else {
                if ($array['echo'] == false && $array['where'] != 'none') {
                    return $assets;
                } elseif ($array['content'] === false) {
                    echo $assets;
                } elseif ($array['where'] == 'below') {
                    $content = $array['content'] . '' . $assets;
                    return $content;
                } elseif ($array['where'] == 'above') {
                    $content = $assets . '' . $array['content'];
                    return $content;
                } elseif ($array['where'] == 'both') {
                    $content = $assets . '' . $array['content'] . '' . $assets;
                    return $content;
                } elseif ($array['where'] == 'none') {
                    return $array['content'];
                }
            }
        } else {
            return $array['content'];
        }
    }
}
function conditional_bbpress_styles_scripts()
{
    //first check that bbpress exists to prevent fatal errors
    if (function_exists('is_bbpress')) {
        //dequeue scripts and styles
        if (!is_bbpress() && !is_buddypress()) {
            wp_dequeue_style('bbp-default');
            wp_dequeue_style('gp-bbp');
            wp_dequeue_style('bbp_private_replies_style');
            wp_dequeue_script('bbpress-editor');
        }
    }
}
 /**
  * Calculate any extra classes for the <body> element.
  * These are then added using the 'body_class' filter.
  * Documentation: ttps://codex.wordpress.org/Plugin_API/Filter_Reference/body_class
  */
 public function body_classes($classes)
 {
     $sidebar_1 = $this->sidebar_context(1);
     $sidebar_2 = $this->sidebar_context(2);
     $c_pageID = Avada::c_pageID();
     $classes[] = 'fusion-body';
     if (is_page_template('blank.php')) {
         $classes[] = 'body_blank';
     }
     if (!Avada()->settings->get('header_sticky_tablet')) {
         $classes[] = 'no-tablet-sticky-header';
     }
     if (!Avada()->settings->get('header_sticky_mobile')) {
         $classes[] = 'no-mobile-sticky-header';
     }
     if (Avada()->settings->get('mobile_slidingbar_widgets')) {
         $classes[] = 'no-mobile-slidingbar';
     }
     if (Avada()->settings->get('status_totop')) {
         $classes[] = 'no-totop';
     }
     if (!Avada()->settings->get('status_totop_mobile')) {
         $classes[] = 'no-mobile-totop';
     }
     if ('horizontal' == Avada()->settings->get('woocommerce_product_tab_design') && is_singular('product')) {
         $classes[] = 'woo-tabs-horizontal';
     }
     if ('modern' == Avada()->settings->get('mobile_menu_design')) {
         $classes[] = 'mobile-logo-pos-' . strtolower(Avada()->settings->get('logo_alignment'));
     }
     if ('Boxed' == Avada()->settings->get('layout') && 'default' == get_post_meta($c_pageID, 'pyre_page_bg_layout', true) || 'boxed' == get_post_meta($c_pageID, 'pyre_page_bg_layout', true)) {
         $classes[] = 'layout-boxed-mode';
     } else {
         $classes[] = 'layout-wide-mode';
     }
     if (is_array($sidebar_1) && !empty($sidebar_1) && ($sidebar_1[0] || '0' == $sidebar_1[0]) && !is_buddypress() && !is_bbpress() && !is_page_template('100-width.php') && (!class_exists('WooCommerce') || class_exists('WooCommerce') && !is_cart() && !is_checkout() && !is_account_page() && !(get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))))) {
         $classes[] = 'has-sidebar';
     }
     if (is_array($sidebar_1) && $sidebar_1[0] && is_array($sidebar_2) && $sidebar_2[0] && !is_buddypress() && !is_bbpress() && !is_page_template('100-width.php') && (!class_exists('WooCommerce') || class_exists('WooCommerce') && !is_cart() && !is_checkout() && !is_account_page() && !(get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))))) {
         $classes[] = 'double-sidebars';
     }
     if (is_page_template('side-navigation.php') && is_array($sidebar_2) && $sidebar_2[0]) {
         $classes[] = 'double-sidebars';
     }
     if (is_home()) {
         if ('None' != $sidebar_1) {
             $classes[] = 'has-sidebar';
         }
         if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
             $classes[] = 'double-sidebars';
         }
     }
     if (is_archive() && (!is_buddypress() && !is_bbpress() && (class_exists('WooCommerce') && !is_shop()) || !class_exists('WooCommerce')) && !is_tax('portfolio_category') && !is_tax('portfolio_skills') && !is_tax('portfolio_tags') && !is_tax('product_cat') && !is_tax('product_tag')) {
         if ('None' != $sidebar_1) {
             $classes[] = 'has-sidebar';
         }
         if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
             $classes[] = 'double-sidebars';
         }
     }
     if (is_tax('portfolio_category') || is_tax('portfolio_skills') || is_tax('portfolio_tags')) {
         if ('None' != $sidebar_1) {
             $classes[] = 'has-sidebar';
         }
         if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
             $classes[] = 'double-sidebars';
         }
     }
     if (is_tax('product_cat') || is_tax('product_tag')) {
         if ('None' != $sidebar_1) {
             $classes[] = 'has-sidebar';
         }
         if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
             $classes[] = 'double-sidebars';
         }
     }
     if (is_search()) {
         if ('None' != $sidebar_1) {
             $classes[] = 'has-sidebar';
         }
         if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
             $classes[] = 'double-sidebars';
         }
     }
     if ((is_bbpress() || is_buddypress()) && !bbp_is_forum_archive() && !bbp_is_topic_archive() && !bbp_is_user_home() && !bbp_is_search()) {
         if (Avada()->settings->get('bbpress_global_sidebar')) {
             if ('None' != $sidebar_1) {
                 $classes[] = 'has-sidebar';
             }
             if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
                 $classes[] = 'double-sidebars';
             }
         } else {
             if (is_array($sidebar_1) && $sidebar_1[0]) {
                 $classes[] = 'has-sidebar';
             }
             if (is_array($sidebar_1) && $sidebar_1[0] && is_array($sidebar_2) && $sidebar_2[0]) {
                 $classes[] = 'double-sidebars';
             }
         }
     }
     if ((is_bbpress() || is_buddypress()) && (bbp_is_forum_archive() || bbp_is_topic_archive() || bbp_is_user_home() || bbp_is_search())) {
         if ('None' != $sidebar_1) {
             $classes[] = 'has-sidebar';
         }
         if ('None' != $sidebar_1 && 'None' != $sidebar_2) {
             $classes[] = 'double-sidebars';
         }
     }
     if (class_exists('Tribe__Events__Main') && is_events_archive()) {
         if (is_array($sidebar_1) && $sidebar_1[0] && !is_bbpress() && !is_page_template('100-width.php') && (!class_exists('WooCommerce') || class_exists('WooCommerce') && !is_cart() && !is_checkout() && !is_account_page() && !(get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))))) {
             $classes[] = 'has-sidebar';
         }
         if (is_array($sidebar_1) && $sidebar_1[0] && is_array($sidebar_2) && $sidebar_2[0] && !is_bbpress() && !is_page_template('100-width.php') && (!class_exists('WooCommerce') || class_exists('WooCommerce') && !is_cart() && !is_checkout() && !is_account_page() && !(get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))))) {
             $classes[] = 'double-sidebars';
         }
     }
     if ('no' != get_post_meta($c_pageID, 'pyre_display_header', true)) {
         if ('Left' == Avada()->settings->get('header_position') || 'Right' == Avada()->settings->get('header_position')) {
             $classes[] = 'side-header';
         }
         if ('Left' == Avada()->settings->get('header_position')) {
             $classes[] = 'side-header-left';
         } elseif ('Right' == Avada()->settings->get('header_position')) {
             $classes[] = 'side-header-right';
         }
         $classes[] = 'menu-text-align-' . strtolower(Avada()->settings->get('menu_text_align'));
     }
     $classes[] = 'mobile-menu-design-' . Avada()->settings->get('mobile_menu_design');
     return $classes;
 }
function social_warfare_buttons($array = array())
{
    // Setup the default Array parameters
    if (!isset($array['where'])) {
        $array['where'] = 'default';
    }
    if (!isset($array['echo'])) {
        $array['echo'] = true;
    }
    if (!isset($array['content'])) {
        $array['content'] = false;
    }
    // Get the options...or create them if they don't exist
    if (isset($array['post_id'])) {
        $postID = $array['post_id'];
    } else {
        $postID = get_the_ID();
    }
    $options = sw_get_user_options();
    // Check to see if display location was specifically defined for this post
    $specWhere = get_post_meta($postID, 'nc_postLocation', true);
    if ($array['where'] == 'default') {
        if ($specWhere == 'default' || $specWhere == '') {
            if (is_singular('post')) {
                $array['where'] = $options['locationPost'];
            } elseif (is_singular('page')) {
                $array['where'] = $options['locationPage'];
            } elseif (is_singular()) {
                $postType = get_post_type($postID);
                if (isset($options['location' . $postType])) {
                    $array['where'] = $options['location' . $postType];
                } else {
                    $array['where'] = 'none';
                }
            } else {
                $postType = get_post_type($postID);
                if (isset($options['location' . $postType])) {
                    $array['where'] = $options['location' . $postType];
                } elseif ($postType == 'post' || $postType == 'page') {
                    $array['where'] = $options['locationSite'];
                } else {
                    $array['where'] = 'none';
                }
            }
        } else {
            $array['where'] = $specWhere;
        }
    }
    // Disable the buttons on Buddy Press pages
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $array['content'];
        // Disable the buttons if the location is set to "None / Manual"
    } elseif ($array['where'] == 'none' && !isset($array['devs'])) {
        return $array['content'];
        // Disable the button if we're not in the loop, unless there is no content which means the function was called by a developer.
    } elseif ((!is_main_query() || !in_the_loop()) && !isset($array['devs'])) {
        return $array['content'];
        // Don't do anything if we're in the admin section
    } elseif (is_admin()) {
        return $array['content'];
        // If all the checks pass, let's make us some buttons!
    } else {
        // Set the options for the horizontal floating bar
        if ($options['float'] && is_singular()) {
            $floatOption = 'float' . ucfirst($options['floatOption']);
        } else {
            $floatOption = 'floatNone';
        }
        // Disable the plugin on feeds, search results, and non-published content
        if (!is_feed() && !is_search() && get_post_status($postID) == 'publish') {
            // Acquire the social stats from the networks
            if (isset($array['url'])) {
                $buttonsArray['url'] = $array['url'];
            } else {
                $buttonsArray['url'] = get_permalink($postID);
            }
            $language = array();
            $language = apply_filters('sw_languages', $language);
            // Setup the buttons array to pass into the 'sw_network_buttons' hook
            $buttonsArray['shares'] = get_social_warfare_shares($postID);
            $buttonsArray['language'] = apply_filters('sw_languages', $language);
            $buttonsArray['count'] = 0;
            $buttonsArray['totes'] = 0;
            $buttonsArray['options'] = $options;
            if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes']) {
                ++$buttonsArray['count'];
            }
            $buttonsArray['resource'] = array();
            $buttonsArray['postID'] = $postID;
            // Disable the subtitles plugin to avoid letting them inject their subtitle into our share titles
            if (is_plugin_active('subtitles/subtitles.php') && class_exists('Subtitles')) {
                remove_filter('the_title', array(Subtitles::getinstance(), 'the_subtitle'), 10, 2);
            }
            // This array will contain the HTML for all of the individual buttons
            $buttonsArray = apply_filters('sw_network_buttons', $buttonsArray);
            // Create the social panel
            $assets = '<div class="nc_socialPanel sw_' . $options['visualTheme'] . ' sw_d_' . $options['dColorSet'] . ' sw_i_' . $options['iColorSet'] . ' sw_o_' . $options['oColorSet'] . '" data-position="' . $options['locationPost'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-scale="' . $options['buttonSize'] . '" data-align="' . $options['buttonFloat'] . '">';
            // Setup the total shares count if it's on the left
            if ($options['totes'] && $options['swTotesFormat'] == 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes']) {
                $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="6" >';
                $assets .= '<span class="sw_count">' . kilomega($buttonsArray['totes']) . ' <span class="sw_label">' . $language['total'] . '</span></span>';
                $assets .= '</div>';
            }
            // Sort the buttons according to the user's preferences
            if ($options['orderOfIconsSelect'] == 'manual') {
                foreach ($options['newOrderOfIcons'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'dynamicCount') {
                arsort($buttonsArray['shares']);
                foreach ($buttonsArray['shares'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            }
            // Create the Total Shares Box if it's on the right
            if ($options['totes'] && $options['swTotesFormat'] != 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes']) {
                if ($options['swTotesFormat'] == 'totes') {
                    $assets .= '<div class="nc_tweetContainer totes" data-id="6" >';
                    $assets .= '<span class="sw_count">' . kilomega($buttonsArray['totes']) . ' <span class="sw_label">' . $language['total'] . '</span></span>';
                    $assets .= '</div>';
                } else {
                    $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="6" >';
                    $assets .= '<span class="sw_count"><span class="sw_label">' . $language['total'] . '</span> ' . kilomega($buttonsArray['totes']) . '</span>';
                    $assets .= '</div>';
                }
            }
            // Close the Social Panel
            $assets .= '</div>';
            // Reset the cache timestamp if needed
            if (sw_is_cache_fresh($postID) == false) {
                delete_post_meta($postID, 'sw_cache_timestamp');
                update_post_meta($postID, 'sw_cache_timestamp', floor(date('U') / 60 / 60));
            }
            if ($array['echo'] == false && $array['where'] != 'none') {
                return $assets;
            } elseif ($array['content'] === false) {
                echo $assets;
            } elseif ($array['where'] == 'below') {
                $content = $array['content'] . '' . $assets;
                return $content;
            } elseif ($array['where'] == 'above') {
                $content = $assets . '' . $array['content'];
                return $content;
            } elseif ($array['where'] == 'both') {
                $content = $assets . '' . $array['content'] . '' . $assets;
                return $content;
            } elseif ($array['where'] == 'none') {
                return $array['content'];
            }
        } else {
            return $array['content'];
        }
    }
}
Beispiel #19
0
    }
    $THEMEREX_cat_options = getCategoryInheritedProperties($cat);
} else {
    if ((is_day() || is_month() || is_year()) && ($page_id = getTemplatePageId('archive')) > 0) {
        $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
    } else {
        if (is_search() && ($page_id = getTemplatePageId('search')) > 0) {
            $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
        } else {
            if (is_404() && ($page_id = getTemplatePageId('404')) > 0) {
                $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
            } else {
                if (function_exists('is_bbpress') && is_bbpress() && ($page_id = getTemplatePageId('bbpress')) > 0) {
                    $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                } else {
                    if (function_exists('is_buddypress') && is_buddypress() && ($page_id = getTemplatePageId('buddypress')) > 0) {
                        $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                    } else {
                        if (is_single() || is_page() || is_singular() || $wp_query->is_posts_page == 1) {
                            // Current post custom options
                            $page_id = is_single() || is_page() ? get_the_ID() : (isset($wp_query->queried_object_id) ? $wp_query->queried_object_id : getTemplatePageId('template-blog'));
                            $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                            $THEMEREX_cat_options = getCategoriesInheritedProperties(getCategoriesByPostId($page_id));
                        }
                    }
                }
            }
        }
    }
}
// Reject old browsers support
Beispiel #20
0
 function axiom_is_buddypress_page()
 {
     return function_exists('is_buddypress') && is_buddypress();
 }
Beispiel #21
0
 /**
  * Filters and hooks initialization
  */
 function init()
 {
     if (!is_buddypress()) {
         return;
     }
     add_filter('fastfood_option_fastfood_xinfos_global', '__return_false');
     add_filter('fastfood_option_fastfood_hide_frontpage_title', '__return_false');
     add_filter('fastfood_use_sidebar', array($this, 'show_sidebar'));
     add_filter('fastfood_filter_featured_title', array($this, 'show_title'));
     add_filter('fastfood_filter_navbuttons', array($this, 'navbuttons'));
     add_filter('fastfood_get_sidebar_singular', '__return_false');
     add_filter('sharing_show', '__return_false');
 }
/**
 * Load a specific template file with fallback support.
 *
 * Example:
 *   bp_core_load_template( 'members/index' );
 * Loads:
 *   wp-content/themes/[activated_theme]/members/index.php
 *
 * @package BuddyPress Core
 * @param string $username Username to check.
 * @return int|bool The user ID of the matched user, or false.
 */
function bp_core_load_template($templates)
{
    global $post, $bp, $wp_query, $wpdb;
    // Determine if the root object WP page exists for this request
    // note: get_page_by_path() breaks non-root pages
    if (!empty($bp->unfiltered_uri_offset)) {
        if (!($page_exists = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp->unfiltered_uri[$bp->unfiltered_uri_offset])))) {
            return false;
        }
    }
    // Set the root object as the current wp_query-ied item
    $object_id = 0;
    foreach ((array) $bp->pages as $page) {
        if ($page->name == $bp->unfiltered_uri[$bp->unfiltered_uri_offset]) {
            $object_id = $page->id;
        }
    }
    // Make the queried/post object an actual valid page
    if (!empty($object_id)) {
        $wp_query->queried_object =& get_post($object_id);
        $wp_query->queried_object_id = $object_id;
        $post = $wp_query->queried_object;
    }
    // Fetch each template and add the php suffix
    $filtered_templates = array();
    foreach ((array) $templates as $template) {
        $filtered_templates[] = $template . '.php';
    }
    // Filter the template locations so that plugins can alter where they are located
    $located_template = apply_filters('bp_located_template', locate_template((array) $filtered_templates, false), $filtered_templates);
    if (!empty($located_template)) {
        // Template was located, lets set this as a valid page and not a 404.
        status_header(200);
        $wp_query->is_page = true;
        $wp_query->is_singular = true;
        $wp_query->is_404 = false;
        do_action('bp_core_pre_load_template', $located_template);
        load_template(apply_filters('bp_load_template', $located_template));
        do_action('bp_core_post_load_template', $located_template);
        // Kill any other output after this.
        exit;
        // No template found, so setup theme compatability
        // @todo Some other 404 handling if theme compat doesn't kick in
    } else {
        // We know where we are, so reset important $wp_query bits here early.
        // The rest will be done by bp_theme_compat_reset_post() later.
        if (is_buddypress()) {
            status_header(200);
            $wp_query->is_page = true;
            $wp_query->is_singular = true;
            $wp_query->is_404 = false;
        }
        do_action('bp_setup_theme_compat');
    }
}
/**
 * Force comments_status to 'closed' for BuddyPress post types.
 *
 * @since BuddyPress (1.7.0)
 *
 * @param bool $open True if open, false if closed.
 * @param int $post_id ID of the post to check.
 * @return bool True if open, false if closed.
 */
function bp_comments_open($open, $post_id = 0)
{
    $retval = is_buddypress() ? false : $open;
    // Allow override of the override
    return apply_filters('bp_force_comment_status', $retval, $open, $post_id);
}
Beispiel #24
0
/**
 * Load a specific template file with fallback support.
 *
 * Example:
 *   bp_core_load_template( 'members/index' );
 * Loads:
 *   wp-content/themes/[activated_theme]/members/index.php
 *
 * @param array $templates Array of templates to attempt to load.
 * @return bool|null Returns false on failure.
 */
function bp_core_load_template($templates)
{
    global $wp_query;
    // check if BP page belongs to, or is a child of, a BP directory page
    $page_id = false;
    foreach ((array) buddypress()->pages as $page) {
        if ($page->name == buddypress()->unfiltered_uri[buddypress()->unfiltered_uri_offset]) {
            $page_id = $page->id;
            break;
        }
    }
    // Set up reset post args
    $reset_post_args = array('is_404' => true, 'post_status' => 'publish');
    // BP page exists - fill in the $wp_query->post object
    //
    // bp_theme_compat_reset_post() looks at the $wp_query->post object to fill in
    // the post globals
    if (!empty($page_id)) {
        $wp_query->post = get_post($page_id);
        $reset_post_args['ID'] = $page_id;
    } else {
        $reset_post_args['ID'] = 0;
    }
    // Reset the post
    bp_theme_compat_reset_post($reset_post_args);
    // Set theme compat to false since the reset post function automatically sets
    // theme compat to true
    bp_set_theme_compat_active(false);
    // Fetch each template and add the php suffix
    $filtered_templates = array();
    foreach ((array) $templates as $template) {
        $filtered_templates[] = $template . '.php';
    }
    // Only perform template lookup for bp-default themes
    if (!bp_use_theme_compat_with_current_theme()) {
        $template = locate_template((array) $filtered_templates, false);
        // Theme compat doesn't require a template lookup
    } else {
        $template = '';
    }
    // Filter the template locations so that plugins can alter where they are located
    $located_template = apply_filters('bp_located_template', $template, $filtered_templates);
    if (!empty($located_template)) {
        // Template was located, lets set this as a valid page and not a 404.
        status_header(200);
        $wp_query->is_page = true;
        $wp_query->is_singular = true;
        $wp_query->is_404 = false;
        do_action('bp_core_pre_load_template', $located_template);
        load_template(apply_filters('bp_load_template', $located_template));
        do_action('bp_core_post_load_template', $located_template);
        // Kill any other output after this.
        exit;
        // No template found, so setup theme compatability
        // @todo Some other 404 handling if theme compat doesn't kick in
    } else {
        // We know where we are, so reset important $wp_query bits here early.
        // The rest will be done by bp_theme_compat_reset_post() later.
        if (is_buddypress()) {
            status_header(200);
            $wp_query->is_page = true;
            $wp_query->is_singular = true;
            $wp_query->is_404 = false;
        }
        do_action('bp_setup_theme_compat');
    }
}
/**
 * Adds current page CSS classes to the parent BP page in a WP Nav Menu.
 *
 * When {@link wp_nav_menu()} is used, this function helps to highlight the
 * current BP parent page during nav menu generation.
 *
 * @since BuddyPress (2.2.0)
 *
 * @param array   $retval CSS classes for the current nav menu item in the menu
 * @param WP_Post $item   The properties for the current nav menu item
 * @return array
 */
function bp_core_menu_highlight_nav_menu_item( $retval, $item ) {
	// If we're not on a BP page or if the current nav item is not a page, stop!
	if ( ! is_buddypress() || 'page' !== $item->object ) {
		return $retval;
	}

	// get the WP page
	$page   = get_post( $item->object_id );

	// see if we should add our highlight CSS classes for the page
	$retval = bp_core_menu_highlight_parent_page( $retval, $page );

	return $retval;
}
/**
 * Set the template to use, buffers the needed template parts
 * and resets post vars.
 *
 * @package WP Idea Stream
 * @subpackage core/template-loader
 *
 * @since 2.0.0
 *
 * @global $wp_query
 * @param  string $template name of the template to use
 * @uses   is_buddypress() to bail early if it's this plugin's territory
 * @uses   wp_idea_stream_get_idea_var() to get a globalized var
 * @uses   is_404() to check for a 404
 * @uses   get_query_template() to get a specific template
 * @uses   get_index_template() to get the index template
 * @uses   wp_idea_stream_set_idea_var() to set a globalized var
 * @uses   is_post_type_archive() to check if it's ideas post type archive
 * @uses   wp_idea_stream_get_post_type() to get ideas post type identifier
 * @uses   set_query_var() to get a query var
 * @uses   remove_all_filters() to remove all filters on a specific hook
 * @uses   wp_idea_stream_reset_post() to reset WordPress $post global and avoid notices
 * @uses   wp_idea_stream_reset_post_title() to reset the title depending on the context
 * @uses   wp_idea_stream_buffer_template_part() to buffer the content to display
 * @uses   wp_idea_stream_is_edit() to check if the idea is to be edited
 * @uses   wp_idea_stream_ideas_lock_idea() to check if the idea to edit is not currently edited by another user
 * @uses   wp_idea_stream_add_message() to give a user some feedback
 * @uses   wp_idea_stream_ideas_can_edit() to check current user can edit an idea
 * @uses   wp_safe_redirect() to safely redirect the user
 * @uses   wp_idea_stream_get_redirect_url() to get the default redirect url
 * @uses   wp_idea_stream_buffer_single_idea() to buffer the idea content to display
 * @uses   do_action() Calls 'wp_idea_stream_set_core_template' to perform actions once a core template is set
 *                     Calls 'wp_idea_stream_set_single_template' to perform actions relative to the single idea template
 *                     Calls 'wp_idea_stream_set_template' to perform actions when no template matched
 * @uses   apply_filters() Calls 'wp_idea_stream_template_args' to override template args in case of custom idea action
 *                         Calls 'wp_idea_stream_single_template_args' to override single template args
 * @return string $template.
 */
function wp_idea_stream_set_template($template = '')
{
    global $wp_query;
    /**
     * Bail if BuddyPress, we'll use its theme compatibility
     * feature.
     */
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $template;
    }
    if (wp_idea_stream_get_idea_var('is_ideastream') && !is_404()) {
        // Try to see if the theme has a specific template for WP Idea Stream
        $template = get_query_template('ideastream');
        if (empty($template)) {
            // else Try the page template
            $template = get_query_template('page', array('page.php'));
        }
        if (empty($template)) {
            // finally fall back to the index template
            $template = get_index_template();
        }
        // Define it into plugin's vars
        wp_idea_stream_set_idea_var('template_file', $template);
        /**
         * First get results of the main query if not on a single idea.
         * and build plugin's main_query var.
         */
        if (!wp_idea_stream_is_single_idea()) {
            wp_idea_stream_set_idea_var('main_query', array('ideas' => $wp_query->posts, 'total' => $wp_query->found_posts, 'query_vars' => array('author' => $wp_query->query_vars['author'], 'per_page' => $wp_query->query_vars['posts_per_page'], 'page' => !empty($wp_query->query_vars['paged']) ? $wp_query->query_vars['paged'] : 1, 'search' => $wp_query->query_vars['s'], 'exclude' => $wp_query->query_vars['post__not_in'], 'include' => $wp_query->query_vars['post__in'], 'orderby' => !empty($wp_query->query_vars['orderby']) ? $wp_query->query_vars['orderby'] : 'date', 'order' => $wp_query->query_vars['order'], 'meta_query' => $wp_query->meta_query->queries, 'tax_query' => $wp_query->tax_query->queries)));
            // Resetting the 's' query var now we got main query's result.
            set_query_var('s', '');
            // Init template args
            $template_args = array('post_title' => '', 'comment_status' => 'closed', 'is_archive' => true, 'is_tax' => false, 'template_slug' => 'archive', 'template_name' => '', 'context' => '');
            // Main plugin's archive page
            if (is_post_type_archive(wp_idea_stream_get_post_type())) {
                $template_args['context'] = 'archive';
            }
            // Category / tag archive pages
            if (wp_idea_stream_get_idea_var('is_category') || wp_idea_stream_get_idea_var('is_tag')) {
                $template_args['is_tax'] = true;
                $template_args['context'] = 'taxonomy';
            }
            // User's profile pages
            if (wp_idea_stream_get_idea_var('is_user')) {
                $template_args['template_slug'] = 'user';
                $template_args['template_name'] = 'profile';
                $template_args['context'] = 'user-profile';
            }
            if (wp_idea_stream_get_idea_var('is_action')) {
                $template_args['is_archive'] = false;
                // New idea form
                if (wp_idea_stream_is_addnew()) {
                    $template_args['template_slug'] = 'idea';
                    $template_args['template_name'] = 'form';
                    $template_args['context'] = 'new-idea';
                } else {
                    if (wp_idea_stream_is_signup()) {
                        $template_args['template_slug'] = 'signup';
                        $template_args['context'] = 'signup';
                        // Allow plugins to add custom action
                    } else {
                        if (has_filter('wp_idea_stream_template_args')) {
                            /**
                             * Custom action ?
                             *
                             * @param array $template_args the template arguments used to reset the post
                             */
                            $template_args = apply_filters('wp_idea_stream_template_args', $template_args);
                        }
                    }
                }
            }
            // Reset WordPress $post global.
            wp_idea_stream_reset_post(array('ID' => 0, 'post_title' => wp_idea_stream_reset_post_title($template_args['context']), 'post_author' => 0, 'post_date' => 0, 'post_type' => 'ideas', 'post_status' => 'publish', 'is_archive' => $template_args['is_archive'], 'comment_status' => $template_args['comment_status'], 'post_password' => false, 'is_tax' => $template_args['is_tax']));
            /**
             * Internally used to redirect to BuddyPress member's profile
             * if needed
             *
             * @param  string $context to help choosing the best template to use
             */
            do_action('wp_idea_stream_set_core_template', $template_args['context'], $template_args);
        } else {
            $query_loop = new stdClass();
            $query_loop->idea = $wp_query->post;
            // Should we use a custom template for single ideas ?
            $specific_single_template = get_query_template('single-ideastream');
            if (!empty($specific_single_template)) {
                $template = $specific_single_template;
            }
            // Populate the global query loop with current idea
            wp_idea_stream_set_idea_var('query_loop', $query_loop);
            // Add the id to globals
            wp_idea_stream_set_idea_var('single_idea_id', $wp_query->post->ID);
            // Are we editing an idea ?
            if (wp_idea_stream_is_edit()) {
                // Check if the idea is currently being edited by someone else
                $user_is_editing = wp_idea_stream_ideas_lock_idea($query_loop->idea->ID);
                if (!empty($user_is_editing)) {
                    wp_idea_stream_add_message(array('type' => 'info', 'content' => sprintf(__('The idea: &#34;%s&#34; is already being edited by another user.', 'wp-idea-stream'), $query_loop->idea->post_title)));
                    // Redirect the user
                    wp_safe_redirect(wp_idea_stream_get_redirect_url());
                    exit;
                }
                // Bail if user can't edit the idea
                if (!wp_idea_stream_ideas_can_edit($query_loop->idea)) {
                    wp_idea_stream_add_message(array('type' => 'error', 'content' => __('You are not allowed to edit this idea.', 'wp-idea-stream')));
                    // Redirect the user
                    wp_safe_redirect(wp_idea_stream_get_redirect_url());
                    exit;
                }
                // Inform the idea is to display in an edit form
                $query_loop->idea->is_edit = true;
                $template_args = array('template_slug' => 'idea', 'template_name' => 'form', 'context' => 'edit-idea');
                $single_args = array('ID' => 0, 'post_title' => wp_idea_stream_reset_post_title($template_args['context']), 'post_author' => 0, 'post_date' => 0, 'post_type' => 'ideas', 'post_status' => 'publish', 'is_archive' => false, 'comment_status' => false, 'post_password' => false);
                // Or simply viewing one ?
            } else {
                $template_args = array('context' => 'single-idea');
                $single_args = array('is_single' => true);
            }
            /**
             * @param array $single_args the single arguments used to reset the post
             */
            wp_idea_stream_reset_post(apply_filters('wp_idea_stream_single_template_args', $single_args));
            /**
             * Internally used to redirect to Buddypress Group's
             * single idea template if needed
             *
             * @param  WP_Post $query_loop->idea the idea to display
             */
            do_action('wp_idea_stream_set_single_template', $query_loop->idea, $template_args);
        }
    }
    /**
     * No IdeaStream template matched
     */
    do_action('wp_idea_stream_set_template');
    return $template;
}
 function tc_buddypress_disable_comments($bool){
   return ( is_page() && function_exists('is_buddypress') && is_buddypress() ) ? false : $bool;
 }
Beispiel #28
0
/**
 * Checks if an idea can be commented
 *
 * @package WP Idea Stream
 * @subpackage buddypress/functions
 *
 * @since  2.0.0
 *
 * @param  bool $open    true if comments opened, false otherwise
 * @param  int  $idea_id the idea ID
 * @uses   wp_idea_stream_is_ideastream() to check if it's the plugin's territory
 * @uses   is_buddypress() to check if it's BuddyPress territory
 * @uses   wp_idea_stream_is_comments_allowed() to get IdeaStream global setting
 * @uses   get_post_field() to get the idea comments opened setting
 * @uses   apply_filters() call 'wp_idea_stream_buddypress_comments_open' to override the comments opened setting
 * @return bool          the comments opened status for the idea
 */
function wp_idea_stream_buddypress_comments_open($open = true, $idea_id = 0)
{
    $retval = true;
    if (!wp_idea_stream_is_ideastream() || !is_buddypress()) {
        return $open;
    }
    // Comments can be disabled globally
    if (!wp_idea_stream_is_comments_allowed()) {
        $retval = false;
    }
    // We need to recheck as BuddyPress is forcing comment status to be closed
    // on its directory pages.
    if ('open' != get_post_field('comment_status', $idea_id)) {
        $retval = false;
    }
    /**
     * Used internally to check the group's comments opened setting
     *
     * @param  bool $retval  the comments opened setting
     * @param  int  $idea_id the ID of the idea
     */
    return apply_filters('wp_idea_stream_buddypress_comments_open', $retval, $idea_id);
}
/**
 * Remove "prev" and "next" relational links from <head> on BuddyPress pages.
 *
 * WordPress automatically generates these relational links to the current
 * page.  However, BuddyPress doesn't adhere to these links.  In this
 * function, we remove these links when on a BuddyPress page.  This also
 * prevents additional, unnecessary queries from running.
 *
 * @since BuddyPress (2.1.0)
 */
function bp_remove_adjacent_posts_rel_link()
{
    if (!is_buddypress()) {
        return;
    }
    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
}
 /**
  * Queue rating data for footer JS hook and return rating's html.
  *
  * @param int $pElementID
  * @param $pOwnerID
  * @param $pTitle
  * @param $pPermalink
  * @param $pElementClass
  * @param bool $pAddSchema
  * @param bool $pHorAlign
  * @param bool $pCustomStyle
  * @param array $pOptions
  * @param bool $pValidateVisibility
  * @param bool $pValidateCategory
  *
  * @return string Rating HTML container.
  *
  * @uses GetRatingHtml
  * @version 1.3.3
  */
 public function EmbedRating($pElementID, $pOwnerID, $pTitle, $pPermalink, $pElementClass, $pAddSchema = false, $pHorAlign = false, $pCustomStyle = false, $pOptions = array(), $pValidateVisibility = false, $pValidateCategory = true)
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence('EmbedRating', $params);
     }
     $result = apply_filters('rw_filter_embed_rating', $pElementID, $pOwnerID);
     if (false === $result) {
         return '';
     }
     if ($pValidateVisibility && !$this->IsVisibleRating($pElementID, 'forum-reply' !== $pElementClass ? $pElementClass : 'forum-post', $pValidateCategory)) {
         return '';
     }
     $urid = $this->get_rating_id_by_element($pElementID, $pElementClass);
     if ('comment' === $pElementClass) {
         // Get the read-only state of the comment rating
         $is_rating_readonly = $this->is_rating_readonly($pElementID, 'comment');
     } else {
         // Get the read-only state of the exact post type, e.g.: post or product
         $is_rating_readonly = $this->is_rating_readonly($pElementID, get_post_type($pElementID));
     }
     if (!$is_rating_readonly) {
         if (function_exists('is_buddypress') && is_buddypress()) {
             // Get the user ID associated with the current BuddyPress page being viewed.
             $buddypress_user_id = 'user' === $pElementClass ? $pElementID : $pOwnerID;
             // Set the rating to read-only if the current logged in user ID
             // is equal to the current BuddyPress user ID.
             $is_rating_readonly = get_current_user_id() == $buddypress_user_id;
         } else {
             if (function_exists('is_bbpress') && is_bbpress()) {
                 // Get the user ID associated with the current bbPress item being viewed.
                 $bbpress_user_id = 'user' === $pElementClass ? $pElementID : $pOwnerID;
                 // Set the rating to read-only if the current logged in user ID
                 // is equal to the current bbPress user ID.
                 $is_rating_readonly = get_current_user_id() == $bbpress_user_id;
             }
         }
     }
     if ($is_rating_readonly) {
         $pOptions['read-only'] = 'true';
     }
     if (!$this->has_multirating_options($pElementClass) || ($this->is_comment_review_mode() || $this->is_comment_admin_ratings_mode()) && 'comment' === $pElementClass) {
         RWLogger::Log('EmbedRating', 'Not multi-criteria rating');
         return $this->EmbedRawRating($urid, $pTitle, $pPermalink, $pElementClass, $pAddSchema, $pHorAlign, $pCustomStyle, $pOptions);
     } else {
         RWLogger::Log('EmbedRating', 'Multi-criteria rating');
         //Prefixed with mr_ to avoid possible collisions after calling extract()
         $vars = array('mr_add_schema' => $pAddSchema, 'mr_custom_style' => $pCustomStyle, 'mr_element_class' => $pElementClass, 'mr_element_id' => $pElementID, 'mr_embed_options' => $pOptions, 'mr_hor_align' => $pHorAlign, 'mr_permalink' => $pPermalink, 'mr_summary_urid' => $urid, 'mr_title' => $pTitle);
         return $this->embed_multi_rating($vars);
     }
 }