WordPress.org

Support

Support » Plugins and Hacks » [Resolved] enque style errors

[Resolved] enque style errors

  • Dear Author,

    First off i really appriciate the plugin, although i found a few “mistakes”.

    q-and-a-focus-plus-faq/q-and-a-focus-plus.php line #49 to #51

    /* Load scripts for front */
    	wp_enqueue_script( 'jquery' );
    	wp_enqueue_script( 'q-a-focus-plus', QAFP_URL . '/js/q-a-focus-plus.min.js', false, $qafp_options['version'], true );
    	wp_enqueue_style( 'q-a-focus-plus', QAFP_URL . '/css/q-a-focus-plus.min.css', false, $qafp_options['version'], 'screen' );

    Here you are enqueueing the script and styles directly which isn’t the proper way. Also you are enqueueing jquery which isn’t needed also.

    So my suggestion is as followed:

    Replace above code with:

    /* Load scripts for front */
    	add_action( 'wp_enqueue_scripts', 'register_faq_scripts' );

    Add the following code somewhere in the same file:

    function register_faq_scripts() {
    	wp_enqueue_script( 'q-a-focus-plus', QAFP_URL . '/js/q-a-focus-plus.min.js', array( 'jquery' ), $qafp_options['version'], true );
    	wp_enqueue_style( 'q-a-focus-plus', QAFP_URL . '/css/q-a-focus-plus.min.css', false, $qafp_options['version'], 'screen' );
    }

    Also why are you using $qafp_options['version'] instead of QAFP_VERSION?

    http://wordpress.org/plugins/q-and-a-focus-plus-faq/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author ELsMystERy

    @elsmystery

    Redacted

    Plugin Author ELsMystERy

    @elsmystery

    Redacted.

    Plugin Author ELsMystERy

    @elsmystery

    Nevermind, my previous reply. I see what you are saying about the add_action. Next update, I already added the code.

    Enqueueing jQuery is irrelevant. If it already exists then that won’t mess with it. WordPress is smart enough to know what to do with that.

    The version stuff, however… I do not feeling like explaining that in detail, but it really does not matter. I programmed it like that to pull it from the current settings when I am testing.

    Plugin Author ELsMystERy

    @elsmystery

    Actually, I just noticed that I am calling $qafp_options[‘version’] on the main script without loading the options. That happened when I copied and pasted it from the admin page and forgot to change that. I thought you were asking about why I was using that on all pages, but since I was not loading the settings it was not working right. So THAT was a bug.

    Anyhow… sorry to be a bit disgruntled earlier… bad day. I did not process your post fully before I replied. I NOW actually do appreciate the input.

    Great to know it is solved!

    Little question: When are you going to release the next version? Can you also include fixes for these ones:

    Notice: Undefined offset: 0 in /Users/camilo/html/cmslandingpages/app/wp-content/plugins/q-and-a-focus-plus-faq/inc/ratings.php on line 65

    Fix:

    function hasAlreadyVoted($post_id) {
    
    	global $current_user, $timebeforerevote, $qafp_options;
    
    	$voted_ID = array();
    	$meta_ID = get_post_meta($post_id, "voted_ID");
    	if (isset($meta_ID[0])) {
    		$voted_ID = $meta_ID[0];
    	}
    
    	get_currentuserinfo();
    	if ( is_user_logged_in() ) $id = $current_user->ID; else $id = 'A' . ip2long($_SERVER['REMOTE_ADDR']);
    
    	if ( in_array($id, array_keys($voted_ID)) ) {
    		if ( $id[0] != 'A' || $qafp_options['rate_wait'] == null ) return true;
    		$time = $voted_ID[$id];
    		$now = time();
    		if ( round(($now - $time) / 60) > $timebeforerevote ) return false;
    		return true;
    	}
    
    	return false;
    }

    and the following notice:
    Notice: Undefined variable: output in /Users/camilo/html/cmslandingpages/app/wp-content/plugins/q-and-a-focus-plus-faq/inc/ratings.php on line 99

    Fix:

    function getPostLikeLink($post_id) {
    
    	global $qafp_options;
    
    	$vote_count = get_post_meta($post_id, "votes_count", true);
    	$icons = $qafp_options['ricons'];
    	$output = '';
    
    	if ( $qafp_options['restrict_ratings'] == false || ( $qafp_options['restrict_ratings'] == true && is_user_logged_in() ) ) {
    		if(hasAlreadyVoted($post_id)) {
    			$vote_count = $vote_count - 1;
    			if ($vote_count == 1) $persons = "person"; else $persons = "people";
    				$output .= '<span title="' . __('You already found this helpful!', 'qa-focus-plus') . '" class="qtip qafp-like-' . $icons .' qafp-alreadyvoted-' . $icons .'"></span>&nbsp;';
    				$output .= '<span class="qafp-count">';
    				$output .= sprintf( __('You and %1$s other %2$s found this helpful.', 'qa-focus-plus'), $vote_count, $persons);
    				$output .= '</span>';
    		} else {
    			if ($vote_count == 1) $persons = "person"; else $persons = "people";
    			$output .= '<a href="javascript:void(\'0\');" data-post_id="'.$post_id.'" class="qafp-star"><span class="qafp-rating-helper">';
    			$output .= __('Please click here if this helped you.', 'qa-focus-plus');
    			$output .= '</span><br />';
    			$output .= '<span title="' . __('This is helpful!', 'qa-focus-plus') . '" class="qtip qafp-like-' . $icons .'">';
    			$output .= '</span></a>
    			<span class="qafp-count">';
    			$output .= sprintf( __('%1$s %2$s found this helpful.', 'qa-focus-plus'), $vote_count, $persons);
    			$output .= '</span>';
    		}
    	} else if ( $qafp_options['restrict_ratings'] == true && !is_user_logged_in() ) {
    		if ($vote_count == 1) $persons = "person"; else $persons = "people";
    		$output .= '<a href="' . wp_login_url( get_permalink() ) . '" target="_top"><span class="qafp-rating-helper">';
    		$output .= __('Please log in to rate this.', 'qa-focus-plus');
    		$output .= '</span><br />';
    		$output .= '<span title="' . __('Please log in to rate this.', 'qa-focus-plus') . '" class="qtip qafp-like-' . $icons .'">';
    		$output .= '</span></a>
    		<span class="qafp-count">';
    		$output .= sprintf( __('%1$s %2$s found this helpful.', 'qa-focus-plus'), $vote_count, $persons);
    		$output .= '</span>';
    	}
    
    	return $output;
    }

    Thanks.

    Plugin Author ELsMystERy

    @elsmystery

    I have started a new business and am transitioning everything over to that. As soon as that is done I will release an update. Next week, probably.

    Thanks for this. I have added the fixes. I have credited you guys in the readme file.

    Plugin Author ELsMystERy

    @elsmystery

    I am a little behind on getting the update out. I still have to update the documentation and do some testing. I will get it out soon. Hopefully in a few days.

    ok 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] enque style errors’ is closed to new replies.