Skip to content

Instantly share code, notes, and snippets.

@seventhqueen
seventhqueen / featured-items-grid.txt
Created September 17, 2018 19:40
Kleo theme & Visual composer- Featured Items gird
@seventhqueen
seventhqueen / kleo-ere.php
Created September 3, 2018 07:55
Kleo WP theme and Essential real estate comnpatibility
<?php
//https://themeforest.net/item/kleo-pro-community-focused-multipurpose-buddypress-theme/6776630?ref=SeventhQueen
//https://wordpress.org/plugins/essential-real-estate/
if ( ! function_exists( 'kleo_ere_before_main_content' ) ) {
function kleo_ere_before_main_content() {
remove_action( 'kleo_before_main_content', 'kleo_title_main_content' );
get_template_part( 'page-parts/general-before-wrap' );
}
add_action( 'ere_before_main_content', 'kleo_ere_before_main_content' );
@seventhqueen
seventhqueen / check-fb-login.php
Created April 12, 2018 09:08
Check if user used Facebook login on KLEO Wordpress theme
<?php
/**
* Check if user used Facebook login
*
* @param int $user_id The user ID to check.
* @return bool
*/
function sq_is_facebook_user( $user_id = null ) {
if ( ! is_user_logged_in() ) {
@seventhqueen
seventhqueen / pmpro-cpt.php
Last active January 15, 2018 16:06 — forked from strangerstudios/pmpro-cpt.php
Add the PMPro meta box to a CPT. Add this to your plugin/etc.
<?php
/*
Add the PMPro meta box to a CPT
*/
function my_sensei_course_meta_wrapper()
{
//duplicate this row for each CPT
add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'course', 'side');
}
function pmpro_cpt_init()
@seventhqueen
seventhqueen / private-community.php
Created January 30, 2017 15:30
Private WordPress community site - redirect guests to register page
<?php
/**
* Restrict users to your site and redirect them to register page
* @author SeventhQueen
*
* @return void
*/
function sq_restrict_my_website(){
@seventhqueen
seventhqueen / sweetdate-centered-sticky-menu.css
Created January 26, 2017 22:26
Sweetdate theme center the menu when sticky
.sticky.fixed .top-bar section {
justify-content: center;
align-items: center;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
@seventhqueen
seventhqueen / restrict-site-access-pmpro.php
Last active November 18, 2020 20:42
Restrict users access to whole site and force them to Paid memberships Pro levels page
<?php
/* Redirect user to levels page until he subscribes for a membership */
add_action( 'template_redirect', 'sq_membership_restrict' );
function sq_membership_restrict() {
global $pmpro_pages, $post;
if ( is_user_logged_in() && ! pmpro_hasMembershipLevel() ) {
if (isset( $post->ID ) && ! in_array( $post->ID, $pmpro_pages )) {
wp_redirect( pmpro_url() );
@seventhqueen
seventhqueen / enable-chinese-characters-usernames.php
Created December 8, 2016 11:07
Enable Chinese usernames in Wordpress registration
function sanitize_chinese_user( $username, $raw_username, $strict ) {
if ( $username != $raw_username ) {
$username = $raw_username;
}
$username = strip_tags( $username );
// Kill Chinese characters
$username = preg_replace( '|[^a-z0-9 _.\-@一-龥]|ui', '', $username );
// Consolidate contiguous whitespace
@seventhqueen
seventhqueen / schema-org-body-header.php
Last active October 11, 2018 15:17
Generate Schema org for the body tag on a Wordpress site
<html>
<head>
<title>page title</title>
</head>
<body <?php body_class(); ?> <?php kleo_schema_org_markup();?>>
</body>
</html>
@seventhqueen
seventhqueen / bbpress-auto-reply-email-on-new-topic.php
Created May 9, 2016 16:44
bbPress - send an auto-reply email to the bbPress topic author when a new topic is created
<?php
/**
* Send an auto-reply email to the bbPress topic author when a new topic is created
* @param int $topic_id The ID of this topic
* @param object $topic The object of this topic
* @return mixed
*/
function kleo_bbp_email_new_topic( $topic_id = 0, $topic ) {
// Bail if this isn't a topic
if ( $topic->post_type != 'topic' ) {