Forum Replies Created

Viewing 15 replies - 1 through 15 (of 101 total)
  • Thread Starter mikebronner

    (@mikebronner)

    I figured it out (hopefully this will help others as well):

    – need to add the template file yith-bundle.php to the woocommerce template override directory:

    <theme directory>\woocommerce\single-product\add-to-cart\yith-bundle.php

    Getting this error as well. This is due to content quotes not being escaped, breaking SQL query quotes.

    Thread Starter mikebronner

    (@mikebronner)

    Hi StarDrive,

    This plugin does have excellent functionality at its core, and I have been unable to find a replacement. In the end I have “forked” the plugin by renaming and re-versioning it (so that it does not get updated by subsequent updates of the original developer), and have applied all the fixes I needed to make it work how I needed it to. I would recommend this route.

    Definitely give the plugin a fair shake and see if it works for you — it likely will if you are not developing custom themes and custom functionality.

    Thread Starter mikebronner

    (@mikebronner)

    Please consider replacing the array with the following:

    array(
                    'current_page_url'   => preg_replace( "~paged?/[0-9]+/?~", "", home_url( $wp->request ) ),
                    'ajaxurl'            => admin_url( 'admin-ajax.php' ),
                    'product_cat'        => $wp_query_product_cat,
                    'products_holder_id' => (array_key_exists('products_holder_id', $br_options) ? $br_options['products_holder_id'] : null),
                    'control_sorting'    => (array_key_exists('control_sorting', $br_options) ? $br_options['control_sorting'] : null),
                    'seo_friendly_urls'  => (array_key_exists('seo_friendly_urls', $br_options) ? $br_options['seo_friendly_urls'] : null),
                    'berocket_aapf_widget_product_filters' => $post_temrs,
                    'user_func'          => (array_key_exists('user_func', $br_options) ? $br_options['user_func'] : function () {}),
                )

    Always check to make sure variables or arrays exist before using them. ?? I’ll be happy to submit any changes to your code repository.

    Thanks!

    Thread Starter mikebronner

    (@mikebronner)

    Hi Dima,

    For this I have overriden the template and updated it to the following:

    <input class="<?= (isset($uo) && array_key_exists('class', $uo) && array_key_exists('checkbox_radio', $uo['class'])) ? $uo['class']['checkbox_radio'] : '' ?>" type='checkbox' id='radio_<?php echo $term->term_id ?>'

    I would be happy to submit this as a PR if you have the code in GitHub or BitBucket. please consider integrating these fixes, and hiding errors is not a solution.

    Thanks ??

    Thread Starter mikebronner

    (@mikebronner)

    Hi Dima,

    First, thanks for the response. Also, thanks for developing the plugin using templates, you have no idea how many plugin developers don’t do that! ??

    I have to be honest, hiding warnings is not a solution, just a work-around. I can fix the problems in the templates, but no those in the widget.php file. Can I submit a PR to handles these properly?

    I think what needs to be done is the following:

    // here we get max products to know if current page is not too big
            if ( $wp_rewrite->using_permalinks() and preg_match( "~/page/([0-9]+)~", $_POST['location'], $mathces ) or preg_match( "~paged?=([0-9]+)~", $_POST['location'], $mathces ) ) {
                $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
                $wp_query = new WP_Query( $args );
            }

    should be changed to:

    if ($wp_rewrite->using_permalinks()
                && array_key_exists('location', $_POST)
                && (preg_match( "~/page/([0-9]+)~", $_POST['location'], $mathces )
                    || preg_match( "~paged?=([0-9]+)~", $_POST['location'], $mathces ))
            ) {
                $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
                $wp_query = new WP_Query( $args );
            }

    Thread Starter mikebronner

    (@mikebronner)

    Oh, sorry for not updating this yesterday. It was actually something in Safari that kept redirecting. Despite clearing cache and flushing DNS cache on computer, it would always redirect to the non-www, even if I entered www.
    Then I did Safari > Reset, and it worked. Go figure.

    This is how I fixed it:

    Replace liines 110 and 111

    $tmp_url = $meta['quote'. ($i+1)];
    			$tmp_title = $meta['quote' . ($i+1) .'_title'];

    with this:

    if (isset($meta['quote' . ($i + 1)]))
    		{
    			$tmp_url = $meta['quote'. ($i+1)];
    		}
    		if (isset($meta['quote' . ($i + 1) . '_title']))
    		{
    			$tmp_title = $meta['quote' . ($i+1) .'_title'];
    		}

    I’m in the same boat, getting errors such as:

    Warning: Illegal string offset ‘quote1’ in […]/plugins/quote-source/quote-source.php on line 110

    Thread Starter mikebronner

    (@mikebronner)

    My apologies, no harm intended.

    Thread Starter mikebronner

    (@mikebronner)

    Try the replacing it with the following, and instead of using a page template, use a normal page, and use the short code:

    /* Generate Leaderboard Rankings **********************************************/
    /**
     * Returns either the ranking for the current user (single row result) or for all users (limited to the current page, if not overriden).
     *
     *
     * @param bool $show_current_user Optional. If true will get the ranking for the current user only. Default is false.
     * @param int $offset Optional. If set, will start the query from a given offset record. Default is to use normal pagination offset.
     * @param int $posts_per_page Optional. If set, will change the number of records returned per page. Default is WordPress default value.
     *
     * @return array. Two-dimensional array is returned, array["restults"] holds search results, while array["total_number_of_pages"] holds the max number of pages which can be used for pagination links.
     * @since Achievements (3.2.2)
     * @author Mike Bronner <[email protected]>
     */
    function dpa_get_leaderboard_rankings($current_user_id = null, $offset = null, $posts_per_page = null)
    {
    	global $wpdb;
    
    	if (null === $posts_per_page)
    	{
    		$posts_per_page = intval(get_query_var('posts_per_page'));
    	}
    	$db_prefix = $wpdb->base_prefix;
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $posts_per_page = intval(get_query_var('posts_per_page'));
        if (null === $offset)
        {
    	    $offset = ($paged - 1) * $posts_per_page;
    	}
    	$leaderboard_query = "SELECT SQL_CALC_FOUND_ROWS
    				person.id
    				,person.user_login
    				,person.user_nicename
    				,person.user_email
    				,person.user_url
    				,person.user_registered
    				,person.user_status
    				,person.display_name
    				, fname.meta_value AS user_firstname
    				, lname.meta_value AS user_lastname
    				,nick.meta_value AS nickname
    				,descr.meta_value AS user_description
    				,capab.meta_value AS wp_capabilities
    				,karma.meta_value AS total_karma
    				,FIND_IN_SET(karma.meta_value, (SELECT  GROUP_CONCAT(DISTINCT ranking.meta_value ORDER BY ranking.meta_value  DESC) FROM " . $db_prefix . "usermeta AS ranking WHERE ranking.meta_key = '" . $db_prefix . "_dpa_points')) as rank
    			FROM " . $db_prefix . "users AS person
    			LEFT JOIN " . $db_prefix . "usermeta as fname
    				ON person.id = fname.user_id
    				AND fname.meta_key = 'first_name'
    			LEFT JOIN " . $db_prefix . "usermeta as lname
    				ON person.id = lname.user_id
    				AND lname.meta_key = 'last_name'
    			LEFT JOIN " . $db_prefix . "usermeta as nick
    				ON person.id = nick.user_id
    				AND nick.meta_key = 'nickname'
    			LEFT JOIN " . $db_prefix . "usermeta as descr
    				ON person.id = descr.user_id
    				AND descr.meta_key = 'description'
    			LEFT JOIN " . $db_prefix . "usermeta as capab
    				ON person.id = capab.user_id
    				AND capab.meta_key = '" . $db_prefix . "capabilities'
    			LEFT JOIN " . $db_prefix . "usermeta as karma
    				ON person.id = karma.user_id
    				AND karma.meta_key = '" . $db_prefix . "_dpa_points'
    		WHERE 1 = 1";
    	if ($current_user_id)
    	{
    		$leaderboard_query .= "
    			AND ID = " . $current_user_id;
    	}
    	$leaderboard_query .= "
    		ORDER BY total_karma DESC
    			,person.user_registered ASC";
    	if ($current_user_id)
    	{
    		$leaderboard_query .= "
    		LIMIT 0, 1;";
    	}
    	else
    	{
    		$leaderboard_query .= "
    		LIMIT " . $offset . ", " . $posts_per_page . ";";
    	}
    	$leaderboard["results"] = $wpdb->get_results($wpdb->prepare($leaderboard_query, null));
    	$sql_posts_total = $wpdb->get_var( "SELECT FOUND_ROWS();" );
        $leaderboard["total_number_of_pages"] = ceil($sql_posts_total / $posts_per_page);
    
        return $leaderboard;
    }
    
    function dpa_leaderboard_data($fields, $protectedfields, $data)
    {
    	$html = '';
    	foreach ($data["results"] as $row)
    	{
    		$html .= '<tr>';
    		for ($i=0; $i<count($fields); $i++)
    		{
    			if (((strpos($protectedfields, $fields[$i]) > 0)
    					&& is_user_logged_in())
    				|| (strpos($protectedfields, $fields[$i]) === false))
    			{
    				switch ($fields[$i])
    				{
    					case "rank":
    						$html .= '<td>' . $row->rank . '</td>';
    						break;
    					case "profile_picture":
    						//var_dump($row->id);
    						$html .= '<td>' . get_avatar($row->id, 39) . '</td>';
    						break;
    					case "bbpress_profile_link":
    						$html .= '<td><a href="/forums/users/' . $row->user_nicename . '">' . $row->display_name . '</a></td>';
    						break;
    					case "karma":
    						$html .= '<td>' . $row->total_karma . '</td>';
    						break;
    					case "user_id":
    						$html .= '<td>' . $row->ID . '</td>';
    						break;
    					case "user_login":
    						$html .= '<td>' . $row->user_login . '</td>';
    						break;
    					case "user_nicename":
    						$html .= '<td>' . $row->user_nicename . '</td>';
    						break;
    					case "user_email":
    						$html .= '<td>' . $row->user_email . '</td>';
    						break;
    					case "user_url":
    						$html .= '<td>' . $row->user_url . '</td>';
    						break;
    					case "user_registered":
    						$html .= '<td>' . $row->user_registered . '</td>';
    						break;
    					case "user_status":
    						$html .= '<td>' . $row->user_status . '</td>';
    						break;
    					case "display_name":
    						$html .= '<td>' . $row->display_name . '</td>';
    						break;
    					case "user_firstname":
    						$html .= '<td>' . $row->user_firstname . '</td>';
    						break;
    					case "user_lastname":
    						$html .= '<td>' . $row->user_lastname . '</td>';
    						break;
    					case "nickname":
    						$html .= '<td>' . $row->nickname . '</td>';
    						break;
    					case "user_description":
    						$html .= '<td>' . $row->user_description . '</td>';
    						break;
    					case "wp_capabilities":
    						$matches = null;
    						$matches_html = "";
    						preg_match_all('/"([^"]+)"/', $row->wp_capabilities, $matches);
    						for ($j=0; $j<count($matches[1]); $j++)
    						{
    							if (strpos($matches[1][$j], "bbp_") === false)
    							{
    								if (strlen($matches_html) > 0)
    								{
    									$matches_html .= ", ";
    								}
    								$matches_html .= ucfirst(strtolower($matches[1][$j]));
    							}
    						}
    						if (strlen($matches_html) == 0)
    						{
    							$matches_html = "?";
    						}
    						$html .= '<td>' . $matches_html . '</td>';
    						break;
    				}
    			}
    		}
    		$html .= '</tr>';
    	}
    
    	return $html;
    }
    
    function dpa_get_leaderboard($attr)
    {
    	extract(
    		shortcode_atts(
    			array(
    				'achievements' => 'all',
    				'categories' => 'all',
    				'fields' => 'rank,profile_picture,bbpress_profile_link,wp_capabilities,karma,user_email,user_registered',
    				'titles' => 'Rank,Avatar,Name,Authority,Points,Email,Member Since',
    				'protectedfields' => 'user_email,user_registered',
    				'width' => '100%',
    				'showcurrentuser' => 'true',
    				'resultlimit' => 'none',
    			),
    			$attr
    		)
    	);
    	$fields = split(',', $fields);
    	$titles = split(',', $titles);
    	$html_blankrow = '<tr class="blank">';
        $html = '
    <table id="roster" width="' . $width . '">
    	<tr>';
    	for ($i=0; $i<count($titles); $i++)
    	{
    		$html_blankrow .= '<td>?</td>';
    		if (((strpos($protectedfields, $fields[$i]) > 0)
    				&& is_user_logged_in())
    			|| (strpos($protectedfields, $fields[$i]) === false))
    		{
    			$html .= '<th>' . $titles[$i] . '</th>';
    		}
    	}
    	$html .= '</tr>';
    	$html_blankrow .= '</tr>';
    	if (($showcurrentuser == 'true') && is_user_logged_in())
    	{
    		$current_user = wp_get_current_user();
    		$current_user_html = dpa_leaderboard_data($fields, $protectedfields, dpa_get_leaderboard_rankings($current_user->ID));
    		if (strlen($current_user_html) > 0)
    		{
    			$html .= $current_user_html;
    			$html .= $html_blankrow;
    		}
    	}
    	$leaderboard = dpa_get_leaderboard_rankings();
    	$html .= dpa_leaderboard_data($fields, $protectedfields, dpa_get_leaderboard_rankings());
    	$html .= '</table>
    	<div class="navigation">
        <div class="previous panel">' . previous_posts_link('? Previous Page', $leaderboard["total_number_of_pages"]) . '</div>
        <div class="next panel">' . next_posts_link('Next Page ?', $leaderboard["total_number_of_pages"]) . '</div>
    </div>';
    
    	return $html;
    }
    add_shortcode('dpa_leaderboard', 'dpa_get_leaderboard');

    Something like this: [dpa_leaderboard]

    You can customize it according to the fields in dpa_leaderboard_data, for example:
    [dpa_leaderboard fields="rank,profile_picture,karma,user_email" titles="Position,Avatar,Points,Email" protectedfields="user_email"]

    By default, the following is shown (if you don’t specify anything):

    'fields' => 'rank,profile_picture,bbpress_profile_link,wp_capabilities,karma,user_email,user_registered',
    				'titles' => 'Rank,Avatar,Name,Authority,Points,Email,Member Since',
    				'protectedfields' => 'user_email,user_registered',

    As you can see in dpa_get_leaderboard(), you can specify width, as well as showing the current user (if logged in) separately at the top of the list.

    Let me know how this works for you.

    Thread Starter mikebronner

    (@mikebronner)

    That is odd. Paul is working on this for a future release, I believe. I have updated the code quite a bit as well for my own use since originally posting this, now using a short-code and optimized the query quite a bit.

    To get to the bottom of why the #59 rank is included in the top 10 you would need to take a look at the SQL query and debug that. Sorry that I can’t be of more help at the moment.

    Thread Starter mikebronner

    (@mikebronner)

    I have submitted this to the GitHub bugs list.

    *BUMP* I really need this as well. ??
    We automatically FTP images every hour to the server, and would like to import them into WordPress automatically as well. Is there a way to run the plugin directly via a URL in a cron job?

    Thread Starter mikebronner

    (@mikebronner)

    Hi Paul, been having more thoughts on this, as this is something that I will need in the coming months. One thought at the moment is adding it as meta-data, and dealing with the functionality where it checks if this event already occurred or not. If it did occur, then it the meta-data will be updated to reflect the number of times the achievement was awarded, as well as increase karma points accordingly. This could perhaps be enabled by a toggle on the achievement admin page to determine if that particular achievement can be awarded multiple, or up to a certain amount of times.

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