Forum Replies Created

Viewing 15 replies - 1 through 15 (of 22 total)
  • I must say this is a very frustrating issue. We widely use Contact Form 7 on dozens of sites; the vast majority we have disabled the Rest API for reasons noted by sirector. Any solution in the mix?

    It is related to rest API. We have it disabled for performance issues and ran into this same problem. Installed 4.7 and all is good.

    Thanks for the replies above; had this issue on a plesk install at Media Temple. Needed to add a htaccess file with default WordPress info. Fixed

    tsetsaf

    (@tsetsaf)

    Just tried installing this plugin and ran into this same issue. It worked fine on our dev site but not production. Difference between the two was/ is an old version of the theme on the live site versus the updated version on the dev site.

    Really sweet plugin but given all the current issues we may go another route until you fix the bugs.

    Thread Starter tsetsaf

    (@tsetsaf)

    <a class="skip-link screen-reader-text" href="#content">Skip to content</a>	    <a id="mobile-trigger" href="#mob-menu"><i class="fa fa-bars"></i></a>
    	    <div id="mob-menu">
    			<ul id="menu-main-menu" class="menu"><li id="menu-item-61" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-7 current_page_item menu-item-61"><a href="/">Home</a></li>

    Here is the menu code. Looks different than your demo. using the built in menu manager.

    Thread Starter tsetsaf

    (@tsetsaf)

    Agreed even your demo works right. Looking at your demo how are you setting your main menu? My code looks significantly different using the WP Menus

    <a class="skip-link screen-reader-text" href="#content">Skip to content</a>	    <a id="mobile-trigger" href="#mob-menu"><i class="fa fa-bars"></i></a>
    	    <div id="mob-menu">
    			<ul id="menu-main-menu" class="menu"><li id="menu-item-61" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-7 current_page_item menu-item-61"><a href="/">Home</a></li>

    Find a different host. Seriously. We had the same issues and went back and forth with their support team. Ended up moving to a VPS server ($150 per month) and all slowness is gone.

    Sample page speed improvements:
    Home WP 8 Seconds – VPS 800MS !!!
    Search Page WP 10 Seconds – VPS 1.5 Seconds

    Thread Starter tsetsaf

    (@tsetsaf)

    Had similar issue. Ended up removing that image and setting something up custom on our end. Sorry that isn’t the easy answer but basically it does not have proper responsive calls to resize.

    Similar errors on a sitemap. Just activated

    This page contains the following errors:
    
    warning on line 2 at column 216: xmlns: URI //www.sitemaps.org/schemas/sitemap/0.9 is not absolute
    error on line 382 at column 67: EntityRef: expecting ';'
    Below is a rendering of the page up to the first error.
    Thread Starter tsetsaf

    (@tsetsaf)

    Easy fix; you need to update your theme files

    front-bgimage-section.php

    Change:
    <?php echo get_custom_header()->width; ?> to 100%
    height=”<?php echo get_custom_header()->height; ?>” to max-height=”750″

    Thread Starter tsetsaf

    (@tsetsaf)

    Made changes direct to common.php

    <?php
    /**
     * WordPress predefined actions
     */
    
    // Exit if accessed directly
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    define( 'BROO_WP_PUBLISH_POST_ACTION', 'wp_publish_post' );
    define( 'BROO_WP_SUBMIT_COMMENT_ACTION', 'wp_submit_comment' );
    if ( ! is_admin() ) {
    	define( 'BROO_WP_SUBMIT_PHOTO_ACTION', 'wp_submit_photo' );
    } else {
    }
    define( 'BROO_WP_LOGIN_ACTION', 'wp_login' );
    define( 'BROO_WP_USER_REGISTER_ACTION', 'user_register' );
    define( 'BROO_WP_PROFILE_UPDATE_ACTION', 'wp_profile_update' );
    define( 'BROO_VIEW_POST_ACTION', 'broo_view_post' );
    
    // Non WordPress
    define( 'BROO_MIN_POINTS_ACTION', 'broo_min_points' );
    
    function broo_init_common_actions( $broo_actions = array() ) {
    
    	$broo_actions[BROO_WP_PUBLISH_POST_ACTION] = array(
    			'description' => __( 'User publishes a post.', 'badgearoo' ),
    			'source' =>	__( 'WordPress', 'badgearoo' )
    	);
    
    	$broo_actions[BROO_WP_SUBMIT_COMMENT_ACTION] = array(
    			'description' => __( 'User submits a comment.', 'badgearoo' ),
    			'source' =>	__( 'WordPress', 'badgearoo' )
    	);
    
    	$broo_actions[BROO_WP_SUBMIT_PHOTO_ACTION] = array(
    			'description' => __( 'User submits a photo.', 'badgearoo' ),
    			'source' =>	__( 'WordPress', 'badgearoo' )
    	);
    
    	$broo_actions[BROO_WP_LOGIN_ACTION] = array(
    			'description' => __( 'User logs in.', 'badgearoo' ),
    			'source' =>	__( 'WordPress', 'badgearoo' )
    	);
    
    	$broo_actions[BROO_WP_USER_REGISTER_ACTION] = array(
    			'description' => __( 'Register user.', 'badgearoo' ),
    			'source' =>	__( 'WordPress', 'badgearoo' )
    	);
    
    	$broo_actions[BROO_WP_PROFILE_UPDATE_ACTION] = array(
    			'description' => __( 'User updates their profile.' ),
    			'source' => __( 'WordPress')
    	);
    
    	$broo_actions[BROO_MIN_POINTS_ACTION] = array(
    			'description' => __( 'Minimum points.', 'badgearoo' ),
    			'source' =>	__( 'Custom', 'badgearoo' )
    	);
    
    	$broo_actions[BROO_VIEW_POST_ACTION] = array(
    			'description' => __( 'Views post.', 'badgearoo' ),
    			'source' => __( 'Custom', 'badgearoo' )
    	);
    
    	return $broo_actions;
    }
    add_filter( 'broo_init_actions', 'broo_init_common_actions', 10, 1 );
    
    /**
     * Adds WP Core actions
     *
     * @param actions
     */
    function broo_add_common_actions( $actions = array() ) {
    
    	if ( isset( $actions[BROO_WP_PUBLISH_POST_ACTION] ) && $actions[BROO_WP_PUBLISH_POST_ACTION]['enabled'] == true ) {
    		add_action( 'transition_post_status',  'broo_transition_post_status', 10, 3 );
    		add_filter( 'broo_condition_step_check_wp_publish_post', 'broo_condition_step_check_publish_post', 10, 4 );
    	}
    
    	if ( isset( $actions[BROO_WP_SUBMIT_COMMENT_ACTION] ) && $actions[BROO_WP_SUBMIT_COMMENT_ACTION]['enabled'] == true ) {
    		add_action( 'comment_post', 'broo_submit_comment', 10, 2 );
    		add_filter( 'broo_condition_step_check_wp_submit_comment', 'broo_condition_step_check_count', 10, 4 );
    	}
    if ( ! is_admin() ) {
    		if ( isset( $actions[BROO_WP_SUBMIT_PHOTO_ACTION] ) && $actions[BROO_WP_SUBMIT_PHOTO_ACTION]['enabled'] == true ) {
    		add_action( 'add_attachment', 'broo_submit_photo', 10, 2 );
    		add_filter( 'broo_condition_step_check_wp_submit_photo', 'broo_condition_step_check_count', 10, 4 );
    	}
    } else {
    }
    	if ( isset( $actions[BROO_WP_LOGIN_ACTION] ) && $actions[BROO_WP_LOGIN_ACTION]['enabled'] == true ) {
    		add_action( 'wp_login', 'broo_user_login', 10, 2 );
    		add_filter( 'broo_condition_step_check_wp_login', 'broo_condition_step_check_count', 10, 4 );
    	}
    
    	if ( isset( $actions[BROO_WP_USER_REGISTER_ACTION] ) && $actions[BROO_WP_USER_REGISTER_ACTION]['enabled'] == true ) {
    		add_action( 'user_register', 'broo_user_register', 10, 1 );
    		add_filter( 'broo_condition_step_check_user_register', 'broo_condition_step_check_once', 10, 4 );
    	}
    
    	if ( isset( $actions[BROO_WP_PROFILE_UPDATE_ACTION] ) && $actions[BROO_WP_PROFILE_UPDATE_ACTION]['enabled'] == true ) {
    		add_action( 'profile_update', 'broo_wp_profile_update', 10, 2 );
    		add_filter( 'broo_condition_step_check_wp_profile_update', 'broo_condition_step_check_count', 10, 4 );
    	}
    
    	if ( isset( $actions[BROO_MIN_POINTS_ACTION] ) && $actions[BROO_MIN_POINTS_ACTION]['enabled'] == true ) {
    		add_filter( 'broo_condition_step_check_broo_min_points', 'broo_condition_step_check_points', 10, 4 );
    	}
    
    	if ( isset( $actions[BROO_VIEW_POST_ACTION] ) && $actions[BROO_VIEW_POST_ACTION]['enabled'] == true ) {
    		add_action( 'wp_head', 'broo_view_post', 10, 0 );
    		add_filter( 'broo_condition_step_check_broo_view_post', 'broo_condition_step_check_count', 10, 4 );
    
    		// TODO add step meta: unique, post type, post id...
    	}
    
    	add_filter('broo_step_meta_count_enabled', 'broo_step_meta_count_enabled', 10, 2 );
    	add_filter('broo_step_meta_post_type_enabled', 'broo_step_meta_post_type_enabled', 10, 2 );
    	add_filter('broo_step_meta_points_enabled', 'broo_step_meta_points_enabled', 10, 2 );
    }
    add_action( 'broo_init_actions_complete', 'broo_add_common_actions' );
    
    /**
     * Sets whether step meta count is enabled
     *
     * @param unknown $enabled
     * @param unknown $action
     * @return boolean|unknown
     */
    function broo_step_meta_count_enabled( $enabled, $action ) {
    
    	if ( $action == BROO_WP_LOGIN_ACTION || $action == BROO_WP_PUBLISH_POST_ACTION
    			|| $action == BROO_WP_SUBMIT_COMMENT_ACTION || $action == BROO_WP_SUBMIT_PHOTO_ACTION || $action == BROO_WP_PROFILE_UPDATE_ACTION
    			|| $action == BROO_VIEW_POST_ACTION ) {
    		return true;
    	}
    
    	return $enabled;
    }
    
    /**
     * Sets whether step meta post type is enabled
     *
     * @param unknown $enabled
     * @param unknown $action
     * @return boolean|unknown
     */
    function broo_step_meta_post_type_enabled( $enabled, $action ) {
    
    	if ( $action == BROO_WP_PUBLISH_POST_ACTION ) {
    		return true;
    	}
    
    	return $enabled;
    }
    
    /**
     * Sets whether step meta points is enabled
     *
     * @param unknown $enabled
     * @param unknown $action
     * @return boolean
     */
    function broo_step_meta_points_enabled( $enabled, $action ) {
    
    	if ( $action == BROO_MIN_POINTS_ACTION  ) {
    		return true;
    	}
    
    	return $enabled;
    }
    
    /**
     * Shows a points step meta
     *
     * @param unknown $step_id
     * @param unknown $action
     */
    function broo_step_meta_points( $step_id, $action  ) {
    
    	$step_meta_enabled = apply_filters( 'broo_step_meta_points_enabled', false, $action );
    
    	if ( $step_meta_enabled ) {
    		$points = Badgearoo::instance()->api->get_step_meta_value( $step_id, 'points' );
    		?>
    		<span class="step-meta-value">
    			<input name="points" type="number" value="<?php echo $points; ?>" class="small-text" />&nbsp;<?php _e( 'points', 'badgearoo' ); ?>
    		</span>
    		<?php
    	}
    }
    add_action( 'broo_step_meta', 'broo_step_meta_points', 10, 2 );
    
    /**
     * Shows a count step meta
     *
     * @param unknown $step_id
     * @param unknown $action
     */
    function broo_step_meta_count( $step_id, $action  ) {
    
    	$step_meta_enabled = apply_filters( 'broo_step_meta_count_enabled', false, $action );
    
    	if ( $step_meta_enabled ) {
    		$count = Badgearoo::instance()->api->get_step_meta_value( $step_id, 'count' );
    
    		if ( $count == null || ! is_numeric( $count ) ) {
    			$count = 1;
    		}
    		?>
    		<span class="step-meta-value">
    			<input name="count" type="number" value="<?php echo $count; ?>" class="small-text" />&nbsp;<?php _e( 'time(s)', 'badgearoo' ); ?>
    		</span>
    		<?php
    	}
    }
    add_action( 'broo_step_meta', 'broo_step_meta_count', 10, 2 );
    
    /**
     * Shows a points step meta
     *
     * @param unknown $step_id
     * @param unknown $action
     */
    function broo_step_meta_post_type( $step_id, $action  ) {
    
    	$step_meta_enabled = apply_filters( 'broo_step_meta_post_type_enabled', false, $action );
    
    	if ( $step_meta_enabled ) {
    		$value = Badgearoo::instance()->api->get_step_meta_value( $step_id, 'post_type' );
    		?>
    		<span class="step-meta-value">
    			<label for="post_type"><?php _e( 'Post Type', 'badgearoo' ); ?></label>
    			<select name="post_type">
    				<option value=""><?php _e( 'All', 'badgearoo'); ?></option>
    				<?php
    				$post_types = get_post_types( array( 'public' => true ), 'objects' );
    				foreach ( $post_types as $post_type ) {
    					?><option value="<?php echo $post_type->name; ?>" <?php if ( $post_type->name == $value ) { echo 'selected'; } ?>><?php echo $post_type->labels->name; ?></option><?php
    				} ?>
    			</select>
    		</span>
    		<?php
    	}
    }
    add_action( 'broo_step_meta', 'broo_step_meta_post_type', 10, 2 );
    
    /**
     * Defaults actions enabled
     *
     * @param array $actions_enabled
     * @return $actions_enabled:
     */
    function broo_default_common_actions_enabled( $actions_enabled ) {
    
    	return array_merge( array(
    			BROO_WP_PUBLISH_POST_ACTION				=> true,
    			BROO_WP_SUBMIT_COMMENT_ACTION			=> true,
    			BROO_WP_SUBMIT_PHOTO_ACTION			=> true,
    			BROO_WP_LOGIN_ACTION					=> true,
    			BROO_WP_USER_REGISTER_ACTION			=> true,
    			BROO_MIN_POINTS_ACTION					=> true,
    			BROO_WP_PROFILE_UPDATE_ACTION			=> true,
    			BROO_VIEW_POST_ACTION						=> true
    	), $actions_enabled );
    
    }
    add_filter( 'broo_default_actions_enabled', 'broo_default_common_actions_enabled', 10, 1 );
    
    /**
     * When a post changes status, check if it's just been published
     *
     * @param unknown $new_status
     * @param unknown $old_status
     * @param unknown $post
     */
    function broo_transition_post_status( $new_status, $old_status, $post = null ) {
    
    	if ( $post == null ) {
    		return;
    	}
    
    	$post_type = $post->post_type;
    	$post_types = get_post_types( array( 'public' => true ), 'names' );
    
    	if ( in_array($post_type, $post_types) && $old_status != 'publish' && $new_status == 'publish' ) {
    
    		// get user id
    		$user_id = $post->post_author;
    
    		Badgearoo::instance()->api->add_user_action( BROO_WP_PUBLISH_POST_ACTION, $user_id, array(
    				'post_type' => $post_type ,
    				'post_id' => $post->ID
    		) );
    
    	}
    }
    
    /**
     * When a comment is posted
     *
     * @param unknown $comment_id
     * @param unknown $comment_approved
     */
    function broo_submit_comment( $comment_id, $comment_approved = null) {
    	$comment = get_comment( $comment_id );
    
    	$user_id = $comment->user_id;
    
    	if ( $user_id != 0 ) {
    		Badgearoo::instance()->api->add_user_action( BROO_WP_SUBMIT_COMMENT_ACTION, $user_id, array( 'comment_id' => $comment_id ) );
    	}
    }
    
    /**
     * When a Photo is posted
     *
     * @param unknown $post_id
     * @param unknown $user_id
     */
    if ( ! is_admin() ) {
    	function broo_submit_photo( $post_id, $user_id) {
    	$photo = get_post_gallery( $post_id, false );
    	//$user_id = $photo->user_id;
    	$user_id = get_current_user_id();
    
    if ( $user_id != 0 ) {
    		Badgearoo::instance()->api->add_user_action( BROO_WP_SUBMIT_PHOTO_ACTION, $user_id, array( 'post_id' => $post_id ) );
    	}
    }
    } else {
    
    }
    /**
     * Whenever a user logs in
     *
     * @param unknown $user_login
     * @param unknown $user
     */
    function broo_user_login( $user_login, $user ) {
    	Badgearoo::instance()->api->add_user_action( BROO_WP_LOGIN_ACTION, $user->ID );
    }
    
    /**
     * Saves post view
     */
    function broo_view_post() {
    
    	$post_id = url_to_postid( BROO_Utils::get_current_url() );
    	$user_id = get_current_user_id();
    
    	if ( $post_id == 0 || $user_id == 0 ) {
    		return;
    	}
    
    	$post_type = get_post_type( $post_id );
    
    	Badgearoo::instance()->api->add_user_action( BROO_VIEW_POST_ACTION, $user_id, array(
    			'post_id' => $post_id,
    			'post_type' => $post_type
    	) );
    
    }
    
    /**
     * Whenever a user registers
     * @param unknown $user_id
     */
    function broo_user_register( $user_id ) {
    	Badgearoo::instance()->api->add_user_action( BROO_WP_USER_REGISTER_ACTION, $user_id );
    }
    
    /**
     * Whenever a user updates their profile
     *
     * @param unknown $meta_id
     * @param unknown $user_id
     * @param unknown $meta_key
     * @param unknown $meta_value
     */
    function broo_wp_profile_update( $user_id, $old_user_data ) {
    	Badgearoo::instance()->api->add_user_action( BROO_WP_PROFILE_UPDATE_ACTION, $user_id, array() );
    }
    
    /**
     * Checks user action has been done once
     *
     * @param unknown $step_result
     * @param unknown $step
     * @param int $user_id
     * @param string $action_name
     * @return boolean
     */
    function broo_condition_step_check_once( $step_result, $step, $user_id, $action_name ) {
    
    	if ( $step_result == false ) { // no need to continue
    		return $step_result;
    	}
    
    	global $wpdb;
    	$query = 'SELECT COUNT(*) FROM ' . $wpdb->prefix . BROO_USER_ACTION_TABLE_NAME . ' WHERE action_name = "'
    			. esc_sql( $step->action_name ) . '" and user_id = ' . $user_id;
    
    	$db_count = $wpdb->get_var( $query );
    
    	if ( intval( $db_count ) == 0 ) {
    		return false;
    	}
    
    	return $step_result;
    }
    
    /**
     * Checks count for user actions
     *
     * @param unknown $step_result
     * @param unknown $step
     * @param int $user_id
     * @param string $action_name
     * @return boolean
     */
    function broo_condition_step_check_count( $step_result, $step, $user_id, $action_name ) {
    
    	if ( $step_result == false ) { // no need to continue
    		return $step_result;
    	}
    
    	$meta_count = Badgearoo::instance()->api->get_step_meta_value( $step->step_id, 'count' );
    
    	// in case empty count is saved...
    	if ( $meta_count == null || ( is_string( $meta_count ) && strlen( trim( $meta_count ) == 0 ) ) ) {
    		$meta_count = 1;
    	}
    
    	global $wpdb;
    	$query = 'SELECT COUNT(*) FROM ' . $wpdb->prefix . BROO_USER_ACTION_TABLE_NAME . ' WHERE action_name = "'
    			. esc_sql( $step->action_name ) . '" and user_id = ' . $user_id;
    
    	$db_count = $wpdb->get_var( $query );
    
    	if ( intval( $db_count ) < intval( $meta_count ) ) {
    		return false;
    	}
    
    	return $step_result;
    }
    
    /**
     * Checks count for the WP publish post user action
     *
     * @param unknown $step_result
     * @param unknown $step
     * @param int $user_id
     * @param string $action_name
     * @return boolean
     */
    function broo_condition_step_check_publish_post( $step_result, $step, $user_id, $action_name ) {
    
    	if ( $step_result == false ) { // no need to continue
    		return $step_result;
    	}
    
    	$meta_count = Badgearoo::instance()->api->get_step_meta_value( $step->step_id, 'count' );
    	$meta_post_type = Badgearoo::instance()->api->get_step_meta_value( $step->step_id, 'post_type' );
    
    	global $wpdb;
    	$query = 'SELECT COUNT(*) FROM ' . $wpdb->prefix . BROO_USER_ACTION_TABLE_NAME
    			. ' ua INNER JOIN ' . $wpdb->prefix . BROO_USER_ACTION_META_TABLE_NAME
    			. ' uam ON uam.user_action_id = ua.id WHERE ua.action_name = "'
    			. esc_sql( $action_name ) . '" AND ua.user_id = ' . $user_id
    			. ' AND uam.meta_key = "post_type"';
    
    	if ( $meta_post_type && strlen( trim( $meta_post_type ) ) > 0 ) {
    		$query .= ' AND uam.meta_value = "' . esc_sql( $meta_post_type ) . '"';
    	}
    
    	$db_count = $wpdb->get_var( $query );
    
    	if ( intval( $db_count ) < intval( $meta_count ) ) {
    		return false;
    	}
    
    	return $step_result;
    }
    
    /**
     * Checks points for user
     *
     * @param unknown $step_result
     * @param unknown $step
     * @param int $user_id
     * @param string $action_name
     * @return unknown
     */
    function broo_condition_step_check_points( $step_result, $step, $user_id, $action_name ) {
    
    	if ( $step_result == false ) { // no need to continue
    		return $step_result;
    	}
    
    	$value = Badgearoo::instance()->api->get_step_meta_value( $step->step_id, 'points' );
    
    	$points = Badgearoo::instance()->api->get_user_points( $user_id );
    
    	if ( intval( $points ) < intval( $value ) ) {
    		return false;
    	}
    
    	return $step_result;
    }
    Thread Starter tsetsaf

    (@tsetsaf)

    Further testing found that I had to update the script to ignore admin users is_admin(). The hook was triggering when using the media upload in admin too.

    Thread Starter tsetsaf

    (@tsetsaf)

    Solved

    Thread Starter tsetsaf

    (@tsetsaf)

    Figured it out. The hook I needed to call was get_post_gallery. I used the common.php file, copied all the “comment” code lines, replaced with photo and then updated the last function to use the above hook (around line 310).

    Thread Starter tsetsaf

    (@tsetsaf)

    Began researching a bit and looking at your plugin code (great documentation by the way). It appears that I want to mimic the get_comment code and replace it with something from media_handle or add_attachment

    I am getting a little lost from there. Will stop and wait for your response.

    Thanks

Viewing 15 replies - 1 through 15 (of 22 total)